Persistent agent session UI with orchestration graph visualization#644
Open
gx-ai-architect wants to merge 10 commits into
Open
Persistent agent session UI with orchestration graph visualization#644gx-ai-architect wants to merge 10 commits into
gx-ai-architect wants to merge 10 commits into
Conversation
Restore and adapt the session capture layer from PR #569 to run alongside existing Langfuse telemetry. Agent invocations are now recorded in a local SQLite database (.factory/sessions.db) with parent/child hierarchy support. - Add factory/sessions.py with full CRUD, transcript ingestion, and backfill - Wire _begin_session_safe/_complete_session_safe into runner.py invoke_agent - Thread FACTORY_SESSION_ID env var for parent→child session linking - Add cycle session tracking in begin_cycle_session/complete_cycle_session - Add `factory sessions <path>` CLI subcommand with --cycle and --role filters - Port 29 unit tests covering session CRUD, hierarchy, and transcript parsing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #644 +/- ##
==========================================
- Coverage 88.23% 87.48% -0.75%
==========================================
Files 70 71 +1
Lines 10570 11229 +659
==========================================
+ Hits 9326 9824 +498
- Misses 1244 1405 +161 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
6 tasks
Add 5 session API endpoints to the dashboard (cycles list, cycle detail, session detail, interactive message, sessions page) and a sessions.html page with two-column cycle browser, chat-style conversation viewer, markdown rendering via marked.js, and syntax highlighting via Prism.js. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…646) Add interactive DAG visualization of agent orchestration to sessions.html. Includes graph API endpoint, dagre layout, click-to-navigate, hover tooltips, and hash-based role coloring. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
Author
Phase 3: Agent orchestration graph visualization (#646)Added interactive DAG visualization of agent orchestration to sessions.html: Changes
Key design decisions
All 23 tests pass, lint clean. |
The send_session_message endpoint was resuming Claude sessions without the agent's role prompt, causing resumed agents to lose their factory specialist identity. Now resolves the session's agent_role to its prompt file, appends any evolved playbook, writes to a temp file, and passes via --system-prompt-file for reliable large-prompt injection. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Bug 1: Remove hardcoded 8-phase linear pipeline bar from dashboard homepage that misrepresented the dynamic agent graph workflow. Replace with prominent Sessions button on project cards and session summary stats (cycle count, total sessions). Bug 2: Fix CEO session having zero items, no claude_session_id, and stuck in 'running' status. Capture CLAUDE_CODE_SESSION_ID env var in begin_cycle_session() and pass it through to the session row. Pass metadata with session_id in complete_cycle_session() to trigger transcript ingestion. Update _discover_claude_session_id() to handle CEO sessions by excluding known child agent transcripts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The session lifecycle functions were defined in runner.py but never called from cmd_ceo(), so CEO sessions were never persisted to SQLite and child agents had no parent_id to link to. Wrap both the headless and interactive code paths with begin/complete_cycle_session calls. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…etion The CEO session never gets a claude_session_id because CLAUDE_CODE_SESSION_ID isn't set in the parent factory process — it only exists inside the spawned Claude Code subprocess. This fix makes complete_session() discover the claude_session_id by scanning transcript files when none was provided, and also prevents COALESCE from overwriting a previously-discovered ID with NULL. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…k in _discover_claude_session_id
The 'factory: ' prefix check was incorrectly matching CEO session titles
like 'factory: i want build snake game', adding them to matched_child_ids
and preventing the CEO fallback path from finding them. Now requires a '/'
in the name to distinguish child agents ('factory: project/role') from CEO
sessions.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… cross-project false matches The broad fallback in _discover_claude_session_id scanned ALL Claude Code project directories when the exact one had no candidates. This caused false matches — e.g., picking up transcripts from the currently running CEO process for a different project instead of the target worktree's CEO. Changes: - Remove the all-directory fallback scan (lines 272-278) — only search the exact project directory derived from project_path - CEO fallback now picks by timestamp proximity to completion time instead of just "most recent", preventing stale transcript matches Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…r on errors Backend: send_session_message now checks subprocess returncode and returns HTTP 410 with error detail when claude --resume fails. Frontend: sendMessage shows error messages inline in the chat area instead of alert() dialogs, and always re-enables the input controls via finally. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Jun 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements #642 — a persistent agent session management UI with graphical orchestration visualization for the factory dashboard.
factory/sessions.py) — captures every agent invocation in a localsessions.dbwith hierarchical parent→child linking, alongside existing Langfuse telemetry (additive, not replacing)sessions.html) — two-column layout with cycle list + chat-style conversation viewer, using marked.js for markdown and Prism.js for syntax highlightingKey design decisions
Verified
Test plan
Manual E2E:
Closes #642, closes #643, closes #645, closes #646
🤖 Generated with Claude Code