Skip to content

Speed up loading long conversations#13098

Open
acarl005 wants to merge 6 commits into
masterfrom
andy/fix-restore-long-convo-latency
Open

Speed up loading long conversations#13098
acarl005 wants to merge 6 commits into
masterfrom
andy/fix-restore-long-convo-latency

Conversation

@acarl005

Copy link
Copy Markdown
Contributor

Description

Linked Issue

  • The linked issue is labeled ready-to-spec or ready-to-implement.
  • Where appropriate, screenshots or a short video of the implementation are included below (especially for user-visible or UI changes).

Testing

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

Screenshots / Videos

Agent Mode

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

@cla-bot cla-bot Bot added the cla-signed label Jun 26, 2026
@oz-for-oss

oz-for-oss Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

@acarl005

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 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 targets long-conversation restore latency by adding an exchange-id index, reducing restored AI-block subscriptions, and bulk-inserting restored command blocks.

Concerns

  • The new exchange-id index is not invalidated on all mutation paths, so lookups can miss or panic after exchange IDs change or tasks are removed.
  • Restored AI blocks no longer subscribe to settings changes that their render path reads, so toggling thinking/orchestration display modes may leave historical blocks stale.
  • Restored command blocks no longer disable reset-grid checks before parsing serialized command/output, which can reintroduce Windows ConPTY reset-grid assertions.
  • This is a user-facing performance/restore behavior change, but the PR description does not include manual testing evidence or screenshots/screen recording demonstrating the long-conversation restore path end to end.

Verdict

Found: 0 critical, 4 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

}

/// Returns the exchange with the given ID in O(1) time.
pub fn exchange_by_id(&self, exchange_id: AIAgentExchangeId) -> Option<&AIAgentExchange> {

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] The new index can go stale because existing mutation paths like modify_task (used by reassign_exchange_ids) can change exchange IDs without changing the exchange count, and remove does not rebuild it. Rebuild or invalidate this map for every task/exchange mutation before using it for exchange_by_id.

Comment thread app/src/ai/blocklist/block.rs Outdated
}
ctx.notify();
}
AISettingsChangedEvent::ThinkingDisplayMode { .. }

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] These display-mode events are still user-visible for restored output: output::render reads AISettings::thinking_display_mode, and orchestration message collapse state also depends on AI settings. Keeping this subscription inside the live-only branch means restored historical blocks can stay stale after the setting changes.

self.active_block_mut().start_background(None);
} else {
self.active_block_mut().start();
self.active_block_mut().disable_reset_grid_checks();

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 call disabled ConPTY reset-grid checks on the restored block before parsing its serialized command/output. After removing it, the remaining calls run only on the fresh placeholder created after restoration, so Windows restored blocks can hit the reset-grid assertion again.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This isn't needed. Callers that pass BootstrapStage::RestoreBlocks already get PerformResetGridChecks::No from Block::new (because RestoreBlocks.is_done() == false), so there is no Windows ConPTY reset-grid assertion risk during parse_bytes.

@acarl005 acarl005 force-pushed the andy/fix-restore-long-convo-latency branch from d685745 to 2cce665 Compare June 26, 2026 23:01
@acarl005 acarl005 force-pushed the andy/fix-restore-long-convo-latency branch from 2cce665 to 3078048 Compare June 26, 2026 23:21
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