-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Description
Problem
:Opencode toggle closes windows and deletes buffers every time. Reopening recreates the UI from scratch, re-renders all output, and loses input draft, scroll/cursor position, and focused pane.
Expected Behavior
When ui.persist_state = true (proposed default):
- Hide UI windows without deleting buffers
- Restore existing buffers into new split windows on next toggle
- Preserve: input draft, scroll/cursor position, focused pane,
input_hiddenstate - Respect user intent: if user clicks a line after restore, do NOT force-scroll to bottom
When ui.persist_state = false, behavior remains unchanged.
Design: Three-State Window Model
closed ──(open)──> visible ──(hide)──> hidden ──(restore)──> visible
^ | | |
+──(close)─────────+ +──(close_hidden)─────+
State is derived — get_window_status() checks window validity + hidden buffer existence. A pure-function decision engine (resolve_toggle_decision) maps (status, persist_state) → action.
Performance
100 toggle cycles, same session with output content:
| Metric | persist_state=false | persist_state=true |
|---|---|---|
| Mean | 27.15 ms | 15.09 ms |
| P50 | ~22 ms | ~12.4 ms |
| P95 | ~37 ms | ~24.6 ms |
~44% mean improvement from skipping buffer recreation and full session re-render.
Pre-requisite Fixes Discovered
Issues found during implementation that should be fixed independently:
curl.lua:job.pidpersists after exit — health check false positive. Fix: explicitis_runningflagtopbar.lua: missingpcall+win_is_validguard on async callbacksloading_animation.lua: missingbuf_is_validguard on extmark operationsoutput_window.lua:is_at_bottom()viewport check always true in streaming — fix: cursor-based checkoutput_window.lua:update_dimensionserrors on split windows — fix: detect floating vs splitinput_window.lua: same floating/split issue inapply_dimensionsrenderer.lua:render_full_sessionhas no debounce — rapid toggles cause request stormsevent_manager.lua:_poll_external_messageshidden→visible transition causes redundant render + scroll overridereference_picker.lua:normal! zzon jump causes visual noise — make configurable
Implementation Status
- Full implementation on
feat/hide-window-toggle(commitc894fd9) - 604-line test suite (
persist_state_spec.lua) - Performance benchmark (
scripts/bench_toggle.lua) - All existing tests pass
- Split into individual PR branches (in progress, see comments)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels