Skip to content

refactor: replace debug logging with termLog utility and clean up termwrap mouse/alt-screen handling#17

Merged
lyx-tec merged 3 commits into
mainfrom
workspace-browserview-cache
Jul 11, 2026
Merged

refactor: replace debug logging with termLog utility and clean up termwrap mouse/alt-screen handling#17
lyx-tec merged 3 commits into
mainfrom
workspace-browserview-cache

Conversation

@lyx-tec

@lyx-tec lyx-tec commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

16 files changed (+178/-254). Refactors logging, optimizes workspace switching, enforces resource limits, and cleans up termwrap.

Changes

Workspace switching performance (emain/emain-window.ts)

Keep BrowserViews alive during workspace switch instead of destroying them. Tab views are positioned off-screen and cached, so switching back is near-instant. allLoadedTabViews is cleared on the window side but cached views survive in wcvCache.

Tab view cache improvements (emain/emain-tabview.ts)

  • MaxCacheSize: 10 → 30 (more tabs kept in memory)
  • isDestroyed check: getOrCreateWebViewForTab now skips destroyed tab views in cache, avoids creating duplicate overlays
  • Stale entry cleanup: tryEvictEntry handles tab views no longer tracked by the window (e.g. after workspace switch clears allLoadedTabViews)

Workspace/Tab limits (pkg/wcore/workspace.go)

  • MaxWorkspaces = 10 — rejected at CreateWorkspace entry with a descriptive error
  • MaxTabsPerWorkspace = 10 — checked in createTabObj before appending a new tab

termwrap cleanup (frontend/app/view/term/termwrap.ts)

  • Remove SyntheticAltScreenTracker (main-screen TUIs no longer get alt-buffer treatment)
  • Remove restoreMouseTrackingMode logic
  • Drop SGR (1006) mouse reports in the main buffer — only alt-buffer programs receive mouse input
  • Significant reduction: 276 lines → fewer (net -167 lines)

Log refactor

New termLog() utility (frontend/util/termlog.ts) replaces console.log/debug across workspace switching, block focus, keyboard navigation, tab operations, terminal resize/resync, and focus management.

Block header (frontend/block/blockframe-header.tsx)

Show abbreviated 8-char blockId in the block header for easier debugging.

lyx-tec added 3 commits July 10, 2026 14:00
Replace removeAllChildViews() (destroy all) with positionTabOffScreen()
so tabs from the previous workspace stay alive in the cache. On switch-back,
setTabViewIntoWindow -> finalizePositioning reuses the cached BrowserView
without recreating the renderer process, preserving xterm.js state
including DEC mouse modes.

- MaxCacheSize 10 -> 30 for cross-workspace caching
- getOrCreateWebViewForTab checks isDestroyed before returning cached view
- tryEvictEntry handles tabs evicted from allLoadedTabViews (workspace switch)
@lyx-tec
lyx-tec merged commit e0ca4ad into main Jul 11, 2026
6 checks passed
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.

1 participant