TUI Epic 3: Library screen (replaces Plans) - #159
Conversation
loadLibraryEntries reads the allowlisted project docs (AGENTS/CLAUDE/ CODEX/README.md, matching the app/metadata-server library surface) plus session plans from .aimux/plans, skipping untouched TBD stubs and falling back to file mtime when a plan lacks a frontmatter updatedAt. Backs the upcoming Library screen that replaces Plans. Epic 3 (Library) phase 1 of 2. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The Plans tab showed per-session .aimux/plans stubs (mostly "TBD"). Replace it with a Library screen (key l) that browses the project's documents (AGENTS/CLAUDE/CODEX/README.md, matching the app/HTTP library surface) alongside real, non-stub plans, with a content preview pane and editor open (e/Enter). Direct cutover: remove the plans screen + its controller/renderer, repoint the union/statusline/nav/dispatch from 'plans'/'p' to 'library'/'l', and migrate any persisted 'plans' screen to 'library'. Epic 3 (Library) phase 2 of 2. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@coderabbitai review |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe PR replaces the ChangesLibrary Screen Replaces Plans Screen
Sequence DiagramsequenceDiagram
participant User
participant handleDashboardKey
participant showLibrary
participant loadLibraryEntries
participant renderLibraryScreen
participant handleLibraryKey
participant openEntryInEditor
User->>handleDashboardKey: press "p"
handleDashboardKey->>showLibrary: showLibrary(host)
showLibrary->>loadLibraryEntries: load docs + plans from fs
loadLibraryEntries-->>showLibrary: LibraryEntry[]
showLibrary->>renderLibraryScreen: render list + frame
User->>handleLibraryKey: press "e" or enter
handleLibraryKey->>openEntryInEditor: openEntryInEditor(host, path)
openEntryInEditor->>openEntryInEditor: exit raw mode, spawnSync $EDITOR
openEntryInEditor->>loadLibraryEntries: refresh after editor exits
openEntryInEditor->>renderLibraryScreen: re-render library
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
✅ Action performedReview finished.
|
'l' is the vim-style worktree drill-in key (alongside enter/right) on the main dashboard, so binding it to Library shadowed drilling into a worktree. Use 'p' instead — the freed Plans key, of which Library is the successor — which only shadows the redundant worktree 'p'=up (k/up still work), exactly as the old 'p'=plans did. Also drop the now-unreachable "plans" literal from the StatuslineData union. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/library.ts`:
- Line 95: The updatedAt field assignment needs to validate that the frontmatter
timestamp from frontmatterUpdatedAt(content) is actually a valid date string
before using it. Currently, malformed timestamps pass through and cause
Date.parse() to return NaN at the sorting logic later. Modify the updatedAt
assignment to validate the frontmatter value by attempting to parse it, and only
use it if the result is a valid number (not NaN); otherwise, fall back to the
mtime value from statSync(path).mtime.toISOString().
- Around line 22-23: The FRONTMATTER regex pattern only matches LF newlines,
which causes frontmatter parsing to fail silently on CRLF-authored markdown
files, affecting both updatedAt extraction and preview stripping. Update the
FRONTMATTER regex to be CRLF-tolerant by modifying all newline matches to accept
both LF and CRLF line endings. Replace hardcoded newline characters in the
pattern with a pattern that matches either carriage return plus line feed or
just line feed.
In `@src/multiplexer/library.ts`:
- Around line 41-48: The terminal mode restoration code in the spawnSync editor
invocation is not protected against exceptions. Wrap the spawnSync call in a
try/finally block to ensure terminal modes are always restored, even if the
spawn operation throws an error. Move the host.terminalHost.exitRawMode() and
host.terminalHost.exitAlternateScreen() calls into the try block before
spawnSync, then move the host.terminalHost.enterRawMode() and
host.terminalHost.enterAlternateScreen(true) calls into a finally block so they
execute unconditionally after the spawn attempt completes or fails.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ad47c34f-2782-4d12-97bd-a06fa08733ea
📒 Files selected for processing (18)
src/dashboard/state.tssrc/dashboard/ui-state-store.tssrc/library.test.tssrc/library.tssrc/multiplexer/archives.tssrc/multiplexer/dashboard-control.tssrc/multiplexer/dashboard-interaction.tssrc/multiplexer/dashboard-tail-methods.tssrc/multiplexer/index.tssrc/multiplexer/library.tssrc/multiplexer/navigation.tssrc/multiplexer/runtime-state.tssrc/multiplexer/session-launch.tssrc/statusline-model.tssrc/tmux/statusline.test.tssrc/tui/screens/dashboard-renderers.tssrc/tui/screens/overlay-renderers.tssrc/tui/screens/subscreen-renderers.ts
|
Sub-agent review pass. One real defect, fixed:
Loader ( |
…ditor try/finally - Make the library frontmatter regex and updatedAt scan CRLF-tolerant so CRLF-authored plans/docs parse correctly. - Ignore a malformed frontmatter updatedAt (falls back to mtime) so it can't degrade the recency sort. - Restore terminal raw/alternate modes via try/finally around the editor spawn so a throw can't leave the terminal broken. - Add CRLF + malformed-timestamp regression tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Third epic of the TUI IA redesign. Replaces the per-session Plans tab with a Library screen — a browsable view of the project's documents and real plans, matching the project's direction (the app/HTTP
/librarysurfaces project docs).What changed
Phase 1 — Library loader. New pure-ish
src/library.ts:loadLibraryEntries({repoRoot, plansDir, resolveLabel})returns allowlisted project docs (AGENTS/CLAUDE/CODEX/README.md, mirroring metadata-server's library allowlist) plus session plans from.aimux/plans— skipping untouched TBD stubs and falling back to file mtime when a plan lacks a frontmatterupdatedAt. PureisStubPlanhelper. Unit-tested via temp dir.Phase 2 — Library screen (key
l). Browsable list of docs + plans with a content preview pane and editor-open (e/Enter). Direct cutover from Plans: removed the plans screen/controller/renderer, repointed theDashboardScreenunion / statusline tab / nav cycle / dispatch fromplans/p→library/l, and migrate any persistedplansscreen →library.Fixes the carried-forward Plans bugs (empty TBD-stub walls, no mtime sort fallback) and frames docs as first-class library content.
Verification
yarn typecheck,yarn lint,yarn buildcleanyarn vitest run— 1389 tests pass (6 new loader tests)Dashboard and Graveyard untouched.
🤖 Generated with Claude Code
Summary by CodeRabbit