Repository navigation
Description
Context
Implementation is on main through PR #721, squash 35fb78d4. This issue remains open for the physical-device and live-agent checks listed below.
The original problem:
The agent sometimes needs the user's order of preference over a set of items. Examples:
- which of these five trips to do first
- rank these talk ideas for the next submission
- order these films by how much you want to see them
- prioritise these backlog items
Before this change, neither structured-input tool could express this:
ask_user(ASK_USER_INPUT_SCHEMA,packages/ui-sdk/src/tool-contracts/bridge.ts:77-78) only offers single-select or multi-select over 2–4 options per question (bridge.ts:63-67). A multi-select answer comes back as an unordered comma-separated label string (packages/ui-sdk/src/protocol.ts:1367-1371), so picking in a particular order carries no meaning.- The bulk list tool shipped by ui-sdk: a bulk ask_user — one scale applied to a list of items, answered in one card #583 applies one shared scale to many items. That gives buckets, not an order, and ui-sdk: a bulk ask_user — one scale applied to a list of items, answered in one card #583 lists ranking as out of scope.
- The kit and PWA previously had no reorderable-list primitive.
packages/ui-kitandpackages/ui-reacthave no drag or sortable dependency, and the earlier pointer-drag code was in the image viewer (packages/ui-react/src/components/images/image-viewer.tsx).
The agent therefore had to ask for the order in prose, and has to parse "3 first, then 1, then … actually swap the last two".
Scope
- Tool: a new bridge tool,
ask_user_rank, defined next toask_userinpackages/ui-sdk/src/tool-contracts/bridge.ts. Input:promptitems: 2–15 entries, each with a stableid, alabel, and optionaldetailandlink, given in the agent's suggested starting order- optional
cutoff: "only the top N matter", after which the rest may stay unranked
- Protocol:
ServerAskUserRankRequest/ClientAskUserRankResponsein@schlessera/brain-ui-sdk, with schemas. The response hasorder, a list of every item id top to bottom, andunchanged: boolean. If the user submits the starting order untouched, that is recorded explicitly so the agent can tell agreement from indifference. - Card: a kit component plus its ui-react binding. It shows a reorderable list with one Submit. Reordering follows the posted design: touch drag on the handle, tap a row then tap its target, and focus-scoped keyboard controls, so it works for keyboard and screen-reader users. The answered state shows the final numbered order.
- Both backends: the Claude bridge and the pi bridge (
packages/ui-backend-pi/src/bridge-tools.ts) expose the tool. - Replay: the exchange survives a reload like an
ask_user_listexchange does. Composer text remains an ordinary message, as for bulk lists and grouped questions; no typed ranking is inferred. Dismiss usesask_user_cancel.
Out of scope
- Ties or tiers ("these two are equal"). Buckets are ui-sdk: a bulk ask_user — one scale applied to a list of items, answered in one card #583's job.
- Pairwise comparison flows ("A or B?" repeated).
- Weighted scores or points allocation.
- Changing
ask_user, or folding ranking into it. - Any domain logic that acts on the order. The tool returns the order, and the skill or agent uses it.
Acceptance criteria
- The agent sends 6 items in one call, and the tool result carries the full
orderof all 6 ids plusunchanged. A ui-sdk contract test covers this. - Every reorder done by dragging can also be done without dragging, and a test reorders a list using only keyboard or the button controls.
- Each row's control has an accessible name that includes the item label and its current position ("Arrival, position 2 of 6"), and moves are announced.
- At 320px width, 15 items reorder without horizontal scroll, and drag handles meet the D34 touch-target reach. Checked by a visual baseline.
- Dragging a row does not scroll or pull-to-refresh the page underneath it on a touch device.
- With
cutoff: N, the card marks the line after position N, and the response still lists every id. - Submitting the untouched starting order returns
unchanged: true. - Reloading the session shows the answered exchange as its final numbered list.
- Tool schema token cost is measured and stated in the PR, since the bridge surface is budgeted (ui-sdk:
show_block's input schema is 5270 tokens — 72% of the whole bridge surface #155, ui-sdk: the bridge briefs cost 655 tokens a turn and their reason expired with D44 — re-measure them #157). Live count completed: rank 597 tokens; brief 54 tokens / 1 line; all seven always-loaded schemas 10,322 tokens and briefs 792 tokens / 32 lines against the 682-token measured floor, usingclaude-sonnet-5and the actual registered MCP schemas on 2026-09-30. This was a free token-count request, without model generation.
Verification
- ui-sdk contract and schema tests; a ui-kit story and visual baseline at 320px and desktop; ui-react interaction tests for pointer drag, keyboard reorder, cutoff and replay.
- Manual on a phone: ask the agent to "rank these five weekend trips", drag two, move one with the buttons, submit, and check the agent's reply follows exactly that order.
Contract impact
Additive: a new bridge tool, new protocol frames, schemas and a kit component. The integration contract lists them. ask_user is unchanged.
Related: #583 (bulk scale over a list, now shipped). The two should share row anatomy (label, detail, link) so a list looks the same whether it is being rated or ranked.
2026-09-30 readiness correction: verified citations on main a01c3895, updated the moved response lines and shipped #583 context, linked the decided tap/drag/keyboard design, and reconciled composer behavior with the existing list exchange. The design’s Android Chrome and iOS Safari check and the requested phone/agent exercise remain required; automated emulation does not replace them.
Required human verification
Desktop Chromium validation is complete: both themes, native touch reorder/cancel and transcript scrolling, 320px with fifteen items, keyboard paths, accessible names/live announcements, cutoff, kept order, replay, and composer focus. The PR records the exact automated and mutation evidence. Physical Android/iOS sessions and an authorized live phone-agent session were unavailable in this work environment.
- On Android Chrome and iOS Safari, drag a handle through a fifteen-item card toward both transcript edges. Confirm scrolling stops at the card edge, no pull-to-refresh occurs, and touching the row body scrolls normally. Cancel a moved row with pointer cancellation, Escape where applicable, and a second finger; confirm restoration of the prior order and the cancellation announcement.
- On a phone with an authorized live agent, ask it to rank five fictional weekend trips, drag two items, tap one into place, submit, and confirm the agent reply follows the exact submitted id order. Check an unchanged order and top-N cutoff as well; all ids must remain in the result.
- Record browser/OS versions, submitted and returned id orders, and sanitized results for scrolling/cancellation and the agent reply. Public evidence must exclude credentials and deployment details.
After those results satisfy the unchanged criteria and chosen design, remove needs: human and close this issue with the completion evidence. Restore agent-ready only if a scoped implementation fix remains.
2026-10-01 implementation handoff: recorded the merged implementation and completed live schema-token count; retained physical Android Chrome/iOS Safari and phone-agent verification as required. Follow-up findings are #719 (date mismatch), #724 (duplicate-id emission ordering), and #725 (scrape-browser test budgets/cleanup).
2026-10-01 triage: refreshed the ordinary ask_user schema, option bounds and answer-semantics pointers against main 0c0c9dfb. The recorded seven-tool token count remains a historical measurement from 2026-09-30, before the form tool landed; it is not the current eight-tool roster budget. Required physical-device/live-agent verification remains unchanged.
2026-10-01 triage at d9e64c9e40e8eab45e60197603c785b416725ff7: Repaired the existing unordered ask_user answer description. The ranking implementation is delivered; required physical-device/live-agent receipts remain needs: human.
Activity
schlessera commentedon Sep 29, 2026
Design needed: how reordering reads and works on a 320px touch screen, with and without dragging.
The tool contract and behaviour are decided in the body. What is left is the interaction: a drag handle per row, a long-press to lift, tap-to-pick-then-tap-to-place, or up/down buttons only. That choice decides whether ranking 15 items on a phone feels quick or fiddly, and whether the non-drag path is first-class or an afterthought. The code cannot decide it.
schlessera commentedon Sep 29, 2026
#585 originally proposed replacing this standalone tool with a node kind of
ask_user_form. Superseded by the maintainer decision of 2026-09-29: this remains a standalone tool, usable individually. The form can reuse its row controls as a node kind; it does not replace its tool contract.Updated 2026-09-29 to reflect the decision.
schlessera commentedon Sep 29, 2026
Ranked
ask_user— put a list in order (ask_user_rank)The agent proposes some items and wants them in order of preference. The
example is five weekend trips. Today the user types "3, 1, 5, 2, 4" and hopes
it gets parsed right. This card makes reordering 5 items effortless and 15
items manageable, one-handed on a phone, with a way to do all of it without
dragging.
Rows share the anatomy of the bulk scale card (#583,
docs/bulk-ask-user.md). They have one header, one action row, and a Submitthat never does nothing silently (#541).
Sources read:
ui-kit/src/decisions/AskUserCard.tsx(header, action row,answered well),
ui-react/.../images/image-viewer.tsx→viewer/zoom-viewer.tsx(the only pointer code),design-kit.mdD34, D35,D36 + addendum, D37 §6, D38 §1, §4, §10, and
docs/bulk-ask-user.md.Precedent taken from
ZoomViewer: hand-rolled pointer events,setPointerCaptureon pointerdown, andtouch-action: noneon the gesturesurface only. That last one is why the browser hands over every pointer
instead of scrolling the page, with no
preventDefaulton the touch path.The difference here is that the surface is a handle, not the whole card.
The card sits in a transcript that scrolls, so the rest of the card has to
keep scrolling it.
1. Primary gesture: tap-to-move, with a drag handle as the accelerator
Ruling: both are always there, and they're equal. Neither one is
"advanced".
and the gutter number becomes
●. Then tap the row whose place itshould take. It moves into that position, and everything between shifts
by one. Tapping the picked-up row again puts it back. There are no extra
"drop here" slots: the target is the whole row, as big as a row.
⠿, at the end of the row) to move a row in onegesture. The handle alone has
touch-action: none. It lifts onpointerdown with no long-press delay, because it only does one thing.
Rationale. The transcript scrolls, so the row body has to stay a scroll
surface. That rules out long-press anywhere: it has to fight the
scroller for every touch, and it collides with text selection and the
iOS/Android context menu. It's also invisible until you know it's there.
A drag handle is the gesture people expect, and it's precise for short
moves. But a long move at 320px needs edge autoscroll under a thumb, and
that's the hardest part of any drag to get right. Tap-to-move costs two
taps for any distance. It needs no precision or autoscroll. It works the
same with a mouse, a finger, a switch device or a screen reader, and it
is the path that never needs dragging (§2). So it can't be hidden behind
the handle.
Cost to get from A B C D E to C A E B D (the "3, 1, 5, 2, 4" example):
Drag is the faster gesture only for moves you can see. Tap-to-move is never
slower than 2 per move. That's why it's the one that's always there, and
why "buttons only" isn't needed.
Drag rules ("dragging never scrolls the page"):
touch-action: noneon the handle, andsetPointerCaptureon pointerdown.The browser never starts a scroll or pull-to-refresh, because the touch
never becomes a pan. While a drag is active, the transcript scroller gets
overscroll-behavior: containas a second guard.other rows slide 150ms to open the gap, instantly under
prefers-reduced-motion.the pointer is within 48px of the transcript's visible top or bottom
edge, we scroll the transcript at up to 12px per frame. It stops as soon
as the card's own edge comes into view. The page never scrolls past the
card.
pointercancel,Escor a second finger cancels the drag. The row goesback to where it was, and the live region says "Move cancelled".
end.
2. Non-drag path: tap-to-move, always visible; ▲▼ only for the keyboard
The non-drag path is tap-to-move (§1), and it's always there because it
uses the row itself. There's nothing extra to reveal. Once a row is picked
up, a one-line hint appears in the action row's place:
Tap where Lisbon should go · Cancel. It stands in for Submit, so you can't submitmid-move. After the drop, Submit comes back.
Not chosen:
132px of controls against about 190px of label. It's also O(distance) taps.
case (tap the row, tap fix(core): sync post-sync owns the caches its reindex rewrites #1).
taps like tap-to-move, but the picker hides the list you're ordering.
The keyboard gets ▲▼ equivalents as keys (§7), not as buttons.
3. Row anatomy (the same as #583's)
1–15.●whenthe row is picked up.
–when it's below the cutoff (§4). The number isthe row's state, so it's never colour-only.
truncates.
has a link, exactly as in ui-sdk: a bulk ask_user — one scale applied to a list of items, answered in one card #583. The full text is in
aria-describedby.wraps rather than ellipsising, and it's its own tap target. A tap on the
link opens the link. It never picks the row up.
::beforereach to 44 × rowheight. Horizontally it can reach only half the gap to the link (D34), so
the link always ends 16px short of the handle's column.
~190 + handle 44 + gaps.
What truncates at 320px: only the detail line on a row that has a link.
Labels, positions and hosts never truncate.
4. Cutoff: a line that says what it means, and nothing fades
When
cutoffis set, a rule sits after row N:opacityas de-emphasis). They're the candidates you might promote, sothey must stay easy to read. The only difference is the gutter:
–inplace of a number, since they're not ranked. The line itself is the
thing that reads as secondary.
is announced: "Seville is now 3. Porto dropped below the top 3."
user.
5. Unchanged Submit: yes, different words
Dismiss·Keep this orderDismiss·Reset·Submit orderTap where Lisbon should go·CancelRationale. Submitting the agent's own order is a real answer ("your guess
was right"). It's also the likeliest accident, because the card arrives
already filled in. "Submit" on an untouched list reads as though something
was done. "Keep this order" says exactly what the agent will be told. It
sends, so it's not a no-op; the words just match the act. It is also what
the contract's
unchanged: truerecords: the words the user tapped are thefact the agent receives. "Keep this order" is shown whenever the current
order equals the starting order, including after moving a row away and
back, or after Reset. So the label and
unchangedcan never disagree.Resetappearsonly once the order has changed, and it puts back the agent's order in one
tap, with an
InlineToastoffering Undo (D38 §4).6. Answered state: the final list, with the tail collapsed at 15
RANKED NorKEPT BRAIN'S ORDER. That's the one fact a reader scrolling back needs.are dropped, because the record is the order.
shown in full. After them comes one disclosure row,
▸ 10 more, in order,which is allowed under D38 §10 because it opens the record. Opened, the
rest wrap one per line.
▸ 12 not ranked.about 1,000px while pending.
typedanswer (D38 §1).Dismissed is the kit's lapsed row with "Ask again".
7. Keyboard (D36, focus-scoped)
The list is one roving group, so it's one Tab stop, followed by Reset and
Submit.
↑↓/jkSpace/Enter↑↓HomeEndEscAlt+↑Alt+↓1–9(any-pointer: fine)(D36 addendum), in thecard footer:
space pick up · ↑↓ move · 1–9 place. The Settings switchfor single-key shortcuts turns off
j/kand the digits. Arrows,Space,EnterandAlt+arrowsalways work.8. Accessible names and announcements
listbox-free: alistlabelled by the prompt, rows arebuttons in a roving groupA polite live region announces every move once, when the row is dropped:
The drag handle isn't the path for screen readers. Double-tapping the row
picks it up, which is the same tap-to-move path.
9. Contract: what the design reads, and findings
The design reads
prompt,items[].id,items[].label,items[].detail?,items[].link?,cutoff?, and the items' order as sent.It writes
order(all ids) andunchanged.orderlists every id even with a cutoff, andthe agent knows the
cutoffit sent, soorder[0..N)is the ranked part.Below the line,
orderkeeps the agent's sequence apart from the user'smoves, as drawn.
unchangedis covered in §5.links go throughclassifyLink. Thehost shown always comes from the verdict.
typed)answer has to be stated in the protocol.
controls or move to top per row" as the non-drag path. This design uses
tap-to-move in their place (§1–§2): every row is a button, so a pick
plus a target is two button presses for any distance, including to the
top. ▲▼ exist as keys (
Alt+↑↓, and↑↓while picked up), not aspainted buttons. The acceptance criterion "a test reorders a list using
only keyboard or the button controls" is met by both. If the maintainer
wants painted ▲▼ anyway, they fit only by revealing them on the
picked-up row, since at 320px they'd take 88px from every label.
10. Mocks
320px mocks are 42 columns (about 288px of card). Desktop mocks are 86
columns (about a 640px card in the 720px transcript column).
▓marks thepicked-up or dragged row.
10.1 5 items: untouched
320px
Desktop
10.2 5 items: mid-drag (Porto from 3 → 1)
320px, with the thumb on Porto's handle, dragged up past Lisbon:
Desktop: the same state. The cursor is
grabbing, and the lifted rowkeeps its full width.
10.3 5 items: submitted
320px
Desktop. It stays one column, because a multi-column list reads in the
wrong direction for an order:
Untouched and submitted, the header reads
✓ ANSWERED · KEPT BRAIN'S ORDER.10.4 15 items, cutoff 3
320px, pending (Seville picked up by tap, about to be tapped onto #2):
Desktop, pending (one line per row):
Answered, both widths:
10.5 The keyboard path (desktop) and the tap-only path (320px)
Desktop keyboard. The goal is A B C D E → C A E B D. Porto (C) is at 3.
That's 7 keys, with no pick-up needed for jumps. The same thing by
pick-up:
Space ↑ ↑ Spacefor Porto, thenj j j j Space ↑ ↑ SpaceforSintra.
320px tap-only, the same goal in 4 taps:
11. Tokens and themes
Everything comes from the kit (D39). The card, head and answered well are
AskUserCard's. Rows sit onsurface. The picked-up row israisedwithan
inset 0 0 0 1pxaccent hairline and the kit's drop shadow; there's noborder (D34). The handle grip is
ink-mute, andinkon hover through.bk-control:hover. The cutoff rule is aline-colour hairline with anink-dimlabel. Below-cutoff rows keep body ink (noopacity, D35). Lightand dark come from the same tokens, and the
FourStatesopacity sweepextends to the new stories.
12. Acceptance criteria
touch-action: none. A touch on the row body scrolls the transcript.pointercancel/Escrestores the row's original position and announces it.–in the gutter.unchanged: true. The label follows order equality, not whether anything was touched. After a change it reads "Submit order", and Reset appears.jkmove focus,Space/Enterpick up and drop,Alt+↑↓nudge,1–9place, andEsccancels.(any-pointer: fine), and the Settings switch turns off letters and digits.order.orderandunchanged.13. Kit and story work
ui-kit/src/decisions/AskUserRankCard.tsx: reusesAskUserCard's head,box, answered well and lapsed row, and ui-sdk: a bulk ask_user — one scale applied to a list of items, answered in one card #583's row anatomy (factor
DecisionRow: gutter, label, detail, host, trailing slot, used by bothcards). Pointer handling follows
ZoomViewer: refs for live gesturestate,
setPointerCapture,touch-action: noneon the handle only.RankUntouched,RankMidDrag(a static frame),RankPickedUp,RankAnswered,RankKept,RankFifteenCutoff(pending +answered), and
RankKeyboard(a play that runs §10.5 and asserts theannouncements). Each runs at 320 and
wide, in both themes.ui-react: a new binding for the rank request, next to ui-sdk: a bulk ask_user — one scale applied to a list of items, answered in one card #583's.schlessera commentedon Sep 30, 2026
Claiming #584 for a dedicated work-issue run. Claim token:
584-01a0f278. Intended branch:feat/584-ask-user-rank-01a0f278. I will verify the current citations, shared list-card anatomy and mobile verification requirements before implementation; other checkouts remain untouched.schlessera commentedon Sep 30, 2026
Readiness checked on
a01c3895: #583 is shipped, #541 is closed, and #585 retains ranking as a standalone tool. The body now carries current citations and the posted tap/drag/keyboard design. Composer sends stay ordinary messages, consistent with the existing list/group exchange; no order is inferred from prose. The handler will require a complete permutation of the requested IDs and deriveunchangedfrom equality with the initial order, rather than trusting a client claim. Real Android Chrome/iOS Safari checks, the phone/agent exercise and live schema token measurement remain required verification; independent implementation and keyless checks proceed first.schlessera commentedon Sep 30, 2026
Merged PR #721 as
35fb78d40542426b9bac4a1c3a2a32cf43803837; verified onmain. Final headcf40fce9passed all ten CI jobs plus contract/project checks: 7,862 Bun passes / 45 skips / zero failures and 1,634 browser passes. The merged implementation and test files match the tested tree; its only additional change is main’s README-only PR #723.The ranked-input contract, both backends, host/socket exchange, card/binding, replay, keyboard/touch paths, API reports, shared rating/ranking text anatomy, and minor changeset are complete. Free live schema count is recorded in the PR: rank 597 tokens, brief 54; all seven always-loaded tools 10,322, briefs 792.
Keeping #584 open with
needs: human, removingagent-ready, and releasing claim584-01a0f278. The body now specifies the remaining Android Chrome/iOS Safari scrolling/cancellation checks and the authorized live phone-agent exercise, with exact completion evidence. These requirements have not been waived. Follow-ups #719, #724 and #725 retain the unrelated findings.schlessera commentedon Oct 1, 2026
2026-10-01 triage — Refreshed the ordinary ask_user input-schema anchor. Ranked-input implementation is present at the inspected main SHA; physical Android/iOS and live phone-agent checks remain required, with their criteria unchecked. Source inspected at main
35fb78d40542426b9bac4a1c3a2a32cf43803837.schlessera commentedon Oct 1, 2026
2026-10-01 triage: repaired the moved ask_user schema/option/answer pointers against main
0c0c9dfb. Clarified that the recorded seven-tool token count is historical now that PR #749 adds the independent form tool. No phone or live-agent receipt has appeared;needs: humanand the full remaining verification stay in place.schlessera commentedon Oct 1, 2026
2026-10-01 triage at
d9e64c9e40e8eab45e60197603c785b416725ff7: Repaired the existing unordered ask_user answer description. The ranking implementation is delivered; required physical-device/live-agent receipts remain needs: human.schlessera commentedon Oct 1, 2026
2026-10-01 triage at main
3f0870d5338c9139f9bb53050847c23974662a00: repaired the ordinary multi-select answer-semantics citation. The ranked tool is delivered; its physical Android/iOS and phone-agent receipts remain required under needs: human. Historical schema measurements stay dated.schlessera commentedon Oct 6, 2026
Physical-device verification: Android Chrome
Run on an Android phone in Chrome, against a live agent session in the hosted PWA.
Check 1: touch drag on a fifteen-item card
Check 2: live agent, five fictional weekend trips
order=canal, glacier, treehouse, lighthouse, vineyard,unchanged: false; agent reply restated exactly that order. Passorder= starting order,unchanged: true. Passcutoff: 2unchanged: false. PassAlso observed: dismissing a card returns
User dismissedto the agent.Remaining
schlessera commentedon Oct 6, 2026
Closing with Android Chrome as the accepted physical-device platform: it is the primary target, and every check in the Required human verification section passed there (see the comment above). An iOS Safari run is waived for now; reopen or file a follow-up if an iOS-specific problem shows up.