fix(native): retain unknown UI executable identity

This commit is contained in:
morluto committed 2026-10-24 04:38:08 +08:00
1 parent 85292fdb26
commit a51a9228be
4 files changed
+26 -5

No files matched your search

+1 -1
View File
@@ -49,7 +49,7 @@ func observe(_ request: Request) async throws -> [String: Any] {
guard let url = app.executableURL else {
try fail("application-executable-unavailable", "The selected application does not expose an executable URL; select a PID with an identifiable application executable")
}
guard let canonicalPointer = realpath(url.path, nil) else { try fail("target-mismatch", "Running executable path cannot be resolved") }
guard let canonicalPointer = realpath(url.path, nil) else { try fail("executable-path-unavailable", "Running executable path cannot be resolved") }
defer { free(canonicalPointer) }
let canonicalExecutable = String(cString: canonicalPointer)
guard canonicalExecutable == request.executable else {
+4 -2
View File
@@ -738,8 +738,10 @@ including unsafe integers, negative zero and non-finite numbers, remain null
with a path-specific gap and incomplete capture coverage. Null alone does not
establish that an accessibility value was successfully read or absent.
An initial PID or window selection refusal is `invalid_request` on `pid` or
`window_id` and leaves provider availability intact. Identity or window loss
An initial PID or window mismatch is `invalid_request` on `pid` or
`window_id` and leaves provider availability intact. An unavailable executable
URL or unresolved executable path leaves identity unknown and reports
`capability_unavailable`. Identity or window loss
after the initial capture remains an observation failure with collected facts.
Permission and other helper failures retain their specific remediation text.
-1
View File
@@ -52,7 +52,6 @@ const responseSchema = z.discriminatedUnion("ok", [
]);
const initialSelectionFields = new Map<string, "pid" | "window_id">([
["pid-not-application", "pid"],
["application-executable-unavailable", "pid"],
["target-mismatch", "pid"],
["window-mismatch", "window_id"],
["ambiguous-window", "window_id"],
+21 -1
View File
@@ -137,7 +137,6 @@ it("keeps native UI availability after initial selection errors and preserves la
const { client, replies, snapshot } = await connectNativeUi();
for (const [code, field] of [
["pid-not-application", "pid"],
["application-executable-unavailable", "pid"],
["target-mismatch", "pid"],
["window-mismatch", "window_id"],
] as const)
@@ -219,3 +218,24 @@ it("keeps native UI availability after initial selection errors and preserves la
});
await client.ping();
});
it.each([
"application-executable-unavailable",
"executable-path-unavailable",
])("preserves unknown executable identity from %s", async (code) => {
const { client, replies } = await connectNativeUi();
const message = `Fixture ${code} diagnostic`;
replies.push({ ok: false, code, message });
const response = await client.callTool({
name: "observe_native_ui",
arguments: scope,
});
expect(parseMcpToolError(response)).toMatchObject({
error: {
code: "capability_unavailable",
message,
details: { reason: `${code}: ${message}` },
},
});
await client.ping();
});