spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / diff / hooks / open-outcome / open-outcome-of.ts
GitHub Actions (publish-mods)chore: Update mods/ addd7a6 · 10 days ago History
25 lines · 781 BRaw
1import { isRecord } from '../is-record'
2import type { OpenOutcome } from './open-outcome.js'
3
4/**
5 * Reads what `$.ui.open` resolved: an unplaced pane is withdrawn, unless the
6 * reason starts `no-surface`, where the engine keeps it for a surface to come.
7 *
8 * An engine that resolves nothing, or never gives that reason, reads as
9 * before: placed, or withdrawn.
10 *
11 * @param opened what the open resolved
12 * @returns what the plugin does with the pane
13 */
14export function openOutcomeOf(opened: unknown): OpenOutcome {
15 const isUnplaced = isRecord(opened) && opened.isPlaced === false
16
17 if (!isUnplaced) {
18 return 'placed'
19 }
20
21 const isUnseen =
22 typeof opened.reason === 'string' && opened.reason.startsWith('no-surface')
23
24 return isUnseen ? 'awaited' : 'withdrawn'
25}