Skip to content

Ask Patch: start a session by typing on the empty screen - #138

Merged
JBlaak merged 8 commits into
mainfrom
ask-patch
Oct 18, 2026
Merged

JBlaak merged 8 commits into
mainfrom
ask-patch

Conversation

@JBlaak

@JBlaak JBlaak commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

Closes #135

What

  • The box: a text box sits under Patch on the empty screen and is focused whenever the screen comes into view. It isn't focused while a dialog is open or the session list holds the keyboard. Enter sends, Shift+Enter adds a new line, and it grows to about 5 lines.
  • Routing: main runs claude -p --model haiku with structured output through the user's shell, using their subscription login. Haiku gets the local projects (no remotes, no worktrees), each with its folder name and five newest session titles, plus the text as typed. A path Haiku invents is dropped (src/domain/ask/route.ts).
  • Startup time: the call skips the user's settings, MCP servers and slash commands, and replaces Claude Code's system prompt with the routing instructions (--setting-sources "" --strict-mcp-config --mcp-config '{"mcpServers":{}}' --disable-slash-commands --system-prompt …). That took a call from about 8 s and ~388k tokens to about 3 s and ~2k. --bare would go further, but it never reads the subscription login. In the real app a routed call answered in 3.1 s.
  • The wait: Patch shows a thinking line and the box locks. Esc kills the call's process group and unlocks the box. Only one call runs at a time, a new one cancels the old, and there's a 30 s timeout.
  • Outcomes:
    • Confident: the session starts in that project with its default options.
    • Not sure: up to three candidates with the rewritten prompt underneath. Enter starts, ↑/↓ picks, Tab opens the New Session picker, Esc goes back to editing.
    • No match, failure or usage limit: Patch says why and the picker opens carrying the text exactly as typed.
  • The prompt: Haiku turns what was said to Patch ("let's fix X in Y") into a full request to Claude: one to three sentences with the goal and what done looks like, in the language it was typed in, naming no files or causes it can't see. The session starts on that alone.
  • launchClaudeSession(project, { initialPrompt }) and projectPicker { initialPrompt } carry a starting prompt. A plan picked in the picker ignores it, and so does a remote project, which can't take one yet.

Worth knowing

  • Cmd+A: with the box focused on the empty screen, Cmd+A would have become Select All. It opens the New Session picker while the box is empty, and selects the text once there is some.
  • Cmd+Arrow: the box claims it for the caret, so it doesn't step to another session mid-sentence. Cmd+N, Cmd+L, Cmd+S and Cmd+G still work from the box. A bare N now types an "n" on the empty screen instead of starting a quick session.
  • Focus after a dialog closes: on the empty screen, focus goes back to the box after any dialog closes. Before, it was left on the page body, and dialogs.spec.ts now expects the box.
  • Thinking pose: the Patch package has no thinking move, so the wait uses peek with a thinking line.
  • ARCHITECTURE.md doesn't mention domain/ask/ yet.

Tests

  • Unit:
    • test/ask-route.test.ts: candidates, argv, prompt, reading the CLI envelope (including a real error sample), validation, failure and usage-limit lines.
    • test/ask-route-service.test.ts: success, cancel, superseded call, timeout, non-zero exit, usage limit.
    • test/ask-slice.test.ts, test/ask-keys.test.ts: the box's phases, keys, focus rule, Cmd+A and Patch's lines.
  • E2e:
    • ask-patch.spec.ts: a confident start, choosing among candidates, Esc while thinking, and a usage-limit failure falling back to the picker.
    • The fake claude answers a routing call from a file the test writes, so these runs go through the real IPC, the shell and the parser.
  • Results: 1710 unit and 156 e2e tests pass locally. I also drove the dev app against the real CLI.

🤖 Generated with Claude Code

JBlaak and others added 8 commits October 18, 2026 20:28
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ts answer (#135)

routeCandidates offers local projects only, each with its last five Claude
session titles. routeArgs builds the Haiku call and skips the user's
settings, MCP servers and skills, which takes a call from ~8 s to ~2 s.
readRouteRun reads the CLI's JSON envelope and trusts no path that isn't a
candidate; composeInitialPrompt keeps the original under the rewrite.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A ClaudeCaller port runs one claude -p call through the user's shell in the
home directory and kills its whole process group on abort. AskRouteService
keeps one request in flight: a newer one or cancel() answers cancelled, 30 s
answers failed, and it never rejects.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…channels (#135)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…135)

A box under Patch on the empty screen, focused whenever the screen comes
into view. Enter sends the text to be routed; the box locks while Patch
thinks, and Esc cancels. A sure answer starts the session on the routed
prompt, an unsure one lists up to three projects to choose from, and
anything else opens the New Session picker carrying the text as typed.

The box's phases live in a new ask slice; launchClaudeSession and the
picker take an optional initial prompt. The route candidates are built
by a local placeholder until domain/ask/route lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…#135)

The fake claude answers a routing call from a file the test writes, so the
journeys run the real IPC, the user's shell and the answer parsing. With the
box holding the focus on the empty screen, Cmd+A would have become Select All
there; it opens the New Session picker while the box is empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the original (#135)

Trying it showed people talk to Patch ("let's change the font to Arial on
MoveLab Connect Web"), and a tidy-only rewrite left the session with a bare
"Change the font to Arial." Haiku now writes one to three sentences addressed
to Claude: the goal and what done looks like, still naming no files or causes
it can't see. The (Original: …) line is dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JBlaak
JBlaak merged commit 1bda358 into main Oct 18, 2026
5 of 6 checks passed
@JBlaak
JBlaak deleted the ask-patch branch October 18, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ask Patch: start a session by typing on the empty screen

1 participant