Skip to content

Add tab navigation and partial submission for question batches - #431

Merged
ilovepixelart merged 14 commits into
ilovepixelart:mainfrom
sproott:question-tabs
Nov 14, 2026
Merged

ilovepixelart merged 14 commits into
ilovepixelart:mainfrom
sproott:question-tabs

Conversation

@sproott

@sproott sproott commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Several questions in one call used to be asked one after another, with no way back to an earlier answer. They now share one tabbed form that ends in a Submit review. A lone question goes through the same form, without tabs.

  • Left/Right or Tab/Shift+Tab switch questions, matching Claude Code's tab keybindings. No key switches questions while the free-text editor is open. multiSelect uses Space to toggle and Enter to confirm, unlike Claude Code's Enter to toggle with a separate submit row. In a batch, Enter with nothing checked leaves the question unanswered, as in Claude Code.
  • Submitting a partial form keeps the answers and marks the rest skipped. Claude Code drops every answer here ([BUG] AskUserQuestion: partial submit discards all already-provided answers anthropics/claude-code#53249).
  • Esc cancels the whole call, with no answers. In the editor it goes back to the options.
  • On timeout, confirmed answers and checked options are sent, and the model is told once that the user may be away, even if every question was answered.

Third-party listeners on pi-code:question:v1 see a lifecycle change. Each question is offered once, on its first visit, and the offer stays live until that question is answered or the form closes, whichever tab has focus. A remote answer saves to its own question.

Rows, answers and per-question state are now tagged unions, replacing the isOther/wasCustom/index flags.

#435 (restyle) touches the same render code, so whichever of the two merges later needs a small rebase.

  • npm run check passes (Biome, strict tsc, Vitest)
  • Tests cover the change

🤖 Generated with Claude Code

@sproott
sproott marked this pull request as draft November 14, 2026 13:59
@sproott
sproott force-pushed the question-tabs branch 10 times, most recently from 943520b to 0da943f Compare November 14, 2026 15:58
Bold question text, a ❯ pointer, one hint line joined with " · " in
Claude Code's wording, and the header as a highlighted chip under the
top border instead of a [header] line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sproott
sproott marked this pull request as ready for review November 14, 2026 16:38
Several questions in one call now share one TUI form: Tab/Shift+Tab or
Left/Right move between questions and a Submit review, answers survive
navigation, and submitting with questions unanswered marks them skipped
while keeping the answers given. A cancel declines the whole call. Each
question keeps its own remote offer, and the idle timeout reports
confirmed answers plus checked options. A lone question goes through the
same form.

The question model becomes tagged unions (rows, per-mode state, answers)
in place of the isOther/wasCustom/index flags.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
render spliced the header chip into the cached lines after
buildQuestionLines returned, which left QuestionView.header and the
`[header]` branch unreachable. The chip is now built where the other
lines are, from the header passed in the view, and the splice and the
dead branch are gone.

The multiSelect hint named no navigation keys. It now reads
"Space to toggle · ↑/↓ to navigate · Enter to confirm · Esc to cancel".
The tabbed form takes the restyled overlay: the ❯ pointer, hints joined
with " · ", the question in bold and the header chip on a lone question.
Assertions that hard-coded the "> " pointer, the "•" hints and the
"[header]" line follow.
Biome reported cognitive complexity above 15 for receive,
handleQuestionInput, handleReviewInput and renderTabs.

- receive returns early on a remote cancel instead of nesting the rest.
- handleQuestionInput hands the editor keys to handleTypingInput and the
  checkbox toggle to toggleChecked.
- handleReviewInput tests its keys as one chain and takes the chosen
  entry from chooseReviewOption.
- renderTabs takes the visible range from a module-level tabWindow.

No behaviour changes.
With two questions, the first answered at the keyboard and the second by
a remote responder, the call stayed pending on the Submit tab: the form
submitted on a remote answer only when every question had been answered
remotely. On main the same sequence returned both answers.

A remote answer now submits the form whenever it leaves every question
answered, whoever answered the others. The per-question remotelyAnswered
flag existed only for the old condition and is removed.
A question of a batch was offered on pi-code:question:v1 only on its
first visit, so a user who jumped to the Submit tab left the remaining
questions never offered, and a listener holding several live offers had
nothing to tell which call or position each belonged to.

- Every question is offered before the form opens. The offers of a call
  with several questions carry an optional batch field: an id shared by
  the call, the 1-based index and the total. A single question's offer
  is unchanged and has no batch field.
- A reply accepted for an earlier question while a later one is still
  being offered is delivered when the form attaches, instead of being
  dropped after the settle handle returned true.
- docs/session-extras.md states what differs for batches: several live
  offers, an accepted answer the local user may still change before
  submit, and a remote cancel ending the whole call.
A multiSelect question confirmed with Alpha, revisited and given Beta
with Space but no Enter, rendered both boxes checked and its tab as
answered while the result reported only Alpha: the confirmed answer was
a snapshot that later toggles did not touch.

A toggle on a confirmed question now updates its answer, and the
question reads as unanswered while nothing is checked. Enter with
nothing checked still leaves a batch question unanswered. The two tests
that pinned the snapshot rule, on submit and on timeout, assert the
checked set instead.
Shift+Tab or Left on the first question landed on Submit, and Tab or
Right on Submit landed on the first question. Claude Code clamps: the
previous index is max(0, i - 1) and the next stops at the last tab.
Navigation now stops at both ends.

The test that reached Submit by pressing Left on the first question
presses Right twice instead.
The hint under a multiSelect question of a batch was 91 columns wide and
was truncated on an 80 column terminal, hiding "Esc to cancel".

A batch now names its navigation as "Tab/Arrow keys to navigate", the
wording of Claude Code's batch hint, in place of the separate arrow and
tab entries. The longest variant is 80 columns. A test renders every
variant (single, multiSelect, editor, batch, review) and asserts its
text and its visible width.
The tab bar sized its tabs with String.length, so a header of
double-width characters counted for half the columns it occupies. With
three nine-character CJK headers at 40 columns the bar kept two tabs,
overflowed, and truncation cut the active tab.

Tabs are measured with visibleWidth, so the visible range is chosen from
the columns each tab takes.
The form renders from its state on every call and keeps no line cache,
but one test was titled "reuses its cached lines at an unchanged width
until the host invalidates" and another's comment said the cache must be
keyed on width.

The first now asserts what holds without a cache: the same lines at an
unchanged width, the new state on the render after input with no
invalidate in between, and no change from an invalidate. The comment
states that render lays out at the width it is given.
docs/session-extras.md said Claude Code drops every answer on a partial
submit and that keeping them is a pi-code divergence. Claude Code
2.1.325 keeps the answered questions ("Your questions have been
answered: ...") and leaves the unanswered ones out; it reports "The
user did not answer the questions." only when nothing was answered.

The doc now states that, and the one real difference: pi-code names
each unanswered question as skipped in the result.
@ilovepixelart
ilovepixelart merged commit 3fea3ec into ilovepixelart:main Nov 14, 2026
12 checks passed
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.

2 participants