- Use a regex ASCII test to detect lines where string indices equal cell
columns, skipping the buildStringToCellMap buffer walk entirely. Most
terminal output is ASCII, so this avoids the majority of cell API calls.
- Share a frozen empty array for non-matching lines instead of allocating
a new array per scanLine call, reducing GC pressure during scrollback.
Inspired by #466 (@crawt).
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* perf(keyword-highlight): reduce highlight latency with throttled rAF and line cache
Based on #464 by @crawt with fixes for review feedback:
- Split triggerRefresh into immediate (rAF) and debounced (setTimeout) modes
so onWriteParsed highlights land with fresh content instead of trailing
by 200ms
- Throttle the immediate path (50ms min interval) to prevent heavy output
like tail -f from refreshing every frame
- Add per-line match result cache (LRU, bounded by cacheEntries config)
so repeated or scrolled-back lines skip regex scanning entirely
- Lazily build cellMap only when a regex match is found, avoiding
unnecessary work on non-matching lines
- Fix buildStringToCellMap to handle empty cells (codepoint 0) which
translateToString() renders as spaces — keeps the map aligned with
the string and makes lineText a safe cache key
- Clean up animationFrameId and matchCache on dispose/rule change
Co-Authored-By: Leo Pan <crawt@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: guard rAF callback against stale state and add debounce fallback
- Re-check enabled/alternate-buffer inside the rAF callback so a
pending frame doesn't resurrect decorations after the user disables
highlighting or enters an alternate-buffer app
- Schedule a debounce timer alongside rAF so background/hidden tabs
(where Chromium suspends rAF) still get highlight updates
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: prevent fallback timer from being cleared on rAF-pending path
- Don't clear debounceTimer at the start of immediate mode — in hidden
tabs rAF stays pending indefinitely, so repeated onWriteParsed calls
were clearing the only timer that could actually fire
- Cancel debounceTimer inside the rAF callback instead, so foreground
tabs don't get a redundant second refreshViewport() 200ms later
- Only arm a new fallback timer if one isn't already pending
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: clear stale rAF in fallback timer and add alternate buffer guard
- Cancel the pending rAF and clear animationFrameId in the fallback
timer callback so hidden-tab refreshes don't leave animationFrameId
stuck, which would block all future immediate refreshes
- Add enabled/alternate-buffer re-check in the fallback callback,
matching the guard already present in the rAF callback
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: extract executeRefresh to ensure all timer paths clear stale rAF
A debounced-path timer (from scroll/resize) could fire without clearing
a stale animationFrameId left by an earlier immediate-path rAF that
never executed (hidden tab). This left the immediate path permanently
blocked.
Extract executeRefresh() with rAF cleanup + state guards, used by all
three callback sites (rAF, immediate fallback, debounced timer).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Leo Pan <crawt@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* perf(keyword-highlight): reduce highlight latency and redundant regex scanning
- Split triggerRefresh into two modes: "immediate" (rAF, for new output
and rule changes) and "debounced" (setTimeout, for scroll/resize),
eliminating the fixed 200ms delay after each write that caused visible
highlight lag on commands like `ls`.
- Add per-line match result cache (LRU, bounded by cacheEntries config)
so repeated or scrolled-back lines skip regex scanning entirely.
- Lazily build the string-to-cell column map only when a regex match is
actually found, avoiding unnecessary work on non-matching lines.
- Clean up animationFrameId and matchCache on dispose/rule change to
prevent leaks and stale results.
* fix: include cell layout in highlight cache key to prevent misplaced decorations
Two IBufferLines can produce identical translateToString() output but
differ in cell layout (e.g. empty cells vs real space characters after
tab stops). Using lineText alone as the cache key could return cached
x/width ranges computed from a different cell layout, producing
misplaced or truncated highlights.
Build the cellMap eagerly and include it in the cache key so lines with
different cell structures get separate cache entries. Pass the pre-built
cellMap into scanLine to avoid redundant work.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: panwk <panwukan@suangoo.com>
Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* chore: remove 65 debug console.log statements from production code
Remove bracketed debug traces ([SFTP navigateTo], [SFTPBackend],
[ManagedSourceSync], [AutoSync], [CloudSync], [Settings], etc.)
across 16 files. These were development logging that shipped to
production, creating noise in the console.
Also clean up dead variables left behind after log removal
(hotkeyDebug, results, verification reads).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* chore: remove 43 unused exports and dead type definitions
Remove export keywords from symbols that are never imported outside
their defining file. Symbols still used internally keep their
definitions; symbols not used at all are removed entirely.
Removed entirely: TerminalLine, SessionLogsSettings, KDFParams,
SyncManagerConfig, GoogleTokenResponse, OneDriveTokenResponse,
getSyncStatusColor, resolveHostTerminalAppearance,
TerminalAppearanceDefaults.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The onScroll event may not fire for all scroll methods (e.g., mouse wheel).
Add onRender listener to detect viewport position changes and trigger
decoration refresh when scrolling stops.
Co-Authored-By: Claude (gemini-claude-opus-4-5-thinking) <noreply@anthropic.com>
Address reviewer feedback: avoid creating new RegExp objects on every
viewport refresh. Now patterns are compiled once in setRules() and
reused across refreshes.
Changes:
- Add CompiledRule interface with pre-compiled regex + color
- Move regex compilation from refreshViewport() to setRules()
- Reset regex.lastIndex before each line scan for correct reuse
- Remove try/catch from hot path (errors caught at compile time)
This reduces CPU/GC pressure especially with many rules or high-frequency
terminal output.
Co-Authored-By: Claude <noreply@anthropic.com>
Address review feedback: regex match indices are JS string positions,
but xterm Decoration API expects terminal cell columns. This caused
highlight misalignment on lines with tabs, CJK characters, or emoji.
Add buildStringToCellMap() helper that iterates buffer cells to build
a mapping from string index to cell column, correctly handling:
- Wide characters (CJK, emoji): 1 char = 2 cells
- Combining characters: multiple chars = 1 cell
- Regular ASCII: 1 char = 1 cell
Co-Authored-By: Claude <noreply@anthropic.com>
Replace ANSI escape sequence-based text processing with xterm.js's
Decoration API for keyword highlighting. This "lazy" approach only
processes visible viewport rows and uses debounced refresh, ensuring
zero impact on scrolling performance.
Key changes:
- New KeywordHighlighter class using IDecoration/IMarker APIs
- Decorations refresh on scroll, write, and resize events
- Skip highlighting in alternate buffer (vim, htop, etc.)
- Add configurable debounce delay (200ms default)
- Remove inline ANSI color injection from data stream
Co-Authored-By: Claude <noreply@anthropic.com>
Expands terminal settings with advanced customization such as emulation type, font weights, line padding, keyword highlighting, link modifiers, and middle-click behavior.
Adds support for clickable URLs, cross-window settings sync, and context-aware right-click actions.
Improves accessibility with minimum contrast ratio controls and allows keyword-based output highlighting.
Refines theme/font selection UI for performance and clarity.