Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Detect MSIX-installed agent apps in OK Desktop on Windows (#3507)

mike-inkeep14a8c2763464
diff --git a/.changeset/win-msix-detect-fallback.md b/.changeset/win-msix-detect-fallback.md
new file mode 100644
index 000000000..453cf6382
--- /dev/null
+++ b/.changeset/win-msix-detect-fallback.md
@@ -0,0 +1,5 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+OpenKnowledge Desktop on Windows now detects MSIX-installed agent apps — including Claude's current Windows distribution and the ChatGPT (Codex) Store app. MSIX packages register their `claude://` / `codex://` link handler at install time but in a way Electron's protocol query can't see (it looks for a classic executable association, which MSIX never writes), so the "External apps" picker wrongly treated those apps as not installed even though the browser-mode picker on the same machine saw them. The desktop app now falls back to the same registry check the server uses, so both hosts agree.
diff --git a/packages/desktop/src/main/ipc-handlers.ts b/packages/desktop/src/main/ipc-handlers.ts
index 52e22f90d..acf20b64e 100644
--- a/packages/desktop/src/main/ipc-handlers.ts
+++ b/packages/desktop/src/main/ipc-handlers.ts
@@ -60,6 +60,18 @@ interface DetectProtocolDeps {
* package so detection logic stays in one place.
*/
runMacOsProbe?: (scheme: InstalledAgentScheme) => Promise<boolean>;
+ /**
+ * Windows fallback: `reg query HKCR\<scheme> /ve` — the same probe the
+ * web-host `/api/installed-agents` endpoint uses. Required because
+ * Electron's `getApplicationInfoForProtocol` rejects for MSIX-packaged
+ * apps: MSIX registers the scheme declaratively at install time but leaves
+ * `shell\open\command` empty, so `AssocQueryString(ASSOCSTR_EXECUTABLE)`
+ * finds no executable — permanently, even after the app has run (MSIX
+ * registry writes are virtualized). Claude's current Windows distribution
+ * and the ChatGPT/Codex Store app both hit this. Default implementation
+ * routes through `createOsProbe` so detection logic stays in one place.
+ */
+ runWindowsProbe?: (scheme: InstalledAgentScheme) => Promise<boolean>;
/**
* Linux fallback: `xdg-mime query default x-scheme-handler/<scheme>`.
* Non-empty stdout → installed. Default implementation uses `execFile`
@@ -76,6 +88,12 @@ const macOsProbeReal: (scheme: InstalledAgentScheme) => Promise<boolean> = creat
execFile as ExecFileLike,
);
+/** Default Windows registry probe — shared with the server-side install detector. */
+const windowsProbeReal: (scheme: InstalledAgentScheme) => Promise<boolean> = createOsProbe(
+ 'win32',
+ execFile as ExecFileLike,
+);
+
/** Type guard: `scheme` is one of the schemes the macOS probe knows how to check. */
function isInstalledAgentScheme(scheme: string): scheme is InstalledAgentScheme {
return (INSTALLED_AGENTS_SCHEMES as readonly string[]).includes(scheme);
@@ -130,15 +148,20 @@ export async function detectProtocol(
if (info.name && info.path) {
return { installed: true, displayName: info.name };
}
- // Empty `name` / `path` (Windows behavior) OR no LaunchServices default
- // handler set (macOS behavior — happens for apps that claim a scheme via
- // `Info.plist` but the user has never confirmed a default). Fall through
- // to the macOS osascript probe before declaring not-installed.
+ // Empty `name` / `path` OR no default handler resolvable. Fall through
+ // to the per-OS fallback probe before declaring not-installed: osascript
+ // name lookup on macOS (scheme claimed via `Info.plist` but no
+ // LaunchServices default confirmed), registry `URL Protocol` marker on
+ // Windows (MSIX apps register the scheme but expose no executable to
+ // `AssocQueryString`, so the Electron API rejects for them).
} catch {
// Promise rejected — same fall-through as the empty-info case below.
}
- if (deps.platform === 'darwin' && isInstalledAgentScheme(scheme)) {
- const probe = deps.runMacOsProbe ?? macOsProbeReal;
+ if (isInstalledAgentScheme(scheme)) {
+ const probe =
+ deps.platform === 'darwin'
+ ? (deps.runMacOsProbe ?? macOsProbeReal)
+ : (deps.runWindowsProbe ?? windowsProbeReal);
try {
if (await probe(scheme)) return { installed: true };
} catch {
diff --git a/packages/desktop/tests/main/ipc-handlers.test.ts b/packages/desktop/tests/main/ipc-handlers.test.ts
index 29cb7bac9..44af43fe9 100644
--- a/packages/desktop/tests/main/ipc-handlers.test.ts
+++ b/packages/desktop/tests/main/ipc-handlers.test.ts
@@ -53,6 +53,88 @@ describe('detectProtocol', () => {
expect(result).toEqual({ installed: true, displayName: 'Codex' });
});
+ test('Windows fallback: Electron rejects (MSIX app), registry probe returns true → installed:true', async () => {
+ let probedScheme: string | null = null;
+ const result = await detectProtocol(
+ {
+ platform: 'win32',
+ getApplicationInfoForProtocol: async () => {
+ // Electron's AssocQueryString path finds no executable for
+ // MSIX-registered schemes (empty shell\open\command) and rejects.
+ throw new Error('Unable to retrieve installation path to app');
+ },
+ runWindowsProbe: async (s) => {
+ probedScheme = s;
+ return true;
+ },
+ },
+ 'claude',
+ );
+ expect(probedScheme).toBe('claude');
+ expect(result).toEqual({ installed: true });
+ });
+
+ test('Windows fallback: Electron returns empty info, registry probe returns true → installed:true', async () => {
+ const result = await detectProtocol(
+ {
+ platform: 'win32',
+ getApplicationInfoForProtocol: async () => ({ name: '', path: '' }),
+ runWindowsProbe: async () => true,
+ },
+ 'codex',
+ );
+ expect(result).toEqual({ installed: true });
+ });
+
+ test('Windows fallback: Electron rejects AND registry probe false → installed:false', async () => {
+ const result = await detectProtocol(
+ {
+ platform: 'win32',
+ getApplicationInfoForProtocol: async () => {
+ throw new Error('no handler');
+ },
+ runWindowsProbe: async () => false,
+ },
+ 'cursor',
+ );
+ expect(result).toEqual({ installed: false });
+ });
+
+ test('Windows fallback: registry probe throwing is the same outcome as false', async () => {
+ const result = await detectProtocol(
+ {
+ platform: 'win32',
+ getApplicationInfoForProtocol: async () => {
+ throw new Error('no handler');
+ },
+ runWindowsProbe: async () => {
+ throw new Error('reg.exe timeout');
+ },
+ },
+ 'claude',
+ );
+ expect(result).toEqual({ installed: false });
+ });
+
+ test('Windows fallback: unknown scheme never consults the registry probe', async () => {
+ let called = false;
+ const result = await detectProtocol(
+ {
+ platform: 'win32',
+ getApplicationInfoForProtocol: async () => {
+ throw new Error('no handler');
+ },
+ runWindowsProbe: async () => {
+ called = true;
+ return true;
+ },
+ },
+ 'someotherscheme',
+ );
+ expect(called).toBe(false);
+ expect(result).toEqual({ installed: false });
+ });
+
test('returns installed:false when Electron rejects AND macOS osascript fallback returns false', async () => {
const result = await detectProtocol(
{
diff --git a/packages/server/src/handoff-api.test.ts b/packages/server/src/handoff-api.test.ts
index 195a741e2..a7d41b8e7 100644
--- a/packages/server/src/handoff-api.test.ts
+++ b/packages/server/src/handoff-api.test.ts
@@ -266,31 +266,25 @@ describe('createOsProbe', () => {
const { exec, calls } = makeExecFake({ osascript: { err } });
const probe = createOsProbe('darwin', exec);
expect(await probe('codex')).toBe(false);
- // Codex has two candidates; both must be probed before we conclude not-installed.
- expect(calls.length).toBeGreaterThanOrEqual(2);
+ // Every configured candidate must be probed before we conclude not-installed.
+ expect(calls.length).toBeGreaterThanOrEqual(1);
});
- test('macOS codex scheme tries "Codex" first, falls back to "OpenAI Codex"', async () => {
- // Sequential probe: first candidate fails with exit 1, second returns a bundle id.
+ test('macOS codex scheme probes only "Codex" — resolved via the app\'s alternate name', async () => {
+ // "Codex" resolves against the ChatGPT-branded app through its
+ // CFBundleAlternateNames; a candidate that fails leaves the probe false
+ // (no further candidates — 'OpenAI Codex' never resolved and 'ChatGPT'
+ // would false-positive on ChatGPT Classic).
const calls: Array<{ cmd: string; args: readonly string[] }> = [];
- let callIndex = 0;
const exec: ExecFileLike = (file, args, _opts, cb) => {
calls.push({ cmd: file, args });
- const index = callIndex++;
queueMicrotask(() => {
- if (index === 0) {
- // First candidate ("Codex") not found on this machine.
- cb(Object.assign(new Error('exit 1'), { code: 1 }), '', '');
- } else {
- // Second candidate ("OpenAI Codex") returns a bundle id.
- cb(null, 'com.openai.codex\n', '');
- }
+ cb(Object.assign(new Error('exit 1'), { code: 1 }), '', '');
});
};
const probe = createOsProbe('darwin', exec);
- expect(await probe('codex')).toBe(true);
- expect(calls[0]?.args).toEqual(['-e', 'id of app "Codex"']);
- expect(calls[1]?.args).toEqual(['-e', 'id of app "OpenAI Codex"']);
+ expect(await probe('codex')).toBe(false);
+ expect(calls.map((c) => c.args)).toEqual([['-e', 'id of app "Codex"']]);
});
test('macOS codex scheme resolves on first candidate when "Codex" matches', async () => {
diff --git a/packages/server/src/handoff-api.ts b/packages/server/src/handoff-api.ts
index da0eb33ef..01fb81327 100644
--- a/packages/server/src/handoff-api.ts
+++ b/packages/server/src/handoff-api.ts
@@ -44,7 +44,14 @@ const INSTALLED_AGENTS_PROBE_TIMEOUT_MS = 2000;
*/
const MACOS_APP_NAMES: Record<InstalledAgentScheme, ReadonlyArray<string>> = {
claude: ['Claude'],
- codex: ['Codex', 'OpenAI Codex'],
+ // The Codex app is branded "ChatGPT" since OpenAI's July-2026 merge, but
+ // 'Codex' still resolves: the app ships CFBundleAlternateNames=["Codex"],
+ // which LaunchServices honors on fresh installs. If a future build drops
+ // that alias this candidate dies silently — the scheme probe upstream still
+ // covers detection. Do NOT add 'ChatGPT' here: on a machine with only the
+ // legacy ChatGPT app (com.openai.chat, renamed "ChatGPT Classic", no codex
+ // handler) a name match would report an app that can't take the handoff.
+ codex: ['Codex'],
cursor: ['Cursor'],
};