Skip to content

Frontend tool-panel registry + feature slices - #67

Merged
LukeMainwaring merged 1 commit into
mainfrom
refactor/frontend-tool-panel-registry
Jul 16, 2026
Merged

Frontend tool-panel registry + feature slices#67
LukeMainwaring merged 1 commit into
mainfrom
refactor/frontend-tool-panel-registry

Conversation

@LukeMainwaring

Copy link
Copy Markdown
Owner

Summary

Replaces the hardcoded per-tool branching in components/message.tsx with a registry lookup, and moves the domain panel components into features/<name>/ slices. Adding a tool panel is now: create the component in its slice + add one map entry — message.tsx never changes again for new tools.

Registry contract

  • features/tool-panel-registry.ts is the composition root — the only file that imports across feature slices. It spreads each slice's Record<string, ToolPanelEntry> map into TOOL_PANELS.
  • A ToolPanelEntry is { Panel: ComponentType<{ input: unknown; output: unknown }>, hideRawOutput?: boolean }. Wrapper components in each slice own the input/output parsing that previously lived in message.tsx.
  • message.tsx does a single TOOL_PANELS[toolName] lookup and renders the panel when part.state === "output-available".

Slice layout

features/
  tool-panel-registry.ts
  sessions/
    session-visualization.tsx   (moved; emotion-trajectory import now relative)
    emotion-trajectory.tsx      (moved, unchanged)
    session-list-panel.tsx      (moved; chat-actions-provider import now aliased)
    tool-panels.tsx             (new: analyze_session, list_sessions)
  retrieval/
    retrieved-tracks-panel.tsx  (moved; waveform-viz import now relative)
    waveform-viz.tsx            (moved, unchanged)
    tool-panels.tsx             (new: retrieve_tracks_from_brain_state)
lib/
  extract-session-id.ts         (new: shared input parser — both slices need it)

The list_sessions HTML-comment ID extraction (and its rationale comment) moved into the sessions slice, since it's specific to that tool. brain-context-badge.tsx stays in components/ — it's chat chrome, not a tool panel.

Behavior preservation

  • Panels mount only on output-available.
  • Unregistered tools fall back to the raw <ToolCall> JSON view.
  • Only list_sessions hides the raw output block (hideRawOutput: true).
  • A failed session_id parse renders no panel (wrapper returns null), exactly as before.

Verification

  • pnpm -C frontend format + pnpm -C frontend lint — clean.
  • pnpm -C frontend exec tsc --noEmit — clean.
  • git diff --stat main -- frontend/api/generated — empty (no backend/API changes, no client regen).

🤖 Generated with Claude Code

… registry

Move the domain panel components out of components/ into
features/sessions/ and features/retrieval/ slices, each exporting a
tool-name -> panel map. features/tool-panel-registry.ts is the
composition root that spreads the slice maps together, and message.tsx
now does a single registry lookup instead of per-tool branching —
adding a tool panel no longer touches message.tsx.

The shared session_id input parser moves to lib/extract-session-id.ts;
the list_sessions HTML-comment ID extraction (and its rationale) moves
into the sessions slice where it belongs.

Behavior preserved: panels mount only on output-available, unregistered
tools keep the raw ToolCall JSON view, only list_sessions hides raw
output, and a failed session_id parse renders no panel.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@LukeMainwaring
LukeMainwaring merged commit 2769845 into main Jul 16, 2026
4 checks passed
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