Repository navigation
fix(prompt): show Claude's words before its question card while it waits (#2088) - #2217
Conversation
…its (#2088) Claude Code 2.1.311 writes a turn's text to its session file only with the answer, so while an AskUserQuestion card waited Chat showed the question without the words Claude wrote right before it. The Claude question reader now reads that text block off the screen (a non-tool ● line and its two-column continuation, right over the question panel's rule), joins the pane's wrapping back, and hands it over as InteractivePrompt.screen_words, outside the card's id. The card shows it over the question with a caption that it comes from the terminal, and leaves it out once the transcript's last turn holds the question's call. Anything else over the panel, or a block whose start is above the screen, gives no words. Fixtures recorded live from Claude Code 2.1.311 at 119 and 40 columns.
) Review follow-up. The rule over the words must be the question panel's own (nothing but its header and question under it), a collapsed tool group ((ctrl+o to expand), bullet drawn or not, live 2.1.311 fixture) and a plugin's MCP call are no words, and wrapped lines are joined only between plain prose lines: a command, a path, a URL or a line after a colon keeps its break, and Chinese and Japanese go on without a space only where the line was full. The card hides its copy only when the transcript's waiting AskUserQuestion call asks this card's question, and keeps the words' indentation (pre-wrap).
…heses (#2088) Second review round: a line with a command option (--oneline, -rf) is never joined to another, a tool call's name is ASCII (so 패치(Patch)는 … stays Claude's text), and the hide rule reads the question call through askedQuestions instead of its own JSON parse.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 11 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
CodeRabbit hit its review limit on this head (639c652), so it did not review it. This PR adds an optional field to an HTTP contract ( omo-native-code-reviewer
Codex Sol 6.1 fast xhigh
Known limits (approved by Dori): words whose first line is above the screen's top show no words; a CJK or multi-paragraph question the pane wrapped may not match the transcript's call, so the card can repeat words the chat already shows (nothing wrong or lost). |
… turn in progress (#2088) Merge-pass review: wrapped lines are joined only in a paragraph that ends as a sentence does, so commands without options (git merge … over git push) keep their breaks; and the card leaves its words out only when the transcript's last turn is Claude's and its waiting AskUserQuestion call asks the card's question under its header with its options, so a call an interrupted earlier turn left waiting no longer hides the new words.
|
Fixed in 3030462, the two MEDIUMs from the merge pass review of 639c652:
|
…graph (#2088) Merge-pass review of 3030462: a paragraph that ended in a path with a period, or in a sentence right under the commands, still joined git merge experimental-feature-branch and git push at 40 columns. A line that opens with a common command (or a $ prompt), or is a path or file name alone, now keeps its breaks on both sides, read on its own.
|
Fixed in d486e91, the last MEDIUM from the merge pass review of 3030462.
Tests: "keeps command lines apart in a paragraph that ends in a path with a period" and "keeps command lines apart when text follows them with no blank line". Both fail on 3030462 and pass now. For the follow-up issue (LOW): a CJK or multi-paragraph question that the pane wrapped may not match the transcript's |
|
Fixed in d486e91, the last MEDIUM from the merge pass review of 3030462.\n\nThe parser now classifies each command/path line on its own, independent of paragraph punctuation or neighboring text. A standalone command (git merge experimental-feature-branch, git push) or path/file token keeps its line breaks, whether the paragraph later ends in a path with a period or continues immediately with prose. Both regressions reproduce and their tests fail on 3030462; the tests pass on d486e91.\n\nbun run check fast passed on d486e91 (8007 unit tests, 0 failures; typecheck and build passed). The branch is pushed.\n\nThe CJK/multi-paragraph duplicate-copy risk and the other LOW display findings are tracked in follow-up #2221: #2221. |
|
Merging d486e91 after three merge-pass review rounds, the last under the round cap. On 639c652, Codex reproduced two MEDIUMs: separate command lines were shown joined, and a stale question call in an earlier turn hid the new turn's words. The lane fixed both in 3030462, and in d486e91 command, $-prompt and lone-path lines keep their breaks whatever ends the paragraph; and words are hidden only when the last turn's waiting question matches the card's question, header and options. New tests for both fail on 639c652. The final-round review passes this head with no HIGH. Codex was at capacity for that round, so an omo reviewer on gpt-6.1-sol stood in. It confirmed both command-joining cases are fixed, ordinary prose still joins, and the question's id and options are unchanged. This PR adds an optional field to the HTTP/WS contract ( |
…#2220) Closes #1644 (part 2; part 1, the card under omp's status row, was #1812). Thanks @CharleoYang, whose #1528 found both parts and first matched the live menu to the open `ask` call. ## What it does for the user An omp Ask card now shows the question and its options in the agent's own Markdown: bold, italics, code, strikethrough, lists, a fenced code block, and links in the question. A question that omp cuts at four rows with `…` shows in full on the card. When the card cannot prove which call is on screen, it shows the screen's text exactly as before, and the terminal is still one click away. ## How - `server/omp-ask.ts` `ompMarkdownPrompt`: the session's one open `ask` call (`ompAsksAfter` in `server/omo-ask.ts`) gives the card its text only when the call is provably the menu on screen. One of its questions, with every option's label and description in order, must be drawn exactly as the screen shows it. - The call's Markdown is read by a CommonMark parser, as omp's own is: `Bun.markdown.render`, built into the Bun the app pins (1.4.2). Its callbacks follow omp's renderer (pi-tui `ask-dialog.ts` and `components/markdown.ts`, omp 18.12.6 to 18.13.2): - emphasis, strikethrough and code show their text, and an unpaired or escaped mark (`*.log`, `_cache/`, `\*`) stays; - a link shows its words, and in the question its address after them; - list items take omp's `- ` or `N. `, and a heading of level 3 or more keeps its `#`s. A table, quote, rule, HTML block or task list, or a block inside a label, leaves the card as drawn. So do an HTML entity and a pair of single tildes (`~x~`): Bun decodes and strikes them, but omp draws them as written. - The card draws the same characters: the chat's own Markdown scanner (now `shared/markdown.ts`, which `PromptCard` renders with) is not CommonMark. It reads `Keep *.log and *.tmp` as emphasis and keeps the backslash of an escaped mark. So a field is Markdown only when that scanner draws exactly the text omp drew; otherwise the card stays as drawn. A picture always keeps the screen's card: omp draws its alt text, the card the picture or its address. - The screen's text keeps every character, and every run of spaces counts as one (omp wraps and pads its rows). So a difference of one `/`, `*`, `_`, a space, letter case or a punctuation mark leaves the card as drawn. A question may match by its start only when omp says it cut it: the question fills its four rows and omp's footer offers `<key> expand` (pi-tui `#expandHint`). At a width where the footer itself is cut, the card stays as drawn. - It also fails closed for: - no open call, or more than one; - no matching question, or more than one; - an answered call or a later turn; - an option with a preview (omp draws it into the option's rows); - a description omp cut at its two rows. - The card keeps the screen's id and answer keys, so POST `/api/pane/prompt/answer` still answers the menu on screen. Only the chat's own read (`readPrompt`) asks the session; an answer's re-reads do not. - New optional field `InteractivePrompt.text_format: "markdown"` (`shared/protocol.ts`). An older client shows the raw Markdown text. - `src/components/PromptCard.tsx` draws the question with the chat's Markdown renderer. Labels and descriptions use a new `InlineMarkdown`, which has no links or pictures, since a row answers when pressed. - `src/lib/promptText.ts` `optionName` is the one reading of an option's name. An omp Markdown card shows its label whole (a link to `recommended` is never the Recommended tag), and its words are `shownText` (`shared/markdown.ts`), which the server's check against omp's screen uses too. - `src/lib/promptAnswer.ts`: a message typed in the chat names an option of a Markdown card only by the words the card shows, with spacing collapsed as the page does (``Use `local` socket`` is "use local socket"). One option's raw Markdown can be the words another option shows. Words that name two options pick neither, on any card. - `src/lib/promptText.ts` `polledPrompt` (used by ChatView's poll): a card with the same id takes Markdown that arrives after its first read, and lets withdrawn Markdown go, keeping its edits. - `shared/askQuestions.ts`, `shared/markdown.ts` and `shared/markdownHtml.ts` moved unchanged from `src/lib`, and `fileUriPath` moved to `shared/fileUri.ts`. The server now reads the call, and checks the card's rendering, with the same code the chat uses, and the remote PC bundle (which carries `server/` and `shared/`, not `src/`) can load it. A new server convention fails on any import of `src/` from code the bundle carries. - The design follows the Claude and Codex apps, which render a question's Markdown in their question cards (DESIGN.md, Prompt card). ## Fixtures Real omp 18.12.6 and 18.13.2 screens at 120 and 60 columns: a single-select question, a four-row cut multi-select question, and an option with a preview. Each comes with its session file while the dialog waits and after it was answered. They were recorded with a fake model provider and a disposable omp home in the isolated herdr test session. Personal paths are replaced. ## Verification - `server/omp-ask.test.ts` (new): on main the module does not exist, so the test fails. With the change it passes: - Every fixture gives the Markdown card. The exceptions are the 60-column cut question, whose footer is cut before `expand`, and the preview screens; both stay as drawn. - Fail-closed cases: 22 variants of the open call, including every Codex reproduction (``local_socket`` in code, `/gui_de`, `Keep *.log`, `_cache/`, an HTML entity, `~x~`); a question that ends in its own `…`; a four-row question without omp's `expand`; and omp's review step. - Mutations that drop omp's cut proof, stop requiring the `expand` hint, drop the entity or tilde guard, or match raw labels first each make it fail. - `server/omp.contract.test.ts` (new case, waiting on herdr's events, `pane.output_matched` and `pane.agent_status_changed`, rather than polling): a stand-in omp draws the recorded 18.13.2 screen, and its session file is the recorded open call. GET `/api/pane/prompt` returns the Markdown card. Settling the call in the session gives the plain card. POST `/api/pane/prompt/answer` sends Down then Enter. Removing the wiring in `readKnownPrompt` makes it fail. - `src/lib/promptAnswer.test.ts`, `src/lib/promptText.test.ts` and `src/components/PromptCard.test.tsx`: new cases, each failing under its mutation or on the code before its fix. - Merge-pass round: the glob pair (in a label and in the question), an escape and a two-backtick code span now keep the screen card. A typed label naming two options picks neither, and a same-id card upgrades to its Markdown. Each test failed before its fix. - Live: an Ovis server on the isolated test session with a real omp 18.13.2 asking these questions. - `curl /api/pane/prompt` returns `text_format: "markdown"` with the raw Markdown. - In the browser at 1280 and 390 px wide, the card renders bold, code, the question's link and the list with its fenced block, with no links in the options and no overflow. - A pick pressed on the card reached omp (`prompt_matched=true outcome=ok`), and omp moved to its next question. - `bun run check fast`: green. ## Reviews Commit hashes before `5b01e9fa` name the branch before its rebase onto main `62662793`; the same commits are on the branch under new hashes. - omo-native-code-reviewer: APPROVE. Its three MEDIUMs are fixed in this PR: typed labels, server-path test coverage, and no session lookup during answers. - Codex Sol (`gpt-6.1-sol`, xhigh), three rounds: - Round 1 blocked on a HIGH (marks stripped inside code and URLs) and a MEDIUM (an authored `…` taken as omp's cut). - Round 2 blocked on two HIGHs (an unpaired `*`/`_` outside code, a typed raw label naming another option) and a MEDIUM (four rows alone taken as a cut). - Round 3 confirmed those fixed and blocked on a HIGH: Bun decodes HTML entities and reads `~x~` as strikethrough, where omp draws both as written. That is fixed by a guard with its two cases. - No fourth round on the matcher: under the project's rule for heuristic matchers, the last round's finding is fixed, and further mismatches need exotic inputs. - Merge-pass round (Codex BLOCK and omo MEDIUMs on `ca6bf3ba`), fixed in `663a835d`: the chat's scanner could show other characters than omp drew and name the wrong option; a same-id card never took late Markdown; the contract scenario polled. - Re-reviews of `663a835d`: Codex Sol found a picture in the question showing its address (MEDIUM), fixed in `c3545004`. omo found that `server/omp-ask.ts` imported `src/`, which the remote bundle does not carry (CRITICAL), fixed in `5f18f761`, with the convention in `c75f9e72`. - Final reviews of `c3545004` and `5f18f761`: Codex Sol APPROVE (it reproduced the bundle load itself) and omo APPROVE. omo's LOWs (stale path comments, the `fileUriPath` re-export) are fixed in `c75f9e72`. - Merge-pass round on `c75f9e72` (Codex HIGH: a link to `recommended` read as the Recommended tag; MEDIUM: spacing-only twins) and CodeRabbit's inline point (spaces removed in the comparison) are fixed in `5b01e9fa`. The branch is rebased onto main `62662793` (#2217). Re-review of `5b01e9fa`: Codex Sol APPROVE and omo APPROVE. ## Known limit A word omp breaks mid-way on a narrow pane (a long address) keeps the plain card, since the screen then has a space the call does not. Bun's CommonMark parser and omp's `marked` can still part on rare constructs not found yet. Almost every such case makes the call differ from the screen, and the card stays as drawn. For a call to lend Markdown that omp draws otherwise, the open call would have to differ from the menu on screen only in such a construct. Even then, the card keeps the screen's id and answer keys. ## Remote bundle `server/` and `shared/` changes are carried by the remote PC bundle. A bundle-shaped copy (`server`, `shared`, `integrations`, `node_modules`) of the final head loads `server/prompt.ts`. The same copy of `c3545004` failed with `Cannot find module '../src/lib/markdown.ts'`. `REMOTE_BUNDLE_VERSION` is not raised here: only a release PR raises it (docs/development.md, Releasing).
Closes #2088. Reported by @Xelanor.
Change
Claude Code 2.1.311 writes a turn's text, and its
AskUserQuestioncall, to the session file only when the question is answered. While a question card waited, Chat showed the question without the words Claude wrote right before it, and on a phone (where Chat is the only view) that context was missing.Following Dori's recommendation for this NEEDS-OWNER item: words are shown only when the question card itself is confirmed, read from the screen as provisional text, and Claude's own record replaces them once it arrives.
server/dialogs/claude.ts): the Claude question reader also reads the text block drawn right over the question panel's top rule (a●line that is not a tool call, its two-column continuation lines, and blank lines between paragraphs). It joins the pane's soft wrapping back and hands the result over as the new optionalInteractivePrompt.screen_words(shared/protocol.ts). The words are not part of the card's id, so answers still match (prompt_matched=truein the live run below).❯prompt, a tool's⎿output, a collapsed tool groupRead 2 files (ctrl+o to expand), an MCP or other tool call, a status line), no words are read. The same goes for a block whose●start is above the screen's top: its lines look exactly like the user's own wrapped prompt (the 40-column recording shows this), so they are left to the terminal. This is narrower than the issue's "show what the screen holds and say it is cut" edge case; Dori approved it as a known limit.$prompt, or a path/file token on its own) keeps its breaks independent of paragraph punctuation or neighboring prose. A command (any-x/--opt), a path, a URL, a code line, a list item or a line after a colon keeps its break as drawn. Korean joins at its spaces; Chinese and Japanese join without a space only where the line was full.PromptCardshows the words over the question, with a caption saying they come from the terminal until the agent saves the turn.screenWordsToShow(src/lib/promptText.ts) leaves them out once the transcript's last turn is Claude's and holds anAskUserQuestioncall still pending that asks this card's question under its header with its options (a same-worded call an interrupted earlier turn left waiting does not count). That covers a later Claude Code that writes the turn early: then the transcript wins.Design reference (src/AGENTS.md): this follows Claude Code's own terminal, which keeps those words above its dialog. The Claude app shows them as the turn's text, and the chat does the same once the transcript has the turn. DESIGN.md's Prompt card section has the entry.
Evidence
server/fixtures/claude-question-words-2.1.311-{120,40}.txt, recorded live from Claude Code 2.1.311 in an isolated herdr session. While the card waited, the session file had 0 assistant records and none of the words. They arrived only with the answer (25 → 42 lines).bun test server/dialogs/claude.test.ts: 27 pass, 7 of them new. On origin/main the three positive cases fail. The negative cases (user prompt or tool output right over the question, start above the screen) pass on both, by nature.src/lib/promptText.test.tsandsrc/components/PromptCard.test.tsx: new cases for the hide rule and the render.GET /api/pane/promptreturned 200 withscreen_wordsholding the two paragraphs from an 80-column pane while the session file had no assistant record. Browser screenshots at 1280×900 and 390×844 show the words above the question with no horizontal overflow. Answering Patch from the phone card went throughPOST /api/pane/prompt/answer(prompt_matched=true outcome=ok), the card closed, and the transcript showed Claude's own paragraphs in place.server/fixtures/claude-question-tools-2.1.311-43.txt(a question right under a collapsedRead 2 files (ctrl+o to expand)group). Over the live server it came with noscreen_words, andPOST /api/pane/prompt/answermatched it (prompt_matched=true).bun run check fast: green on the final head.Reviews
패치(Patch)는 …read as a tool call), round 3 APPROVE.Notes
server/andshared/.REMOTE_BUNDLE_VERSIONis raised by the release PR, per docs/development.md.