Skip to content

turn presentation: shared turn code names what to show, each frontend draws it; permission review builds again - #2101

Merged
trissim merged 2 commits into
mainfrom
fork-qt-acp-turns
Nov 18, 2026
Merged

trissim merged 2 commits into
mainfrom
fork-qt-acp-turns

Conversation

@trissim

@trissim trissim commented Nov 18, 2026

Copy link
Copy Markdown

Two changes.

1. Permission review could not be built (TUI regression)

c0f6983 put an abstract select_answer(index) on QuestionContext, but every caller runs context.question.select_answer(...). The method belongs to the question. PermissionsScreen is a context that hands off to its own PermissionsQuestion, so it could not be built ("abstract select_answer"). That broke the TUI's permission review, and three tests failed:

  • test_j_and_k_step_through_the_changes_from_the_question
  • test_a_request_changed_while_its_screen_push_is_pending_is_cancelled_or_shown_once
  • the native permissions layout test

The fix: a new ChoiceQuestion declares select_answer, and QuestionContext.question returns a ChoiceQuestion. Textual's Question and Qt's QtQuestion inherit both, since each is its own question. All three tests pass.

2. Shared turn code no longer builds Textual widgets

The shared turn code built Textual widgets itself:

Shared code Built
LocalTurnBinding.present_input UserInput
ResponseStream.create AgentResponse
ThoughtStream.create AgentThought
AgentFail.present ErrorNote
HelpAgentFail.present MarkdownNote
FailureLog.show_log AgentResponse link

So Qt couldn't draw a turn, and six of these lazy imports sat on the APK's KNOWN_LAZY list.

The contract. toad.turn_presentation declares the hooks:

  • present_user_input, response_block, thought_block, show_live_block
  • present_error_note, present_help_note, present_log_link
  • shows_live_output and after_live_output, which LiveOutput uses

The streams and failures decide what appears and call these hooks; LiveBlock is the block contract.

Textual: Conversation answers with the same widgets as before, so the TUI doesn't change.

Qt: QtConversation answers with history rows.

  • qt/live_turn.py's QtLiveBlock is one transcript event that grows in place.
  • It's drawn as a QtLiveFragment after the saved history and the draft, through the row delegate, so the sticky header and the reader's place work on it.
  • HistoryFragment.revision is the event count by default and the live text's revision here. It keys the row cache, so a growing row renders again.
  • A finished block leaves when the window's committed pages change.

KNOWN_LAZY: 21 → 15. check.sh reported all six chains GONE, and their lines are deleted.

Evidence (final head 53abce9, on main 526f26a)

  • New qt_drive scenario live_turn: on scratch-live-pipeline against the live bus, it feeds a Qt view an input row, a thought, a response streamed in three pieces, a failure and its help.
    • The response grows as one row ("The probe renders as rows.").
    • The thought closes when the response starts.
    • The failure flashes, and the note and help show as rows.
    • committed_pages_changed clears the finished blocks.
    • The render shows a User divider with the input bar, the muted thought, and an Agent divider over the response.
  • Other drives: tabs, composer and menu all exit 0 with no stray windows. composer's traceback is its intended forced send to #composer-drive-missing.
  • Gates:
    • Ratchet: bare classes 21/21, copies 0, Textual-UI 11/11.
    • shadow_check: 0.
    • tools/android/check.sh: exit 0 at 15/15.
  • TUI tests: a 30-file subset covering turns, failures, the log link, live output, questions and permissions.
    • Branch: 10 failed, 80 passed.
    • All 10 failures also fail on main: 9 in the same run, plus test_window_top_edge[size1], which fails on its own at both sizes on both trees, every time.
    • test_live_output_streams.py declares its own stream; it's updated to the new create(view, fragment).
    • Main's own full run hung on test_reader_position_in_live_output.py::test_reader_returns_to_the_same_session_after_a_switch. The template server waits on ProcessPoolExecutor workers that never exit: the preparation pool shutdown the feedback fork is fixing.

Not in this PR

Running an ACP agent on Qt. Qt launches with NoAgent (qt/window.py) and nothing calls binding.attach_to(...) on a Qt view. QtAcpSessionView only reopens a saved session, so no agent replies there today. This PR gives Qt the turn drawing; making an agent run on Qt is a separate port:

  1. A Qt surface binding: AttachedSurfaceBinding delivers agent events through Textual's post_message, and its terminal path builds a TerminalTool widget.
  2. Agent creation hoisted out of the Textual-side OperationalSessionSources.create_agent.
  3. QtAcpSessionView implementing AgentConversation, and the Qt session entry calling attach_to.
  4. A Qt launch or New Session path with AgentAttached.
  5. Qt permission review and terminal output.

Android can't run an ACP agent process in any case.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3

trissim and others added 2 commits November 18, 2026 01:28
c0f6983 put `select_answer(index)` on `QuestionContext` as an abstract method,
but every caller invokes `context.question.select_answer(...)`: the method is the
question's. `PermissionsScreen` is a context that delegates to its own
`PermissionsQuestion`, so it could not be built ("abstract select_answer"), which
broke the permission review in the TUI and three tests:
test_j_and_k_step_through_the_changes_from_the_question,
test_a_request_changed_while_its_screen_push_is_pending_is_cancelled_or_shown_once,
and the native permissions layout test.

`ChoiceQuestion` now declares `select_answer`; `QuestionContext.question` returns
one. Textual's `Question` and Qt's `QtQuestion` inherit both (each is its own
question); `PermissionsScreen` stays a context only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
…tend draws it

The shared turn code built Textual widgets itself: LocalTurnBinding.present_input
made a UserInput, ResponseStream/ThoughtStream.create made AgentResponse/AgentThought,
and AgentFail/HelpAgentFail/FailureLog made ErrorNote/MarkdownNote/AgentResponse.
Qt could not draw a turn, and six of those imports sat on the APK's KNOWN_LAZY list.

toad.turn_presentation declares the hooks: present_user_input, response_block,
thought_block, show_live_block, present_error_note, present_help_note,
present_log_link, plus shows_live_output/after_live_output for LiveOutput.
The streams and failures call them; LiveBlock is the block contract.

Textual's Conversation answers with its existing widgets (no behaviour change).
QtConversation answers with history rows: qt/live_turn.py's QtLiveBlock is one
transcript event that grows in place, drawn as a QtLiveFragment after the saved
history and the draft through the row delegate; HistoryFragment.revision (event
count by default, the live text's revision here) keys the row cache, so a growing
row re-renders. A finished block leaves when the window's committed pages change.

KNOWN_LAZY 21 -> 15. qt_drive live_turn feeds an input row, a thought, a response
streamed in three pieces, a failure and its help into a Qt view on the live bus.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
@trissim
trissim merged commit 9de70af into main Nov 18, 2026
1 of 2 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.

1 participant