Skip to content

feat(terminal): jump to latest agent message (#11816)#11924

Open
maxmilian wants to merge 9 commits into
warpdotdev:masterfrom
maxmilian:maxmilian/fix-11816-jump-to-latest-agent-message
Open

feat(terminal): jump to latest agent message (#11816)#11924
maxmilian wants to merge 9 commits into
warpdotdev:masterfrom
maxmilian:maxmilian/fix-11816-jump-to-latest-agent-message

Conversation

@maxmilian
Copy link
Copy Markdown
Contributor

@maxmilian maxmilian commented May 30, 2026

Description

Adds a "Jump to latest agent message" command (#11816). When you're in an agent conversation, ESC back to the terminal, and then run commands in the same thread, the agent's last message gets buried. This command takes you straight back to it.

Key behavior: agent messages only render inside the agent view — once you return to the terminal they collapse to a hidden, zero-height block. So there is nothing to scroll the terminal viewport to; the only way to actually show the latest agent message is to re-enter the agent view. This command does exactly that, re-entering the agent view for the most recent conversation (which lands on its latest message).

Note: an earlier draft of this PR tried to scroll the terminal block list to the agent's AIBlock. Testing showed that can't work — in terminal mode those blocks are should_hide / zero-height, so the jump landed on the collapsed conversation-entry marker and the message was never visible. Re-entering the agent view is the correct mechanism.

Implementation (minimal):

  • TerminalView::jump_to_latest_agent_message (app/src/terminal/view.rs): looks up the most recent conversation via BlocklistAIHistoryModel::last_conversation_id and calls the existing enter_agent_view_for_conversation. No-op when there is no agent conversation.
  • New AgentViewEntryOrigin::JumpToLatestAgentMessage (+ telemetry mapping in TelemetryAgentViewEntryOrigin) so this entry point is attributed correctly.
  • New no-arg TerminalAction::JumpToLatestAgentMessage, registered in the command palette (init.rs). No default keybinding.

It reuses enter_agent_view_for_conversation, which already handles the live / in-memory / load-from-disk conversation cases (with error toasts), so this adds no new state or traversal logic.

Questions for reviewers

  • Keybinding: registered with no default keystroke (command-palette only). Happy to bind whatever you'd prefer.

Linked Issue

Fixes #11816

Testing

  • I have manually tested my changes locally with ./script/run.

Repro: start an agent conversation → ESC to the terminal → run seq 1 400 (or git log) to bury the conversation → command palette → Jump to Latest Agent Message. The agent view re-opens on the most recent conversation, showing its latest message.

Screenshots / Videos

PR11924-jump-to-latest-agent-message-1.5x.mp4

Agent Mode

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

maxmilian and others added 5 commits May 30, 2026 10:20
Adds a pure model method that scans the block list from the tail and
returns the BlockIndex of the most recent visible AIBlock rich-content
item. Includes 4 unit tests covering empty, single, multiple, and
mixed-type cases (TDD: tests written first, confirmed failing, then
passing).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cla-bot cla-bot Bot added the cla-signed label May 30, 2026
@github-actions github-actions Bot added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label May 30, 2026
maxmilian added 3 commits May 30, 2026 14:40
…entView)

Agent messages (AIBlock) are hidden (should_hide, zero height) once you leave
the agent view back to the terminal; only the collapsed EnterAgentView entry
marker stays visible. Broaden latest_agent_block_index to return the latest
*visible* agent-related rich content so the jump works both in the agent view
(lands on the AIBlock) and after returning to the terminal (lands on the
visible conversation entry). Rename from latest_ai_block_index to reflect this.
"Jump to Latest Agent Message" re-enters the agent view for the most
recent conversation, landing on its latest message.

Agent messages only render inside the agent view; once you ESC back to
the terminal they collapse to a hidden, zero-height block, so scrolling
the terminal viewport can never reveal them. Re-entering the agent view
is the only mechanism that actually shows the message.

- jump_to_latest_agent_message: resolve the most recent conversation via
  BlocklistAIHistoryModel::last_conversation_id and enter its agent view
  through the existing enter_agent_view_for_conversation path. No-op when
  there is no agent conversation.
- Add AgentViewEntryOrigin::JumpToLatestAgentMessage (+ telemetry mapping)
  so the entry point is attributed correctly.
- TerminalAction::JumpToLatestAgentMessage, command-palette only, with no
  default keybinding.

This replaces the earlier terminal-scroll approach, which could not work:
in terminal mode the agent AIBlocks are hidden, so the jump only reached
the collapsed conversation-entry marker, never the message itself.

Fixes warpdotdev#11816
Address fresh-context review:
- Guard `jump_to_latest_agent_message` with `FeatureFlag::AgentView`, so
  it doesn't route into the agent-view-only `enter_agent_view_for_conversation`
  when the flag is off (matches `handle_continue_conversation` /
  `ResumeConversation` idiom).
- Drop the redundant trailing `ctx.notify()` — entering the agent view
  already emits its own events and dirties rich content.
@maxmilian maxmilian marked this pull request as ready for review May 30, 2026 17:03
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 30, 2026

@maxmilian

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

oz-for-oss[bot]
oz-for-oss Bot previously requested changes May 30, 2026
Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

Overview

Adds a command-palette action that re-enters Agent View for a recent conversation, along with the terminal action plumbing and telemetry attribution. The PR includes visual evidence, and the attached spec context contains no approved repository spec to validate against.

Concerns

  • The command currently chooses the last-created live conversation, which can differ from the conversation containing the latest or currently active agent message after users switch between conversations.

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 app/src/terminal/view.rs Outdated
Comment on lines +21849 to +21850
let Some(conversation_id) =
BlocklistAIHistoryModel::as_ref(ctx).last_conversation_id(self.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] last_conversation_id returns the last conversation created in this terminal, not the conversation with the latest or active agent message. If a user switches back to an older conversation and receives a newer response there, this command will still jump to the newer-created conversation; use active_conversation_id(self.id()) or the latest-exchange helper so the command follows actual agent activity.

Oz review: last_conversation_id returns the last-created conversation,
not the one with the latest/active agent message. Switching back to an
older conversation and receiving a newer response there would jump to
the wrong conversation. Use the history model's active_conversation_id
(most recently streamed, persists across ESC to terminal) and fall back
to last_conversation_id only when there is no active conversation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@maxmilian
Copy link
Copy Markdown
Contributor Author

Thanks for the review, @oz-for-oss — addressed the IMPORTANT concern in 0ab8e5a.

The command now follows actual agent activity instead of creation order: it uses the history model's active_conversation_id(self.id()) (the "currently or most recently streamed" pointer in active_conversation_for_terminal_view), falling back to last_conversation_id only when there is no active conversation.

  • This pointer is updated by set_active_conversation_id / mark_active_conversation_id on stream start and follow-ups, and is not cleared when the user presses ESC back to the terminal — so after burying the conversation and jumping back, it resolves to the conversation that last streamed, even if the user switched back to an older one.
  • It uses the history-model version (keyed by EntityId), not the AgentViewState one (which goes Inactive on ESC and would return None for this exact flow).
  • Consistent with the existing ToggleQueueNextPrompt / ForkConversationFromLastKnownGoodState handlers, which already prefer active_conversation_id(self.id()).

/oz-review

@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 31, 2026

@maxmilian

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

You can view the conversation on Warp.

I reviewed this pull request and requested human review from: @harryalbert.

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 dismissed their stale review May 31, 2026 04:04

Oz no longer requests changes for this pull request after the latest automated review.

Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

Overview

Adds a command-palette-only terminal action that re-enters Agent View for the active/latest conversation and wires telemetry for the new entry path.

Concerns

  • No blocking concerns found in the changed diff. Security review found no issues, and no approved spec context was available to compare against.

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

@oz-for-oss oz-for-oss Bot requested a review from harryalbert May 31, 2026 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-bookmark the last agent output so you can jump back after running commands

1 participant