can1357/oh-my-pi · error · ToolError
no window matches ${JSON.stringify(selector)}
Error message
no window matches ${JSON.stringify(selector)} What it means
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.
Source
Thrown at packages/coding-agent/src/tools/computer/worker.ts:680
},
displays: async (): Promise<DesktopDisplay[]> => {
const { signal } = getContext();
return await nativeCall(signal, () => session.listDisplays());
},
windows: async (filter?: WindowFilter): Promise<DesktopWindow[]> => {
const { signal } = getContext();
return (await nativeCall(signal, () => session.listWindows())).filter(window =>
matchesFilter(window, filter),
);
},
window: async (selector: string | WindowFilter): Promise<Win> => {
const { signal } = getContext();
const windows = await nativeCall(signal, () => session.listWindows());
const matches =
typeof selector === "string"
? windows.filter(window => window.id === selector)
: windows.filter(window => matchesFilter(window, selector));
if (matches.length === 0) throw new ToolError(`no window matches ${JSON.stringify(selector)}`);
if (matches.length > 1) {
const candidates = matches
.map(window => `${window.id} ${window.app} ${JSON.stringify(window.title)}`)
.join("\n");
throw new ToolError(`multiple windows match ${JSON.stringify(selector)}:\n${candidates}`);
}
return makeWin(matches[0]!);
},
focusedWindow: async (): Promise<Win | null> => {
const { signal } = getContext();
const window = (await nativeCall(signal, () => session.listWindows())).find(candidate => candidate.focused);
return window ? makeWin(window) : null;
},
screenshot: (options?: ScreenshotOptions) => captureScreenshot(session, getContext, "desktop", options),
click: desktopTarget.click.bind(desktopTarget),
doubleClick: desktopTarget.doubleClick.bind(desktopTarget),
move: desktopTarget.move.bind(desktopTarget),
drag: desktopTarget.drag.bind(desktopTarget),View on GitHub (pinned to 9690622007)
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.
Example fix
// before
const win = await desktop.window('firefox-main');
// after
const [w] = await desktop.windows({app: 'Firefox'});
if (!w) throw new Error('Firefox not running');
const win = await desktop.window(w.id); Defensive patterns
Strategy: validation
Validate before calling
const candidates = await desktop.windows(filter);
if (candidates.length === 0) throw new Error(`no window for ${JSON.stringify(filter)}`); Try / catch
try {
const win = await desktop.window(selector);
} catch (err) {
if (String(err?.message).startsWith('no window matches')) {
// enumerate and retry with a live id
} else throw err;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- multiple windows match ${JSON.stringify(selector)}:\n${candi
- Computer session tool bridge is unavailable
- Computer session is closed
- read-only run: '${method}' requires read_only: false
- Assertion failed
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/d032cfd15139f439.
Report an issue: GitHub.