Skip to content

feat: configurable chat history scrollback#423

Closed
amanthanvi wants to merge 11 commits intoDimillian:mainfrom
amanthanvi:feat/chat-history-scrollback
Closed

feat: configurable chat history scrollback#423
amanthanvi wants to merge 11 commits intoDimillian:mainfrom
amanthanvi:feat/chat-history-scrollback

Conversation

@amanthanvi
Copy link
Contributor

@amanthanvi amanthanvi commented Feb 12, 2026

Fixes #422

What

  • Adds an app-wide setting for chat history scrollback (max items retained per thread).
  • Adds a Settings UI (unlimited toggle, presets, custom number input) with guidance about performance + re-syncing older messages.
  • Plumbs the setting into thread item retention logic (null = unlimited).
  • Virtualizes the conversation list to reduce render cost for large histories (uses existing @tanstack/react-virtual).

Notes

  • On startup, trimming is deferred until persisted settings hydrate (scrollback is treated as unlimited briefly), preventing older items from being dropped before the configured limit is known.
  • Increasing the scrollback limit does not automatically re-fetch older history that was previously trimmed; use "Sync from server" on a thread to restore older messages.
  • "Unlimited" may increase memory usage; virtualization mitigates UI rendering cost but not memory growth.

How to validate

  • Open Settings → Display & Sound → Chat and adjust scrollback (toggle Unlimited, pick presets, or enter a custom value).
  • Confirm longer threads retain more items locally and UI remains responsive with large histories.

Tests

  • npm run lint
  • npm run typecheck
  • npm run test
  • cd src-tauri && cargo test

Copilot AI review requested due to automatic review settings February 12, 2026 22:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements configurable chat history scrollback to prevent losing older messages in long-running threads. The implementation adds an app-wide setting (default 200 items) that can be increased up to 5000 or set to unlimited, and uses virtualization to maintain UI performance with large histories.

Changes:

  • Adds chatHistoryScrollbackItems setting (number | null) to control thread item retention per thread
  • Implements virtualization for the Messages component using @tanstack/react-virtual with ResizeObserver
  • Provides Settings UI with unlimited toggle, preset selector (200/500/1000/2000/5000), and custom number input

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/utils/threadItems.ts Adds optional maxItemsPerThread parameter to prepareThreadItems with null for unlimited
src/utils/threadItems.test.ts Tests custom and unlimited scrollback limits
src/types.ts Adds chatHistoryScrollbackItems: number | null to AppSettings type
src/features/threads/hooks/useThreadsReducer.ts Adds maxItemsPerThread to ThreadState and setMaxItemsPerThread action
src/features/threads/hooks/useThreadsReducer.test.ts Tests trimming when maxItemsPerThread is reduced
src/features/threads/hooks/useThreads.ts Plumbs chatHistoryScrollbackItems setting into reducer via useEffect
src/features/threads/hooks/threadReducer/threadItemsSlice.ts Passes maxItemsPerThread option to all prepareThreadItems calls
src/features/threads/hooks/threadReducer/threadConfigSlice.ts New slice to handle setMaxItemsPerThread action and re-process all threads
src/features/settings/hooks/useAppSettings.ts Adds normalization for chatHistoryScrollbackItems (clamps 50-5000, rounds)
src/features/settings/components/sections/SettingsDisplaySection.tsx Implements Chat scrollback UI with toggle, presets, and input
src/features/settings/components/sections/SettingsDisplaySection.test.tsx Tests unlimited toggle and preset selection
src/features/messages/components/Messages.tsx Replaces flat rendering with virtualized list using useVirtualizer and ResizeObserver
src/features/messages/components/Messages.test.tsx Mocks useVirtualizer for tests
src/styles/messages.css Adds CSS for virtual list container and rows
src-tauri/src/types.rs Adds chat_history_scrollback_items: Option<u32> to Rust AppSettings with default 200
src/App.tsx Passes chatHistoryScrollbackItems to useThreads hook

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ba45a268d7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@amanthanvi
Copy link
Contributor Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7b9fb1301c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@amanthanvi
Copy link
Contributor Author

Follow-ups pushed to address review feedback:

  • Disable preset + reset while Unlimited is enabled (e8bf542).
  • Stabilize per-row ref callbacks to avoid ResizeObserver churn on rerender (7b9fb13).
  • Fix settings hydration edge case so we don't trim history before persisted scrollback loads; reducer now seeds maxItemsPerThread up-front and trimming is deferred during settings load (21fc843, plus regression test).

CI is green (lint/typecheck/test + Rust + Tauri builds).

@amanthanvi
Copy link
Contributor Author

@codex review

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 591 to 594
const observer = new ResizeObserver(() => {
rowVirtualizerRef.current.measureElement(node);
requestAutoScrollRef.current();
});
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

Superfluous argument passed to default constructor of class ResizeObserverMock.

Copilot uses AI. Check for mistakes.
@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Bravo.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Dimillian
Copy link
Owner

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Dimillian
Copy link
Owner

@amanthanvi it introduces an issue, when loading an old thread, and trying to scrollup it'll jump back to the bottom making it almost impossible to scroll up

@Dimillian
Copy link
Owner

Overall lot of complexity by virtualizing the conversation view

@Dimillian Dimillian closed this Feb 13, 2026
@amanthanvi
Copy link
Contributor Author

Got it. Hoping a nice way to add this can be figured out somewhere down the line. Appreciate you taking a look at it! @Dimillian

@amanthanvi
Copy link
Contributor Author

Follow-up: opened #427 as a reduced-scope alternative (same configurable scrollback setting + retention logic, but no Messages virtualization) based on the scroll-jump + complexity feedback here.

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.

feat: configurable chat history scrollback (avoid losing older messages)

3 participants