Skip to content

feat(task-panel): add per-task collapsible notes, changed-files, and shell sections - #383

Open
truongthinh1412 wants to merge 12 commits into
johannesjo:mainfrom
truongthinh1412:feat/204-collapsible-sections
Open

truongthinh1412 wants to merge 12 commits into
johannesjo:mainfrom
truongthinh1412:feat/204-collapsible-sections

Conversation

@truongthinh1412

@truongthinh1412 truongthinh1412 commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Description

Implements item 1 of #204 ("Reduce task panel density: collapsible sections and title-bar badge consolidation"): a collapse toggle in the header of each secondary section of a task panel — notes, changed files, and the shell section — persisted per task. Items 2 (width-derived default collapse), 3 (badge consolidation) and 4 (coordinator-line merge) of the issue remain open and are not addressed by this PR.

What the toggles do

  • Collapsed sections show only their header row (~32px, 35px shell toolbar) and contribute no layout: bodies are hidden in place (display: none / display: contents) rather than unmounted, so DOM state persists, aria-controls targets always exist, xterm terminals are never disposed, and ChangedFilesList keeps reporting counts to TaskPanel while collapsed.
  • Persistence rides the existing panelUserSize map (keys task:${taskId}:collapsed:${section}, collapse stores 1, expand deletes the key — absence means expanded, so existing users see zero change). The key format is owned by focused-panel.ts (the same seam as isShellToolbarPanel; importing ui.ts from tasks.ts would cycle).
  • Collapse-aware ResizablePanel wiring: collapsed cells never hold a flex-absorber role (minSize floors drop, noPin while collapsed, defaultSize suppressed, absorberIds filtered or substituted with a safe sentinel). The horizontal notes-split renders only when both sides are expanded; any collapse stacks the sections as a plain full-width column. The zone's vertical floor uses notesFilesZoneFloor (sum semantics: a collapsed header + the expanded sibling's floor).
  • The shell section auto-expands when a shell is spawned or a bookmark is dispatched while collapsed (so commands never run in a hidden row), and the persisted flag clears when the last shell closes.
  • Toggle clicks preserve keyboard focus across the section's reparent boundary (queueMicrotask restore); collapsed sections are excluded from buildMainGrid and the pointerdown focus write, so arrow-key navigation and panel focus never land on a hidden body.

Verification highlights

  • 335 unit tests (incl. a 48-case exhaustive grid matrix covering all 8 collapse combinations × 2 layouts) + the full client suite + 16 live-app collapse runs with real CDP keyboard/mouse input at 4 window sizes, islands-dark, and prompt-hidden — 0 strands, 0 clips, 0 errors.
  • Live-app reproduction of every round-3 review finding on pre-fix code, confirmed resolved on this branch.

Issues Resolved

Contributes to #204 (implements item 1: collapsible secondary sections; issue stays open for items 2–4)

Check List

  • New functionality includes testing.
  • New functionality has been documented in the README if applicable. (Not applicable — UI behavior addition, no user-facing configuration.)

@truongthinh1412
truongthinh1412 force-pushed the feat/204-collapsible-sections branch from 399dc82 to 36c3f82 Compare November 28, 2026 18:14
- hide the sticky notes tour footer inside the collapse wrapper so it cannot
  paint over the header row while collapsed (display:none|contents wrapper
  around the editor container and the footer, expanded layout unchanged)
- drop the duplicate changed-files body id: the collapse wrapper is the
  aria-controls target, the inner grid wrapper loses it
- floor the notes/files zone by summing its panes: every non-both-expanded
  state now stacks them as a plain full-width column, so one collapsed side
  never leaves a dead strip and the both-collapsed floor is two header rows
  (62px); the section roots drop height:100% while collapsed to match
- render the horizontal notes-split only when both sides are expanded and
  revert its children to the plain expanded-floor panels, deleting the
  width-floor variants (maxAutoSize can no longer leak as max-width)
- gate the change-tour FeatureHint on the section being expanded
- auto-expand the shell section when shells grow while collapsed and also
  clear the persisted flag when the last shell closes on its own
- share one SectionCollapseToggle across notes/changed-files/shell headers;
  its pointerdown stops propagation so the section root cannot steal focus
- buildMainGrid omits collapsed cells/rows in both layouts: notes/changed-files
  rows only while expanded, the shell toolbar row and terminal rows only while
  the shell section is not collapsed
- samePanelKindIn no longer maps onto a target task whose shell section is
  collapsed; pickTargetTerminalFamilyPanel takes the target id and returns
  null for it, so cross-task arrows fall through to the grid fallback
- setTaskSectionCollapsed drops the task's panel focus when the section being
  hidden holds it (shell:N and shell-toolbar:N included), mirroring
  setProjectsCollapsed's hidden-row cleanup
- move the shell-toolbar panel prefix helpers into focused-panel.ts so ui.ts
  reuses them without a cycle through focus.ts
…collapses

Split mode now always keeps the left column (AI terminals + prompt) in the
navigation grid however the right column collapses: the toolbar row rides
with the AI panes even when no shell rows exist, so an arrow press from the
AI terminal or the prompt always has a next cell instead of stranding. The
stack layout keeps its collapsed notes/files/shell-row filtering but makes
the shell toolbar row unconditional — the toolbar stays visible and
interactive while the shell section is collapsed.

buildMainGrid is exported for an exhaustive parametrized grid-invariant
suite over both layouts and the full collapse-combination matrix, plus the
regression pair: the AI terminal never strands (title/prompt within two
presses in split), and the prompt always walks back onto an AI terminal.
- SectionCollapseToggle restores DOM focus in a microtask after toggling:
  the panel tree reparents the section body and Chromium drops native
  focus, which let the panel's setTimeout(0) auto-focus steal the keyboard.
  The toggle also gains its class and a hover rule matching the toolbar
  buttons' intent.
- Dispatching a bookmark from a collapsed shell toolbar expands the
  section first: the reuse path writes into an existing shell without
  spawning, so the growth effect never fired and the command ran out of
  sight. closeShell no longer retargets panel focus onto surviving shells
  while the section is collapsed (the flag is read locally in tasks.ts —
  importing ui would cycle through navigation).
- ResizablePanel hides handles whose grip cannot follow the pointer: a
  noPin child pins the handle's own position, so when the sole absorber
  sits beyond the handle the drag would only trade space between panes the
  grip is not between.
- Collapsed shell terminals drop their WebGL context (visible=false), and
  the notes/changed-files header clicks no longer write panel focus while
  collapsed; collapsed headers get flex-shrink 0 so a stacked column with
  overflow hidden cannot shrink them below their floor.
- Split-right sizing: a collapsed shell section caps notes' default size
  and cards' auto max like the empty-shell state.
- COLLAPSED_SECTION_MIN_HEIGHT moves 31 -> 32: the parallel-code look's
  border-box heading is 32px and 31 clipped it by a pixel; the shell
  toggle row gets the toolbar's 5px left inset, and the growth client test
  re-collapses before shrinking so the count===0 clear is genuinely
  exercised.
@johannesjo johannesjo added the needs work Review requested changes; waiting on the author label Dec 4, 2026
@johannesjo

Copy link
Copy Markdown
Owner

🔧 Needs changes – labelled needs work; ping me once the items below are addressed and I'll re-review.

Thanks for the PR! This adds collapse toggles to the notes, changed-files and shell sections of a task panel, saved per task. It's carefully done and well tested. One behaviour needs fixing before merge: collapsing a section throws away the size the user dragged it to.

Should fix before merge

  • src/components/TaskPanel.tsx:877, :922, :932, :966 – collapsing a section deletes its saved size for good. The PR marks a collapsed section as noPin and also changes absorberIds while a section is collapsed. ResizablePanel's existing cleanup effect (src/components/ResizablePanel.tsx, the createEffect that calls deletePanelUserSize for any child that is noPin or the sole absorber) deletes the saved panelUserSize entry of each such child. setTaskSectionCollapsed (src/store/ui.ts:100-117) does not save that size anywhere first, so expanding the section does not bring it back. Example in the default stack layout with one shell open:

    1. Drag the shell/AI-terminal divider so the shells are 300px tall. This saves task:<id>:shell-section.
    2. Click "Hide shell terminals". noPin() becomes true and the entry is deleted.
    3. Click "Show shell terminals". The shells come back at the 140px default, not 300px.

    The same thing happens to the split-right notes and changed-files sizes when either one collapses. It also happens to changed-files in split mode when collapsing the shells makes it the sole absorber, and to the stack-mode notes-files/AI-terminal ratio when the whole notes-files zone collapses.

    Two possible fixes:

    • Give PanelChild a separate collapsed flag. childStyle would treat it as content-sized, like noPin, but the cleanup effect would ignore it.
    • Have setTaskSectionCollapsed save the affected sizes on collapse and restore them on expand.

    Either way, a test that saves a size, collapses, expands and checks the size is still there would cover it.

Nits

  • src/store/focus.ts:29 – isTaskSectionCollapsed is imported in a second import from ./focused-panel, right below the existing one. It could go in the existing list.

Automated review pass (Claude Code). Anything unclear or wrong – say so and I'll take a look.

@johannesjo

Copy link
Copy Markdown
Owner

Collapsible sections fit #204 – thanks. Two things before merging:

  1. The blocker from the review: collapsing a section drops its dragged size, so expanding brings back the default instead of the user's size.
  2. A collapsed Notes section hides the only way into Review Plan and the tours. Please show a small hint in the collapsed Notes header when a plan or tour exists (like the summary the collapsed Changed files header keeps), so it isn't lost.

Ping me when that's in.

- Preserve dragged panel sizes across section collapse: PanelChild gains
  a collapsed flag — content-sized like noPin for styling and drag, but
  the stale-pin cleanup never deletes a collapsed child's pin, nor a
  sibling's while it is only the sole absorber because absorberIds
  rerouted around the collapse. Expanding restores the user's size in
  the stack and split layouts (covered by save/collapse/expand tests).
- Show a hint in the collapsed Notes header when a plan or tour exists
  (Plan available / Tour available / Plan & tour available), mirroring
  the summary the collapsed Changed Files header keeps, so Review Plan
  and the tours are not lost behind the collapse.
- Keep the shell toolbar a keyboard target while the shell section is
  collapsed (cross-task landing and panel-focus retention), hide
  handles beside a sentinel absorber, restore toggle focus via the
  clicked node, route the collapse key through taskSectionCollapseKey
  in tests and mocks, and merge the duplicate focused-panel import
  in focus.ts.
@truongthinh1412

Copy link
Copy Markdown
Contributor Author

Thank you so much for the careful review — and for spelling out the size-loss scenario so clearly, that made it easy to reproduce and fix! 🙏

Both items (and the import nit) are addressed in c32cd2c4:

  1. Dragged sizes survive collapse — I went with your first suggestion, extended a little: PanelChild now has a dedicated collapsed flag. A collapsed child is sized and dragged around exactly like a noPin child, but the stale-pin cleanup never deletes its pin. The same deferral covers the sibling cases you listed — e.g. changed-files becoming the sole absorber in split mode while the shells are collapsed, and the stack-mode notes-files/AI-terminal ratio while the zone is collapsed — since their pins are legitimate fixed sizes again on expand, and the self-heal resumes once nothing is collapsed. New tests cover save → collapse → expand for both the collapsed child and the temporarily-sole sibling (plus a guard that sole-absorber cleanup still fires when nothing is collapsed).
  2. Collapsed Notes hint — the header now shows · Plan available, · Tour available, or · Plan & tour available whenever the corresponding actions exist, mirroring the summary the collapsed Changed Files header keeps. Covered for plan-only, agent-tour-only, both, and neither.
  3. Nit — the duplicate focused-panel import in focus.ts is merged into the existing list. This commit also folds in a few round-five polish items from my working copy (sentinel-absorber handles, toggle focus restore via the clicked node, routing the collapse key through taskSectionCollapseKey in tests/mocks).

Verified locally: npm run check passes, test:changed is green (1,283 unit + 2,198 client), and I ran the app locally to eyeball drag → collapse → expand restoring the exact size, with the plan hint showing in the collapsed Notes header. Pinging as requested — happy to adjust the hint wording or the preservation semantics if you'd prefer them different. Thanks again for the thoughtful feedback! 😊

- jumpToWaitingTask reveals a collapsed shell section before focusing the
  asking shell:N panel: the tray can list a shell question while the
  terminal is display:none and its grid row is gone, which stranded the
  keyboard (and left closeShell's guard pointing at a dead panel).
- "Open terminal" (toolbar button, Enter, and the global shortcut) expands
  the section synchronously before spawning, like runBookmark: the growth
  effect only fires after the new TerminalView mounted, so its PTY would
  otherwise start inside display:none at 80x24.
- ResizablePanel: a collapsed absorber's dormant pin no longer counts
  toward the asymmetric-pin self-heal, and that heal (like the sole
  absorber one) waits while any sibling is collapsed, so a pin can never
  be purged merely because a sibling collapsed.
- Shell toolbar inset only applies when the collapse toggle renders.
- focus.test.ts: the layout matrix prints "stack layout"/"split layout"
  instead of "false mode"/"true mode".
… path

- addShellToTask clears the shell-section collapse key next to
  shellAgentIds.push, so every spawn path (Open terminal, Run buttons,
  cloud sessions, setup shells) reveals the row before the terminal
  mounts; the setup shell now shares that function instead of pushing
  into shellAgentIds itself.
- Drop the hand-copied expands in App.tsx and TaskShellSection's
  openShell. The bookmark reuse path keeps its own expand, since it
  writes into an existing shell and spawns nothing.
- Drop the ResizablePanel absorber-role-flip test: it passed on the
  parent version too, so it does not guard this change; the sibling-pin
  test is the one that fails without the fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs work Review requested changes; waiting on the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants