Skip to content

Add AskUserQuestion support to the TUI#13830

Open
ianhodge wants to merge 1 commit into
graphite-base/13830from
ian/code-1846-answer-questions-tool-call
Open

Add AskUserQuestion support to the TUI#13830
ianhodge wants to merge 1 commit into
graphite-base/13830from
ian/code-1846-answer-questions-tool-call

Conversation

@ianhodge

@ianhodge ianhodge commented Jul 16, 2026

Copy link
Copy Markdown
Member

Description

Adds an interactive AskUserQuestion tool-call card to the headless TUI. The card shares the questionnaire state machine with the GUI, supports single-select, multiselect, numbered selection, custom “Other” responses, question navigation, and one-press Ctrl+C skip-all behavior. It also restores focus to the main input when the question action finishes and renders deterministic completed-answer summaries.

The implementation is rebased as one commit on harry/code-1822-tui-option-selector (PR #13716) and uses the refreshed generic editor/selector APIs.

Linked Issue

Testing

  • Manually tested locally with ./script/run-tui
  • cargo nextest run -p warp_tui — 303 passed
  • cargo nextest run -p ai ask_user_question_session — 17 passed
  • cargo clippy --workspace --exclude warp_completer --all-targets --tests -- -D warnings
  • cargo clippy -p warp_completer --all-targets --tests -- -D warnings
  • ./script/format --check
  • ./script/check_no_inline_test_modules
  • git diff --check

Review regressions:

  • Mixed single-/multi-select payloads retain the original action identity even though the shared session normalizes display order.
  • Clearing an existing Other response and navigating away removes the stale free-text answer.
  • Normal option selectors retain their committed selected-row styling independently of ask-question selection ids.
  • Completed summaries pair normalized questions with finished/API answers by question ID rather than vector position.

Screenshots / Videos

Exact TuiBuffer::to_lines() snapshot asserted by active_card_matches_question_panel_structure:

┌──────────────────────────────────────────────────────────────────────────────┐
│                                                                              │
│ ■ Agent questions                                                 ← 1 of 2 → │
│                                                                              │
│ Which targets should be tested? (select all that apply)                      │
│ (1)   Stable                                                                 │
│ (2)   Nightly                                                                │
│ (3) Other…                                                                   │
│                                                                              │
│ Enter or number to select  Tab or ← → to navigate  Ctrl + C to skip all      │
│                                                                              │
└──────────────────────────────────────────────────────────────────────────────┘

Authenticated real-PTY verification with ./script/run-tui:

  • Single-select: pressing 2 selected and submitted Option B.
  • Multiselect: rapid 1, 3, Canary, Enter submitted Stable plus Other: Canary; text did not leak into the main input.
  • Skip-all: one Ctrl+C skipped all three questions, resumed the model, and kept warp-tui running.

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

Agent artifacts

CHANGELOG-IMPROVEMENT: Warp's TUI can now answer interactive agent questions, including multiple-choice and custom responses.

Co-Authored-By: Oz oz-agent@warp.dev

@oz-for-oss

oz-for-oss Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

@ianhodge

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Copy link
Copy Markdown
Member Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ianhodge ianhodge mentioned this pull request Jul 16, 2026
2 tasks

@oz-for-oss oz-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR extracts the AskUserQuestion session state into shared AI code and adds a stateful TUI ask-question card with option-selector integration, keybindings, rendering, and tests.

Concerns

  • The TUI child view can be recreated repeatedly for mixed single-/multi-select payloads because matches_action compares the session's sorted question order to the original action payload order.
  • Navigating away from a cleared Other editor can leave the previous free-text answer in the session because blank active text is filtered to None and then not saved.
  • This is a user-facing TUI change, but the PR description does not include accepted TUI visual evidence. Please attach a terminal transcript, render_to_lines/TuiBuffer::to_lines snapshot diff, or ./script/run-tui capture demonstrating the flow end to end.

Verdict

Found: 0 critical, 3 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread crates/warp_tui/src/tui_ask_question_view.rs Outdated
Comment thread crates/warp_tui/src/tui_ask_question_view.rs Outdated

#[derive(Clone, Debug, Default, Eq, PartialEq)]
/// In-progress answer data for a single question while the user is editing.
pub struct QuestionDraft {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agent suggested factoring this out into a seperate file from the view, lmk if you agree with that logic

@ianhodge
ianhodge force-pushed the ian/code-1846-answer-questions-tool-call branch from ed4c16c to 8fb7cf0 Compare July 16, 2026 18:54
@ianhodge

Copy link
Copy Markdown
Member Author

/oz-review

@oz-for-oss

oz-for-oss Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

@ianhodge

I'm re-reviewing this pull request in response to a review request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR adds a shared AskUserQuestion session and wires an interactive AskUserQuestion card into the TUI, including option selection, Other text, navigation, skip-all, focus restoration, and completed summaries.

Concerns

  • The option selector now ignores its existing selected-row signal outside ask-question cards, which regresses normal option selector rendering for committed selections.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread crates/warp_tui/src/option_selector.rs Outdated
) -> Box<dyn TuiElement> {
let disabled = row.disabled_reason.is_some();
let label_style = if is_selected {
let is_selected = self.selected_ids.contains(&row.id);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [IMPORTANT] This shadows the is_selected argument with the question-only selected_ids set, which defaults empty for normal option selectors, so existing selectors stop styling their committed selection. Preserve the incoming selected state for non-question selectors, or OR it with self.selected_ids.contains(&row.id).

@ianhodge
ianhodge force-pushed the ian/code-1846-answer-questions-tool-call branch from 8fb7cf0 to 6c13f12 Compare July 16, 2026 19:23
@ianhodge

Copy link
Copy Markdown
Member Author

Addressed the latest selector-rendering review in 6c13f12. Outside ask-question cards, render_row now explicitly uses the existing selected-row signal; question cards continue to use selected_ids for multiselect state. Added normal_selector_selected_row_does_not_depend_on_question_selected_ids, which verifies the numeric prefix and label retain bold selected styling with empty question ids. Full warp_tui suite: 301/301 passed; both required clippy passes and formatting checks passed.

@ianhodge

Copy link
Copy Markdown
Member Author

/oz-review

@oz-for-oss

oz-for-oss Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

@ianhodge

I'm re-reviewing this pull request in response to a review request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR adds interactive AskUserQuestion support to the headless TUI, including a shared questionnaire session, TUI question card, option-selector integration, focus restoration, and TUI/unit coverage. The attached TUI snapshot and run-tui transcript satisfy the repo's visual-evidence requirement for this user-facing TUI change. No security findings were identified, and the provided spec context says no approved/repository spec context was found.

Concerns

  • Completed answer summaries can pair answers with the wrong question when question order differs between the session's normalized editing order and a finished result's action/API order.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

let mut content = TuiFlex::column();
content.add_child(self.render_summary(&label, answered > 0, app));
for (index, question) in self.session.questions().iter().enumerate() {
let answer = answers

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [IMPORTANT] Match answers by question_id here instead of by vector index. AskUserQuestionSession::new sorts questions for editing, but finished results can preserve the original action/API order; with a mixed single-/multi-select payload, answers.get(index) can render an answer beside the wrong question.

@ianhodge
ianhodge requested a review from harryalbert July 16, 2026 19:43
Co-Authored-By: Oz <oz-agent@warp.dev>
@ianhodge
ianhodge force-pushed the ian/code-1846-answer-questions-tool-call branch from 6c13f12 to 6f03d83 Compare July 16, 2026 19:47
@ianhodge

Copy link
Copy Markdown
Member Author

/oz-review

@oz-for-oss

oz-for-oss Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

@ianhodge

I'm re-reviewing this pull request in response to a review request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

Adds a shared AskUserQuestion session state machine and an interactive headless TUI card for answering agent questions, including option selection, custom Other answers, navigation, skip-all behavior, focus restoration, rendered summaries, and regression coverage.

Concerns

  • No blocking correctness, security, or spec-alignment concerns found in the attached diff. spec_context.md was empty, so there were no approved spec commitments to validate beyond the PR description.

Verdict

Found: 0 critical, 0 important, 0 suggestions

Approve

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@harryalbert
harryalbert changed the base branch from harry/code-1822-tui-option-selector to graphite-base/13830 July 16, 2026 22:12
@harryalbert harryalbert mentioned this pull request Jul 16, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant