Skip to content

Persist token count and scroll position across agent restarts#50620

Merged
eholk merged 3 commits intomainfrom
persist-token-count-and-scroll-position
Mar 3, 2026
Merged

Persist token count and scroll position across agent restarts#50620
eholk merged 3 commits intomainfrom
persist-token-count-and-scroll-position

Conversation

@eholk
Copy link
Copy Markdown
Contributor

@eholk eholk commented Mar 3, 2026

Release Notes:

  • Token counts and scroll position are restored when loading a previous agent thread

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 3, 2026
@zed-community-bot zed-community-bot bot added the staff Pull requests authored by a current member of Zed staff label Mar 3, 2026
@eholk eholk force-pushed the persist-token-count-and-scroll-position branch from 6de7065 to a8b2636 Compare March 3, 2026 18:22
eholk added 2 commits March 3, 2026 13:28
- Move scroll handler from ConnectionView into ThreadView so it can
  trigger persistence.
- Extract schedule_save() method that coalesces saves with a throttle
  timer. Both the draft prompt observer and the scroll handler call it,
  replacing the old _draft_save_task with a shared _save_task.
- Add dbg! statements at each step of the scroll position data flow
  for debugging.
- Use gpui::ListOffset as the in-memory type for scroll position on
  both Thread and AcpThread. SerializedScrollPosition remains only
  for the serde boundary in DbThread. Eliminates all manual
  conversions between layers.
- Consistent naming: ui_scroll_position everywhere (field, getter,
  setter) across AcpThread, Thread, and DbThread.
- Scroll handler writes directly to Thread via as_native_thread()
  instead of bouncing through AcpThread. AcpThread only carries the
  initial value during the load path (set in register_session).
- Remove all dbg! statements.
- Revert from_db back to tail expression (intermediate binding was
  only needed for removed dbg!).
- Add comment explaining cx.defer in scroll handler (RefCell hazard).
- Use assert_eq! for float comparison in test (12.5 is exactly
  representable in f32).
@eholk eholk force-pushed the persist-token-count-and-scroll-position branch from 2be6b72 to f90e65e Compare March 3, 2026 22:05
@eholk eholk marked this pull request as ready for review March 3, 2026 22:12
@eholk eholk enabled auto-merge (squash) March 3, 2026 22:13
@eholk eholk merged commit 832782f into main Mar 3, 2026
29 checks passed
@eholk eholk deleted the persist-token-count-and-scroll-position branch March 3, 2026 22:20
tahayvr pushed a commit to tahayvr/zed that referenced this pull request Mar 4, 2026
…dustries#50620)

Release Notes:

- Token counts and scroll position are restored when loading a previous
agent thread
wzulfikar pushed a commit to wzulfikar/zed that referenced this pull request Mar 4, 2026
…dustries#50620)

Release Notes:

- Token counts and scroll position are restored when loading a previous
agent thread
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants