Repository navigation
Migrate terminal scrollback setting from bytes to rows - #6593
Conversation
Transition terminal scrollback configuration from a byte-based (MB) limit to a row-based count to align with standard terminal emulator behavior. - Introduce a shared scrollback policy to handle normalization and safe migration of legacy byte presets to row equivalents. - Update persistence logic to automatically convert and clean up legacy settings on startup and write-back. - Refactor the advanced settings interface and localization strings to let users configure scrollback in terms of rows (up to 50k). - Live-apply row limit changes directly to mounted xterm instances without recreating panes or restarting PTY sessions.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR replaces terminal scrollback configuration from bytes ( 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
src/shared/terminal-scrollback-policy.ts (1)
12-15: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument the legacy MB→rows bucketing rationale.
The 17.5/37.5/75 MB cutoffs are policy-driven, not obvious from the code, so this migration will be hard to safely maintain without a short why-comment near the thresholds or conversion function.
As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."
Suggested diff
export const LEGACY_TERMINAL_SCROLLBACK_BUCKET_5K_MAX_BYTES = 17_500_000 export const LEGACY_TERMINAL_SCROLLBACK_BUCKET_10K_MAX_BYTES = 37_500_000 export const LEGACY_TERMINAL_SCROLLBACK_BUCKET_25K_MAX_BYTES = 75_000_000 + +// Why: legacy byte presets were coarse intent signals, not exact row budgets. +// Bucket by nearest row preset so old settings land on the closest new preset.Also applies to: 38-54
Source: Coding guidelines
src/shared/terminal-scrollback-policy.test.ts (1)
38-46: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover the midpoint cutoffs explicitly.
The migration behavior depends on strict boundary choices at 17.5MB, 37.5MB, and 75MB, but the suite only checks representative preset values. Add exact-threshold assertions so an accidental
</<=flip is caught immediately.src/main/persistence.ts (1)
419-435: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a short “Why” note for the migration precedence.
terminalScrollbackRowswinning over legacy bytes andneedsSaveforcing a rewrite are compatibility rules, not obvious normalization behavior. A brief note here would make that intent much easier to preserve during future cleanup.
As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: bade6d5d-962d-4acb-9204-6c89d7794dbc
📒 Files selected for processing (27)
src/main/codex-accounts/runtime-home-service.test.tssrc/main/codex-accounts/service.test.tssrc/main/ipc/settings.test.tssrc/main/ipc/settings.tssrc/main/persistence.test.tssrc/main/persistence.tssrc/renderer/src/components/settings/Settings.tsxsrc/renderer/src/components/settings/SettingsConstants.tssrc/renderer/src/components/settings/TerminalAdvancedSection.tsxsrc/renderer/src/components/settings/TerminalPane.pwsh.test.tssrc/renderer/src/components/settings/terminal-advanced-platform-search.tssrc/renderer/src/components/settings/terminal-search.test.tssrc/renderer/src/components/settings/useGhosttyImport.test.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.test.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/lib/pane-manager/pane-lifecycle.test.tssrc/renderer/src/lib/pane-manager/pane-terminal-options.tssrc/renderer/src/store/slices/settings.tssrc/shared/constants.tssrc/shared/terminal-scrollback-policy.test.tssrc/shared/terminal-scrollback-policy.tssrc/shared/types.ts
| keywords: [ | ||
| ...translateSearchKeyword('auto.components.settings.terminal.search.f66a7cf715', 'terminal'), | ||
| ...translateSearchKeyword( | ||
| 'auto.components.settings.terminal.search.cde233f5da', | ||
| 'scrollback' | ||
| ), | ||
| ...translateSearchKeyword('auto.components.settings.terminal.search.rows', 'rows'), |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Keep legacy search aliases during the bytes→rows rename.
This entry no longer matches old queries like size, mb, or bytes, so users following older docs or habit will stop finding the control after the rename. Keep those as aliases while the migration is still fresh.
💡 Suggested change
keywords: [
...translateSearchKeyword('auto.components.settings.terminal.search.f66a7cf715', 'terminal'),
...translateSearchKeyword(
'auto.components.settings.terminal.search.cde233f5da',
- 'scrollback'
+ 'scrollback',
+ { aliases: ['size', 'mb', 'bytes'] }
),
...translateSearchKeyword('auto.components.settings.terminal.search.rows', 'rows'),📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| keywords: [ | |
| ...translateSearchKeyword('auto.components.settings.terminal.search.f66a7cf715', 'terminal'), | |
| ...translateSearchKeyword( | |
| 'auto.components.settings.terminal.search.cde233f5da', | |
| 'scrollback' | |
| ), | |
| ...translateSearchKeyword('auto.components.settings.terminal.search.rows', 'rows'), | |
| keywords: [ | |
| ...translateSearchKeyword('auto.components.settings.terminal.search.f66a7cf715', 'terminal'), | |
| ...translateSearchKeyword( | |
| 'auto.components.settings.terminal.search.cde233f5da', | |
| 'scrollback', | |
| { aliases: ['size', 'mb', 'bytes'] } | |
| ), | |
| ...translateSearchKeyword('auto.components.settings.terminal.search.rows', 'rows'), |
Transition terminal scrollback configuration from a byte-based (MB) limit to a row-based count to align with standard terminal emulator behavior. - Introduce a shared scrollback policy to handle normalization and safe migration of legacy byte presets to row equivalents. - Update persistence logic to automatically convert and clean up legacy settings on startup and write-back. - Refactor the advanced settings interface and localization strings to let users configure scrollback in terms of rows (up to 50k). - Live-apply row limit changes directly to mounted xterm instances without recreating panes or restarting PTY sessions.
Avoid committing terminal scrollback row setting changes on every keystroke, which can trigger rapid updates with incomplete or invalid numbers. Instead, manage a local draft state and commit to settings only when the input is blurred or the user presses Enter.
…estigate-scrollback
* Migrate terminal scrollback setting from bytes to rows Transition terminal scrollback configuration from a byte-based (MB) limit to a row-based count to align with standard terminal emulator behavior. - Introduce a shared scrollback policy to handle normalization and safe migration of legacy byte presets to row equivalents. - Update persistence logic to automatically convert and clean up legacy settings on startup and write-back. - Refactor the advanced settings interface and localization strings to let users configure scrollback in terms of rows (up to 50k). - Live-apply row limit changes directly to mounted xterm instances without recreating panes or restarting PTY sessions. * Migrate terminal scrollback setting from bytes to rows Transition terminal scrollback configuration from a byte-based (MB) limit to a row-based count to align with standard terminal emulator behavior. - Introduce a shared scrollback policy to handle normalization and safe migration of legacy byte presets to row equivalents. - Update persistence logic to automatically convert and clean up legacy settings on startup and write-back. - Refactor the advanced settings interface and localization strings to let users configure scrollback in terms of rows (up to 50k). - Live-apply row limit changes directly to mounted xterm instances without recreating panes or restarting PTY sessions. * defer updating terminal scrollback rows until blur or Enter Avoid committing terminal scrollback row setting changes on every keystroke, which can trigger rapid updates with incomplete or invalid numbers. Instead, manage a local draft state and commit to settings only when the input is blurred or the user presses Enter.
Summary
Migrates the terminal scrollback buffer setting from bytes (MB presets) to a row-based count (Row presets: 5k, 10k, 25k, 50k). This provides a more standard terminal configuration experience, optimizes memory usage, and allows dynamically applying scrollback updates to live, mounted panes without pane recreation or PTY interruption.
Key changes:
terminalScrollbackByteswithterminalScrollbackRowsacross settings types and store defaults.terminal-scrollback-policycontaining row presets (5,000 to 50,000 rows) and mapping logic from legacy byte settings to rows.Store) to convert legacy settings on startup and strip deprecatedterminalScrollbackBytes.applyTerminalScrollbackRowsToMountedPaneson settings change without PTY disruption.Screenshots
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildEvidence of testing:
src/shared/terminal-scrollback-policy.test.tschecking defaults, normalization, and byte-to-row migration.src/main/persistence.test.ts.src/main/ipc/settings.test.ts.src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.test.ts.AI Review Report
The code changes were thoroughly reviewed for correctness, edge cases, and cross-platform stability.
Security Audit
Notes
terminalScrollbackBytessetting is gracefully stripped from the persisted storage.