{"record":{"id":"d032cfd15139f439","repo":"can1357/oh-my-pi","slug":"no-window-matches-json-stringify-selector","errorCode":null,"errorMessage":"no window matches ${JSON.stringify(selector)}","messagePattern":"no window matches (.+?)","errorType":"exception","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/computer/worker.ts","lineNumber":680,"sourceCode":"\t\t\t},\n\t\t\tdisplays: async (): Promise<DesktopDisplay[]> => {\n\t\t\t\tconst { signal } = getContext();\n\t\t\t\treturn await nativeCall(signal, () => session.listDisplays());\n\t\t\t},\n\t\t\twindows: async (filter?: WindowFilter): Promise<DesktopWindow[]> => {\n\t\t\t\tconst { signal } = getContext();\n\t\t\t\treturn (await nativeCall(signal, () => session.listWindows())).filter(window =>\n\t\t\t\t\tmatchesFilter(window, filter),\n\t\t\t\t);\n\t\t\t},\n\t\t\twindow: async (selector: string | WindowFilter): Promise<Win> => {\n\t\t\t\tconst { signal } = getContext();\n\t\t\t\tconst windows = await nativeCall(signal, () => session.listWindows());\n\t\t\t\tconst matches =\n\t\t\t\t\ttypeof selector === \"string\"\n\t\t\t\t\t\t? windows.filter(window => window.id === selector)\n\t\t\t\t\t\t: windows.filter(window => matchesFilter(window, selector));\n\t\t\t\tif (matches.length === 0) throw new ToolError(`no window matches ${JSON.stringify(selector)}`);\n\t\t\t\tif (matches.length > 1) {\n\t\t\t\t\tconst candidates = matches\n\t\t\t\t\t\t.map(window => `${window.id} ${window.app} ${JSON.stringify(window.title)}`)\n\t\t\t\t\t\t.join(\"\\n\");\n\t\t\t\t\tthrow new ToolError(`multiple windows match ${JSON.stringify(selector)}:\\n${candidates}`);\n\t\t\t\t}\n\t\t\t\treturn makeWin(matches[0]!);\n\t\t\t},\n\t\t\tfocusedWindow: async (): Promise<Win | null> => {\n\t\t\t\tconst { signal } = getContext();\n\t\t\t\tconst window = (await nativeCall(signal, () => session.listWindows())).find(candidate => candidate.focused);\n\t\t\t\treturn window ? makeWin(window) : null;\n\t\t\t},\n\t\t\tscreenshot: (options?: ScreenshotOptions) => captureScreenshot(session, getContext, \"desktop\", options),\n\t\t\tclick: desktopTarget.click.bind(desktopTarget),\n\t\t\tdoubleClick: desktopTarget.doubleClick.bind(desktopTarget),\n\t\t\tmove: desktopTarget.move.bind(desktopTarget),\n\t\t\tdrag: desktopTarget.drag.bind(desktopTarget),","sourceCodeStart":662,"sourceCodeEnd":698,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/computer/worker.ts#L662-L698","documentation":"Thrown by the computer tool's desktop.window(selector) API when the selector (a window id string or a filter object) matches zero open windows on the desktop. The tool enumerates all live windows via the native session and requires an exact unique match before returning a Win handle. This is a targeted 'selector matched nothing' error, distinct from the ambiguous-match error thrown when several windows match.","triggerScenarios":"Calling desktop.window('some-id') with a stale or nonexistent window id; calling desktop.window({app: 'Firefox'}) when no Firefox window is open; calling desktop.window({title: '…'}) with a title that no open window has; the target window was closed or minimized out of the enumeration between listing and selecting.","commonSituations":"Agent automation scripts referencing a window id captured earlier in the session that has since been closed; typos in app names; case-sensitivity mismatches in title filters; running on a headless or freshly rebooted machine where the expected app hasn't launched yet.","solutions":["List current windows with desktop.windows() (optionally with the same filter) and use an id or title from that live list.","Fix the selector: check spelling/case of the app or title filter, or use the exact window id string.","Launch or restore the target application before retrying the window() call.","Handle the error and fall back to focusedWindow() or the desktop target when a specific window isn't required."],"exampleFix":"// before\nconst win = await desktop.window('firefox-main');\n// after\nconst [w] = await desktop.windows({app: 'Firefox'});\nif (!w) throw new Error('Firefox not running');\nconst win = await desktop.window(w.id);","handlingStrategy":"validation","validationCode":"const candidates = await desktop.windows(filter);\nif (candidates.length === 0) throw new Error(`no window for ${JSON.stringify(filter)}`);","typeGuard":null,"tryCatchPattern":"try {\n  const win = await desktop.window(selector);\n} catch (err) {\n  if (String(err?.message).startsWith('no window matches')) {\n    // enumerate and retry with a live id\n  } else throw err;\n}","preventionTips":["Always select window ids from a fresh desktop.windows() call, never cache them across actions.","Prefer exact ids over partial title/app filters.","Launch the target app and confirm it appears in windows() before interacting.","Re-enumerate windows after any action that could open or close windows."],"tags":["computer-tool","window-selector","automation","desktop"],"backgroundTag":"window-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}