Skip to content

feat(agents-server-ui): add state explorer panel to entity view#4156

Open
balegas wants to merge 19 commits intomainfrom
feature/state-explorer-panel
Open

feat(agents-server-ui): add state explorer panel to entity view#4156
balegas wants to merge 19 commits intomainfrom
feature/state-explorer-panel

Conversation

@balegas
Copy link
Copy Markdown
Contributor

@balegas balegas commented Apr 23, 2026

Summary

  • Adds a collapsible right side panel to the entity view that visualizes StreamDB state in real-time
  • Adapts the 3-panel state visualizer (TypeList + StateTable + EventSidebar) from the Electric Cloud Dashboard
  • Supports time-travel through state events, FK navigation, column sorting/resizing, and live tail toggle

Components

  • StateExplorerPanel — connects to the entity's main stream, materializes state, composes the 3 inner panels
  • TypeList — collection type navigator with row counts
  • StateTable — virtualized data table with FK detection, hover previews, sorting, resizing
  • EventSidebar — event timeline with time-travel (INS/UPD/DEL/UPS badges), expand/collapse
  • EntityHeader — adds a Database icon toggle button
  • EntityPage — splits into timeline (left) + state panel (right, 50% width) when open

Test plan

  • Start agents server and UI (pnpm --filter @electric-ax/agents-server-ui dev)
  • Spawn an entity that produces state events
  • Click the Database icon in the entity header
  • Verify the state explorer panel opens on the right
  • Verify types appear in the left TypeList panel
  • Click a type and verify rows appear in the StateTable
  • Click events in the EventSidebar to time-travel
  • Toggle the Live switch to pause/resume live updates
  • Click the Database icon again to close the panel

🤖 Generated with Claude Code

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

❌ Patch coverage is 8.01217% with 907 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.72%. Comparing base (3cef0ca) to head (4815b0b).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...server-ui/src/components/CodingSessionTimeline.tsx 0.00% 181 Missing ⚠️
packages/agents/src/agents/coding-session.ts 33.33% 150 Missing ⚠️
...rc/components/stateExplorer/StateExplorerPanel.tsx 0.00% 116 Missing ⚠️
...ver-ui/src/components/stateExplorer/StateTable.tsx 0.00% 104 Missing ⚠️
...r-ui/src/components/stateExplorer/EventSidebar.tsx 0.00% 84 Missing ⚠️
packages/agents-runtime/src/context-factory.ts 1.61% 61 Missing ⚠️
...ver-ui/src/components/CodingSessionSpawnDialog.tsx 0.00% 54 Missing ⚠️
...ges/agents-server-ui/src/hooks/useCodingSession.ts 0.00% 44 Missing ⚠️
packages/agents-server-ui/src/router.tsx 0.00% 42 Missing ⚠️
...agents-server-ui/src/components/EntityTimeline.tsx 0.00% 23 Missing ⚠️
... and 8 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4156      +/-   ##
==========================================
- Coverage   68.08%   64.72%   -3.36%     
==========================================
  Files         130      139       +9     
  Lines       16211    17174     +963     
  Branches     3912     4184     +272     
==========================================
+ Hits        11037    11116      +79     
- Misses       5170     6054     +884     
  Partials        4        4              
Flag Coverage Δ
packages/agents 37.36% <33.03%> (-1.04%) ⬇️
packages/agents-runtime 80.64% <5.79%> (-0.71%) ⬇️
packages/agents-server 65.55% <ø> (ø)
packages/agents-server-ui 0.00% <0.00%> (ø)
packages/electric-ax 30.26% <0.00%> (-0.20%) ⬇️
packages/experimental 87.73% <ø> (ø)
packages/react-hooks 86.48% <ø> (ø)
packages/start 82.83% <ø> (ø)
packages/typescript-client 94.30% <ø> (ø)
packages/y-electric 56.05% <ø> (ø)
typescript 64.72% <8.01%> (-3.36%) ⬇️
unit-tests 64.72% <8.01%> (-3.36%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

icehaunter and others added 16 commits April 23, 2026 21:32
Registers a durable `coding-session` entity that spawns claude/codex,
mirrors their normalized JSONL event stream into the entity's durable
stream, and exposes a dedicated UI for Create / Attach / Import flows
(including cross-agent import via the normalized format).

Key pieces:
- agents-runtime: `HandlerContext.useCodingAgent(sessionId, opts)` +
  `codingSession(id)` observation source + `CodingSessionHandle` types.
- agents: `registerCodingSession(registry, opts)` wires the entity. Per
  prompt, starts an fs-watch + poll loop that tails the JSONL via
  `tailSession` and appends events using content-derived idempotent
  keys so the UI sees user turns, assistant tokens, and tool calls as
  they land. First create-mode prompt discovers the CLI-assigned
  session id via pre/post `discoverSessions` diff. Import uses
  `importLocalSession` (same-agent: native rewrite; cross-agent:
  normalized round-trip).
- agents-server-ui: `CodingSessionSpawnDialog` (Create/Attach/Import
  tabs), `CodingSessionTimeline` rendering NormalizedEvent variants
  via Streamdown + paired tool_call/tool_result blocks,
  `CodingSessionView` composing timeline + MessageInput,
  `useCodingSession` hook. Sidebar routes `coding-session` to the
  dedicated dialog; router branches body by entity type.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Three fixes to the coding-session handler:

1. Replace `discoverSessions` (reads ~/.claude/history.jsonl) with
   direct filesystem scanning of the project directory. `claude -p`
   doesn't register sessions in history, so discovery always returned
   0 new sessions. Now scans ~/.claude/projects/<sanitized-cwd>/ for
   .jsonl files and diffs pre/post to find the CLI-created session.

2. Guard firstWake insert with `alreadyInitialized` check — the
   runtime can call the handler with firstWake=true multiple times
   if the manifest hasn't been written yet, causing a duplicate-key
   error on sessionMeta_insert.

3. Skip empty-text prompts (used as handler triggers for attach mode)
   instead of sending them to the CLI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The runtime skips the handler on first wake when there's no fresh user
input. For coding-session attach/import mode this means session history
never loads until the user sends a prompt. Work around by sending an
empty initial message on spawn — the handler skips empty-text prompts
but still runs firstWake setup.

Applied to both the UI (CodingSessionSpawnDialog) and the CLI
(--initial-message flag on the spawn command).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds a collapsible right side panel to the entity view that visualizes
StreamDB state in real-time. Adapts the 3-panel state visualizer
(TypeList + StateTable + EventSidebar) from the Electric Cloud Dashboard.

Supports time-travel through state events, FK navigation, column
sorting/resizing, and live tail toggle.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Update pnpm-lock.yaml for new dependencies
- Replace fixed 50% split with draggable vertical separator
- Move events panel to horizontal bottom layout with draggable separator
- Add consistent section headers (Types, Records, Events) with badges
- Move state explorer toggle to header icon + dropdown menu
- Fix overflow issues in all panel containers
- Remove unused cursorIndex prop from StateTable
- Fix highlighted row border-left shifting cells (use box-shadow)
- Remove dead liveTail dependency from useEffect
- Clean up unused imports and constant-as-state patterns

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… timeline

Set ScrollArea to vertical-only scrollbars to prevent horizontal
overflow sliders from appearing on hover.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…is open

Use width: 100% with box-sizing: border-box on the timeline content
wrapper so it respects the parent container width instead of expanding
to fit code blocks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…lorer

Clear the virtualizer's cached row measurements when the viewport
width changes (e.g. state explorer panel opens/closes). Without this,
the virtualizer uses stale measurements from the previous width,
causing broken absolute positioning of timeline rows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…youts

- Add a floating arrow-down button that appears when scrolled up in the
  timeline and scrolls to the latest entry on click
- Move state explorer panel to EntityPage so it works for all entity
  types (horton + coding-session), not just generic entities
- Fix React hooks violation: useCallback was after early returns
- Fix layout shift when toggling state explorer button
- Unify CodingSessionView to use the same fragment pattern as
  GenericEntityBody, removing redundant flex wrapper

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@balegas balegas force-pushed the feature/state-explorer-panel branch from c1553dd to 43aebbe Compare April 24, 2026 00:02
balegas and others added 3 commits April 24, 2026 01:04
…imeline

Adds the same floating arrow-down button to CodingSessionTimeline that
was already added to EntityTimeline, ensuring consistent UX across both
entity view types.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…olor

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

3 participants