Skip to content

feat: vendor shared file tree + resizable picker from monorepo#63

Merged
dastratakos merged 4 commits into
mainfrom
dastratakos/cli-shared-file-tree
Jun 3, 2026
Merged

feat: vendor shared file tree + resizable picker from monorepo#63
dastratakos merged 4 commits into
mainfrom
dastratakos/cli-shared-file-tree

Conversation

@dastratakos
Copy link
Copy Markdown
Contributor

@dastratakos dastratakos commented Jun 2, 2026

Summary

Syncs the CLI's file picker and chapter detail sidebar with the monorepo file-tree overhauls that landed after the CLI was forked (~May 27). Brings the CLI up to the shared file tree architecture and the resizable panel hook.

Ports three monorepo PRs:

  • #980 — extract one shared FileTree (+ FileFilterInput) rendered by both the Files-changed picker and the chapter detail sidebar. Previously the CLI's chapter sidebar used a flat FileViewRow list and the file picker had its own inlined tree reimplementation — two divergent copies, now one.
  • #984 — order the collapsed picker indicators by file-tree order instead of raw API order.
  • #985 — shared useResizablePanel hook + chapter-panel-constants; CollapsiblePicker gains an opt-in resize handle and the chapter side panel drops its hand-rolled drag logic.

Changes

  • New: lib/use-resizable-panel.ts, components/chapter/chapter-panel-constants.ts, components/files/file-tree.tsx, components/files/file-filter-input.tsx (vendored from the monorepo, imports adapted to @/lib/*).
  • Rewritten: file-picker.tsx (thin wrapper over FileTree), chapter-file-list.tsx (renders FileTree instead of a flat list), collapsible-picker.tsx (internal collapse state + shortcutKey + resize + ShortcutTooltip), chapter-side-panel.tsx (uses useResizablePanel).
  • Deleted: components/chapter/file-view-row.tsx — its last consumer (the chapters index page) now renders a small local FilePathRow.
  • Adaptations for the CLI: FILE_VIEWED_STATE moved into lib/diff-types; comment counts are absent so callers pass an empty map; CollapsiblePicker drops the command-board event the CLI lacks. The chapter sidebar now passes focusedFilePath so the tree highlights the active file.

Testing

  • pnpm typecheck
  • pnpm lint ✅ (clean, no warnings)
  • pnpm test ✅ 299/299
  • pnpm build

Open in Stage

Summary by cubic

Ports the shared file tree and resizable picker to the CLI and adds explicit file-focus navigation with keyboard shortcuts. This speeds up file review, aligns picker/sidebar behavior, and smooths chapter completion and navigation.

  • New Features

    • Explicit focused-file model with keyboard shortcuts: j/k (navigate), v (mark viewed + advance), ; / Shift+; (collapse file / all), Esc (exit). Focused diffs show an outline; tooltips display shortcut hints.
    • Chapter flow: Shift+V marks the chapter viewed and advances; marking a chapter’s last unviewed file auto-marks the chapter and advances. Chapter links and keyboard nav preserve scroll; switching chapters realigns to the first file under the header with robust --content-top parsing.
  • Refactors

    • Files tab and chapter detail use useFileDiffNavigation; removed scroll-derived active-file heuristic; added use-current-file, use-file-viewed-key, use-file-collapse-keys, use-file-keyboard-mode-exit-key; FileDiffList accepts focusedFilePath.
    • Replaced chapter sidebar list and file picker tree with shared FileTree + FileFilterInput; CollapsiblePicker gains shortcutKey and optional resize via useResizablePanel; chapter side panel uses the same hook.
    • Removed Files tab scrollTo deep-link; Prologue “Review Focus” now shows the filename only.

Written for commit b7a36b4. Summary will update on new commits.

Review in cubic

Syncs the CLI's file picker / chapter sidebar with the monorepo overhauls
that landed after the fork:

- #980: extract a single shared FileTree (+ FileFilterInput) rendered by
  both the Files-changed picker and the chapter detail sidebar. Replaces
  the chapter sidebar's flat FileViewRow list and the file picker's own
  inlined tree reimplementation.
- #984: order the collapsed picker indicators by file-tree order rather
  than raw API order.
- #985: add a shared useResizablePanel hook + chapter-panel-constants;
  CollapsiblePicker gains an opt-in resize handle and the chapter side
  panel drops its hand-rolled drag logic for the hook.

Adaptations for the CLI: imports rewritten to @/lib/*; FILE_VIEWED_STATE
moved into lib/diff-types; comment counts are absent so callers pass an
empty map; CollapsiblePicker drops the command-board event the CLI lacks.
file-view-row.tsx is deleted (its last consumer, the chapters index page,
now renders a small local FilePathRow).

Typecheck, lint, test (299), and build all pass.
@stage-review
Copy link
Copy Markdown

stage-review Bot commented Jun 2, 2026

* feat(web): vendor explicit file-focus navigation + viewed/collapse shortcuts

Syncs the CLI with the monorepo's keyboard-navigation overhaul that
landed after the fork:

- #943: replace scroll-derived "active file" with an explicit focused-file
  state machine (useCurrentFile) + a shared orchestrator (useFileDiffNavigation)
  that owns the diff-viewer ref and wires every file shortcut. Adds a
  "file keyboard mode" so keyboard focus shows an outline ring while
  click/scroll selection only highlights the picker row.
- #975: add v (mark file viewed + advance, pinning the marked file to top),
  ; / Shift+; (collapse file / all files), Esc (exit keyboard mode), and
  re-bind chapter-viewed from v to Shift+V (#910). file-header gains
  ShortcutTooltip hints on the viewed + collapse controls.

New hooks (vendored, imports adapted to @/lib/*): use-current-file,
use-file-viewed-key, use-file-collapse-keys, use-file-keyboard-mode-exit-key,
use-file-diff-navigation; use-file-navigation-keys rewritten to the focus
signature. The old scroll heuristic use-active-file-on-scroll is deleted.
Both routes now delegate to useFileDiffNavigation; FileDiffList gains a
focusedFilePath outline. Ported the monorepo's file-focus-shortcuts test
(16 cases).

CLI simplification: the canToggleViewed gate stays at its default (the CLI's
viewed state is client-side and always writable).

Typecheck, lint, web tests (105), and build all pass.

* feat(web): advance to next chapter on view + auto-mark chapter when all files viewed

Mirrors the hosted app's chapter mark-complete flow (chapter-context.tsx
handleMarkComplete / toggleChapterFileViewed), which the CLI lacked:

- Marking a chapter viewed (Shift+V or the navigator toggle) now advances
  to the next chapter — or returns to the run's chapter list once every
  chapter is viewed.
- Marking a chapter's last unviewed file now auto-marks the chapter viewed
  and advances, so finishing a chapter by its files behaves like Shift+V.

Both routes through a shared advanceAfterChapterComplete helper. The all-
viewed/next-chapter check reads the pre-mark view-state snapshot (the
optimistic cache patch lands a tick later), matching the monorepo's
current-snapshot logic. Confetti is intentionally omitted (CLI has none).

Verified locally via stagereview show: completing a chapter's files marks
it viewed and navigates to the next chapter. typecheck, lint, test (315) pass.

* fix(web): preserve scroll position when navigating between chapters

The chapter detail page scrolls the window, and TanStack Router defaults
to resetScroll: true, so every chapter-to-chapter navigation jumped back
to the top. The hosted app passes resetScroll: false for on-detail-page
chapter nav (chapter-context.tsx navigateToPrev/Next/Chapter); the CLI's
navigations omitted it.

Add resetScroll={false} to the navigator's prev/next/jump <Link>s and to
the keyboard + auto-advance navigate() calls. Navigating to the run's
chapter list once all chapters are viewed keeps the default reset, matching
the hosted app's mark-complete-all flow.

Verified locally: scrolling down a chapter and advancing keeps the scroll
position instead of jumping to the top.

* fix(web): align to the new chapter's first file on chapter change

resetScroll: false alone left the window at the prior chapter's offset, so
advancing could strand the reader deep in (or past) the next chapter. The
hosted app realigns the diff column to the new chapter's first file under
the sticky header on chapter change, gated on the side panel being pinned
(i.e. only when scrolled into the content).

Port that to the CLI's window-scroll model: a useLayoutEffect keyed on
chapter id scrolls to the first file when the carried-over offset left it
above --content-top, and leaves the view alone when already near the top
(so the chapter summary stays visible).

Verified locally: scrolled to the bottom of a chapter then advanced -> the
next chapter's first file snaps under the header; advancing from the top
leaves the view in place.

* fix(web): sync file focus on route-driven scrolls + robust collapse-all test

Addresses PR review (Bugbot/codex):
- Deep-link scrollTo on the Files tab now selects the linked file (not just
  scrolls), so the picker highlights it and j/k/v/; start from it.
- Key-change jumps and the chapter-change first-file realign now select the
  file they scroll to, so shortcuts act on the file shown at the top instead
  of a stale path carried over from the previous chapter. This also makes the
  orchestrator's selectFile return value a live consumer (was unused).
- allCollapsed now tests membership (files.every(has)) instead of size >=
  length, so Shift+; can't flip to expand-all when collapsedFiles carries
  paths outside the current file list.

typecheck, lint, test (315) pass.

* refactor(web): align collapse-state + chapter realign with hosted monorepo

Match the hosted app rather than diverging:
- allCollapsed: revert to collapsedFiles.size >= files.length (the monorepo's
  test). Instead of a membership test, scope the Files-tab collapse defaults to
  the current files (only mark deleted/viewed paths that are in the diff), so
  collapsedFiles stays a subset of files exactly like the monorepo guarantees.
- Chapter-change realign now only scrolls to the first file (no selectFile),
  matching the monorepo's reset effect which repositions without touching
  file-focus state.

Key-change jumps still selectFile(target.filePath) — that DOES match the
monorepo (its chapter route effect selects the focused key change's file).

typecheck, lint, test (315) pass.

* refactor(web): remove scrollTo deep-link, matching the hosted monorepo

The hosted app has no scrollTo flow on the Files tab, so drop the CLI's:
- files route: remove the scrollTo search param + validateSearch schema
- FilesPage: remove the scrollTo prop and the select-on-scrollTo effect
- prologue Review Focus: the concern location is now plain text (matching
  pull-request-summary-section), not a link into the Files tab

PrologueSection no longer needs runId. typecheck, lint, test (315), build pass.
Comment thread packages/web/src/components/chapter/chapter-file-list.tsx
Comment thread packages/web/src/routes/chapter-detail-page.tsx
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 63b3f16b75

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/web/src/components/prologue/prologue-section.tsx
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 issues found across 30 files

Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.

Re-trigger cubic

Comment thread packages/web/src/routes/chapter-detail-page.tsx Outdated
Comment thread packages/web/src/components/chapter/chapter-file-list.tsx
Comment thread packages/web/src/components/chapter/chapter-panel-constants.ts
Comment thread packages/web/src/components/prologue/prologue-section.tsx
@dastratakos dastratakos changed the title Vendor shared file tree + resizable picker from monorepo feat: vendor shared file tree + resizable picker from monorepo Jun 3, 2026
The chapter-realign gate reads --content-top the same way the hosted app's
getContentTop does (parseFloat of the resolved px value). Add the monorepo's
Number.isFinite fallback so a missing/NaN value degrades to 0 instead of
NaN, for exact parity. No runtime behavior change on the chapter page, where
--content-top resolves to px.
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b7a36b4. Configure here.

Comment thread packages/web/src/lib/use-file-diff-navigation.ts
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b7a36b4bc2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/web/src/components/chapter/chapter-file-list.tsx
Comment thread packages/web/src/lib/keyboard-shortcuts.ts
@dastratakos dastratakos merged commit b70d9a6 into main Jun 3, 2026
6 checks passed
@dastratakos dastratakos deleted the dastratakos/cli-shared-file-tree branch June 3, 2026 04:44
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