Skip to content

fix(client): share the side-card width across sessions (last drag wins) - #36

Closed
fsvov wants to merge 1 commit into
omdsh-dev:mainfrom
fsvov:fix/share-panel-width-across-sessions
Closed

fix(client): share the side-card width across sessions (last drag wins)#36
fsvov wants to merge 1 commit into
omdsh-dev:mainfrom
fsvov:fix/share-panel-width-across-sessions

Conversation

@fsvov

@fsvov fsvov commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Problem

The side-card panel width is stored in the per-session state (dsh-sidebar:v1:<sessionId> in localStorage). Dragging the panel in one conversation writes only that session's width — switching to another conversation snaps the panel back to that session's own width (its persisted value or the "default width share" seed). The width is a layout preference, not session content, so per-session isolation here is surprising: users expect the width they chose to hold across conversations.

Fix

Make the panel width a cross-session preference with "last drag wins":

  • New global key dsh-sidebar:v1:width (next to the per-session keys).
  • schedulePersist writes the current width to the global key on every persist (any width change — drag or fullscreen toggle — becomes the shared width).
  • loadState prefers the global width over a session's persisted value, and the fresh-session seed uses it too.
  • A cache-hit session switch (setSession) adopts the global width, so already-loaded sessions stay in sync within the same page lifetime.

Everything else (open/closed state, tabs, splits, bottom-panel height) stays per-session, exactly as before.

Backward compatibility

With no global key present (first run after upgrade, or pre-existing sessions), the behavior is byte-for-byte unchanged: readGlobalWidth() returns undefined and every code path falls through to the original logic. The first drag anywhere seeds the global key; from then on all conversations follow it.

Tests

Added a regression test in tests/unit.spec.ts ("shares the panel width across sessions (last drag wins)") that drives the real store with a storage-backed localStorage stub:

  1. drag in session A → 500;
  2. switch to fresh session B → width is 500 (was the default 400 before this change);
  3. drag in B → 600, switch back to cached A → width is 600.

tests/service.spec.ts and the store suites pass; the two unit.spec.ts failures (requireAbsolute POSIX-path expectation and defaultShell expecting /bin/bash) are pre-existing Windows-platform issues, reproduced identically without this change.

Design note

An alternative would be a settings toggle ("sync width across conversations") backed by the existing side-card prefs document — happy to rework toward that if the maintainers prefer an opt-in pref over the unconditional behavior. The panel width has no session-specific meaning today (it is a pure viewport preference), which is why this change makes it global unconditionally.

The panel width lived in the per-session state (dsh-sidebar:v1:<id>), so a
drag in one conversation never carried to another: switching conversations
snapped the panel back to that session's own width. The width is a layout
preference, not session content, so it now persists under a cross-session
key (dsh-sidebar:v1:width):

- every persist writes the current width to the global key;
- loadState prefers the global width over a session's persisted one;
- a cache-hit session switch adopts the global width.

Backward compatible: with no global key present (first run / older data)
the behavior is unchanged. Adds a regression test covering drag-in-A ->
switch-to-B and drag-in-B -> switch-back-to-A.
@HuanLinOTO HuanLinOTO added bug Something isn't working P3 低:体验/建议 area/sidebar Sidebar shell, panels, layout, tabs, workspace windows duplicate This issue or pull request already exists labels Aug 23, 2026
Menghuan1918 pushed a commit that referenced this pull request Aug 24, 2026
# Conflicts:
#	src/client/state.ts
#	tests/unit.spec.ts
Menghuan1918 added a commit that referenced this pull request Aug 24, 2026
- README / README_EN: add v0.16.0 changelog (free windows #354, model-driven
  sidebar opens #353, Markdown inline HTML + TOC #360, 19-language overlays
  #339, multi-repo git + linked worktrees #326/#285, browser loopback
  allowlist, Vue + 28 legacy languages #202, preview refresh trio #215/#228,
  local Markdown images #292, ego-browser catalog #340; fixes: market/cordis
  #338, ctx.get() reads #357, workspace boundary #345, panel-host layering
  #330/#278, layout-push hardening #310/#130/#180, width sharing #36, terminal
  cleanup #130, fs-search noise dirs #342, mermaid #341, Nerd Font #190,
  UTF-8 HTML #193, trust-fence #182, reveal-in-explorer #94, PowerShell #47,
  GET probe fallback #69, unrun devDep #336) and move v0.15.2 into history
- feature tour: free windows + Markdown inline HTML/TOC (EN), feature list
- plugin ecosystem: add ego-browser (24 tab plugins), install pin ^0.16.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sidebar Sidebar shell, panels, layout, tabs, workspace windows bug Something isn't working duplicate This issue or pull request already exists P3 低:体验/建议

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants