(evt)
| 199 | |
| 200 | const worktreesInUse = (): Set<string> => |
| 201 | new Set( |
| 202 | agentManager |
| 203 | .list() |
| 204 | .map((s) => s.worktree) |
| 205 | .filter((w): w is string => typeof w === 'string'), |
| 206 | ); |
| 207 | |
| 208 | // ── Open in OS ──────────────────────────────────────────────────────────────── |
| 209 | // Reveal a worktree path in the OS file browser. Only paths under the worktree root |
| 210 | // are allowed — the engine is loopback-only but must never shell `open` on an |
| 211 | // arbitrary path. Keeps UI clients pure-web (no Tauri opener API needed). |
| 212 | app.post('/api/open', async (c) => { |
| 213 | const { path: target } = (await jsonBody(c)) as { path?: string }; |
| 214 | const root = worktreesRoot(); |
| 215 | const resolved = path.resolve(target ?? ''); |
| 216 | if (resolved !== root && !resolved.startsWith(`${root}${path.sep}`)) { |
| 217 | return c.json({ error: 'path is not under the worktree root' }, 403); |
| 218 | } |
| 219 | try { |
| 220 | const opener = process.platform === 'darwin' ? 'open' : 'xdg-open'; |
| 221 | await execFile(opener, [resolved]); |
nothing calls this directly
no test coverage detected