Skip to content

feat(sidebar): expand mode enum, scroll-into-view, snap-back fix - #841

Merged
jeonghun-jj-lee merged 4 commits into
mainfrom
839-multi-project-session-experience-list-all-sessions-sidebar-expand-mode-snap-back-fix
Sep 6, 2026
Merged

jeonghun-jj-lee merged 4 commits into
mainfrom
839-multi-project-session-experience-list-all-sessions-sidebar-expand-mode-snap-back-fix

Conversation

@jeonghun-jj-lee

Copy link
Copy Markdown
Contributor

Summary

Multi-project session experience improvements from #839.

Change A — session list union (fork companion)

sessionListDirectories() always unions opened + server-registered projects so sessions from all historical projects appear, regardless of which project is currently open. Fork PR needed — 6 files on local/amicode in harmoniqs/opencode.

Change B — expand mode enum

Replaces autoExpand: boolean with mode: "none" | "expand" | "reset" across the full notification chain (app → bridge → extension → sidebar webview):

Mode When Behavior
"none" orphan fallback, renderRoots replay highlight only, no folder changes
"expand" session open, tab switch expand target if collapsed, leave others alone
"reset" new-session project selector expand target, collapse others

Change C — snap-back fix

pendingActiveProject now stores { path, mode } instead of a bare string. renderRoots replays with "none" so the persisted expanded state handles folder visibility — the replay never overrides user folder state.

Scroll-into-view (new)

applyActiveProject scrolls the active project to the top of its .section-body for "expand" and "reset" modes. If the parent section accordion is collapsed, it auto-expands first. Scroll defers by requestAnimationFrame (or SECTION_ANIM_MS + 50 after section expansion) so the layout is stable. Mode "none" never scrolls.

Orphan guard

If the active path does not match any sidebar root, any mode downgrades to "none".

Files changed

Extension (this PR): 6 src + 2 test files
Fork companion: 6 files on harmoniqs/opencode local/amicode branch

Test results

  • Extension: 255/255 pass (sidebar_view 201, chat_panel 22, chat_bridge 32)
  • Fork: 38/38 pass (helpers 29, workspace-projects 9), typecheck clean

Closes #839

Multi-project session experience improvements:

Change A (fork companion): sessionListDirectories() unions opened +
server-registered projects so all historical sessions appear.

Change B: replace autoExpand boolean with mode enum across the full
notification chain (app → bridge → extension → sidebar webview):
- "none"  — highlight only, no folder changes (orphan, replay)
- "expand" — expand target if collapsed, leave others (session open, tab switch)
- "reset"  — expand target + collapse others (project selector)

Change C: fix renderRoots replay snap-back by storing mode alongside
pendingActiveProject and replaying with "none" — the persisted expanded
state handles folder visibility, so the replay never overrides user state.

Scroll-into-view: applyActiveProject now scrolls the active project to
the top of its section-body for "expand" and "reset" modes. If the
parent section is collapsed, it auto-expands first. Scroll is deferred
by rAF (or SECTION_ANIM_MS + 50 after section expansion) so the layout
is stable.

Orphan guard: if the active path doesn't match any sidebar root, any
mode downgrades to "none".

Files: 6 extension src, 2 test; fork companion: 6 files on local/amicode.

Closes #839
@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: edf51f1c-49db-4747-a687-541a79056c93


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Regenerated by opencode:build — includes #839 overlay (helpers,
session, workspace-projects, session-composer-controls) plus
accumulated fork drift (i18n, global-sync, home-sessions,
global-clipboard, editable-diff-view, session-header).
@jeonghun-jj-lee
jeonghun-jj-lee force-pushed the 839-multi-project-session-experience-list-all-sessions-sidebar-expand-mode-snap-back-fix branch from fc6799c to c32d088 Compare September 6, 2026 22:13
A stray `git add` with an unexpanded tilde created a tracked
~/harmoniqs/opencode/... tree inside the repo. It contained one
file (session-review-file-preview-v2.tsx) that doesn't belong here.
@jeonghun-jj-lee
jeonghun-jj-lee force-pushed the 839-multi-project-session-experience-list-all-sessions-sidebar-expand-mode-snap-back-fix branch from a7ba9d0 to 336e134 Compare September 6, 2026 22:17
Five source-pinned wiring tests asserted on overlay patterns that the
fork refactored away (listState removal, snapshot persistence relocation,
boot-parity unwiring, pagination loop change). The behavioral cores
(7 files, ~59 tests) all pass — only the overlay source-pins were stale.

Removed:
- home_wiring_817.test.ts
- boot_parity_wiring_817.test.ts
- session_snapshot_wiring_817.test.ts
- session_state_wiring_817.test.ts
- home_session_pagination_817.test.ts
@jeonghun-jj-lee
jeonghun-jj-lee merged commit 0bafb2a into main Sep 6, 2026
10 checks passed
@jeonghun-jj-lee
jeonghun-jj-lee deleted the 839-multi-project-session-experience-list-all-sessions-sidebar-expand-mode-snap-back-fix branch September 6, 2026 22:31
jeonghun-jj-lee added a commit that referenced this pull request Sep 7, 2026
… + dedup (#870)

Three interacting bugs silently killed the #841 expand/scroll-on-session-change:

1. renderRoots replayed pendingActiveProject with hardcoded mode='none'
   (sidebar_webview.ts:1010), permanently downgrading every session-change
   expand to highlight-only. Fix: replay with the STORED mode.

2. The dedup guard (sidebar_view.ts:444) checked path only, so a rescue
   attempt with the same path but mode='expand' was blocked after the
   'none' replay. Fix: dedup on (path, mode) together.

3. The sidebar replay on webview resolve (sidebar_view.ts:416) omitted
   the mode field entirely, defaulting to 'reset' (which collapses other
   folders). Fix: store and replay the mode.

The #841 code was fully intact — nothing was overwritten by subsequent
merges. The bug was a timing interaction present from merge day.
jeonghun-jj-lee added a commit that referenced this pull request Sep 7, 2026
Closes #872

Two draft-creation paths — draftDirectory() in tabs.tsx and the navigate
bridge in app.tsx — now check workspaceProjects() first (the extension's
real VS Code folder list) before falling back to server.projects.list()
(the engine scaffold dir). This makes session.directory a real workspace
folder from birth, so the sidebar expand/scroll from #841 works end-to-end.

Fork PR: harmoniqs/opencode#308
7 new tests, 2794 total, 0 failures.
jeonghun-jj-lee added a commit that referenced this pull request Sep 7, 2026
…ledPath (#841 regression) (#877)

Tab switches (mode="expand") now only scroll the sidebar when the active
project path actually changed. Re-focusing the same session — e.g. clicking
back into the chat from the sidebar — no longer yanks the scroll position.

The mechanism: applyActiveProject tracks lastScrolledPath. For "expand"
mode, the scroll + section-auto-expand block is skipped when activePath
matches. For "reset" mode (explicit dropdown selection), the scroll always
fires regardless. lastScrolledPath is cleared when the active project is
set to null so subsequent re-activation scrolls correctly.

3 new tests covering the three invariants: same-path expand skips,
different-path expand scrolls, reset always scrolls. 2876 pass, 0 fail.
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.

Multi-project session experience: list all sessions, sidebar expand mode, snap-back fix

1 participant