Skip to content

feat: expand/collapse sections for headings#7

Closed
tomasz-tomczyk wants to merge 1 commit intomainfrom
worktree-section-collapse
Closed

feat: expand/collapse sections for headings#7
tomasz-tomczyk wants to merge 1 commit intomainfrom
worktree-section-collapse

Conversation

@tomasz-tomczyk
Copy link
Copy Markdown
Owner

Summary

  • Collapsible markdown sections: each heading defines a section that can be toggled via chevron icons to the left of the gutter, a header "Collapse All / Expand All" button, or the s keyboard shortcut
  • Collapsed sections show a "N lines collapsed" summary row and a comment count badge if the section contains comments
  • j/k keyboard nav skips collapsed blocks; TOC clicks auto-expand parent sections
  • Collapse state persisted to localStorage per filename; sections not collapsible in diff view

Test plan

  • Open a long markdown file with multiple heading levels
  • Click chevrons to collapse/expand individual sections
  • Verify nested sections (H3 inside H2) collapse correctly with parent
  • Test "Collapse All" / "Expand All" header button
  • Test s keyboard shortcut
  • Verify j/k navigation skips collapsed blocks
  • Add a comment inside a section, collapse it, verify badge shows count
  • Click a TOC entry for a collapsed section, verify it expands and scrolls
  • Reload page, verify collapsed state is restored from localStorage
  • Toggle diff view, verify no chevrons appear

🤖 Generated with Claude Code

Add ability to collapse markdown sections to their headings for quick
navigation of long documents. Sections are defined by heading levels
and can be toggled via chevron icons, a header button, or keyboard
shortcut (s).

- Build section tree from heading blocks after parsing
- Chevron toggle positioned to the left of each heading gutter
- Collapsed sections show "N lines collapsed" summary row
- Comment count badge on collapsed headings with comments
- j/k keyboard nav skips collapsed blocks
- TOC clicks auto-expand collapsed parent sections
- Collapse state persisted to localStorage per filename
- Sections not collapsible in diff view

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tomasz-tomczyk tomasz-tomczyk force-pushed the main branch 3 times, most recently from de1cee7 to 74e233a Compare February 23, 2026 10:10
@tomasz-tomczyk tomasz-tomczyk deleted the worktree-section-collapse branch March 1, 2026 01:20
tomasz-tomczyk added a commit that referenced this pull request Apr 29, 2026
…pe test

Bundle of low-risk improvements flagged by the independent review:

Popover keyboard + a11y
- Add `role="listbox"` to the focus-picker list and `role="option"` +
  `aria-selected` + `tabindex="-1"` to each item, matching the listbox
  pattern the popover already implies via aria-haspopup.
- Add Escape handler that closes the popover and returns focus to the
  trigger button — same pattern as the commit-picker.

Stable test attributes
- `data-label` on each picker item (lifts the label out of rendered DOM
  children, replacing brittle `evaluate(() => innerText)` reads in
  focus-picker spec).
- `data-focus-kind` on each item, replacing the substring-match selector
  `[data-focus-payload*="working_tree"]` which would false-positive on any
  payload that happened to contain that string.

Brittle test fixes
- comment-stale spec: replace `stackOrdered[1]` with a feat-b-relative
  lookup so fixture growth doesn't silently shift the test.

Net new coverage
- scope-toggle-files: new test asserts a layer-scoped comment is hidden
  in full-stack and reappears when the user flips back. This is the
  lossless-visibility invariant — the only regression test against
  accidentally serialising scope-filtered comments out to disk.

Skipped from the polish list (with reasons):
- Branches-section base_sha precompute (#2) — server-side change, owned
  by go-expert; would be a separate ticket.
- Pre-feature comment WT-only test (#6) and /api/focus error-rollback
  toast test (#7) — both require fixture or daemon-state changes that
  exceed the 30-min budget for "polish".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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