Skip to content

feat(#89): System Prompt UX — provider grouping, prompt badge, bidirectional navigation#93

Merged
lis186 merged 6 commits into
mainfrom
feat/sysprompt-ux-89
Jun 20, 2026
Merged

feat(#89): System Prompt UX — provider grouping, prompt badge, bidirectional navigation#93
lis186 merged 6 commits into
mainfrom
feat/sysprompt-ux-89

Conversation

@lis186

@lis186 lis186 commented Jun 20, 2026

Copy link
Copy Markdown
Owner

摘要

System Prompt 頁面重新設計 + Dashboard↔System Prompt 的完整雙向導航鏈。
Badge 顯示真正的 agent type(Orchestrator/Explorer),點擊可 deep-link 到對應版本,Back 鍵能正確回來。

Changes

Server (4 files)

  • versionIndex: stores provider, agentKey, agentLabel per prompt version
  • summarizeEntry: includes toolsHash for tools-changed detection
  • /_api/sysprompt/versions: returns sessionCount, provider, agents[] with provider info
  • /_api/tools-diff: new endpoint — given two toolsHash values, returns added/removed tool names

Dashboard (4 files)

  • Prompt badge in timeline: shows ● Orchestrator · 63cc1 View in System Prompt
    • Provider dot (● anthropic / ◆ openai) conveys provider visually
    • Agent label resolved from coreHash→agentLabel lazy-fetched map (not entry.agent)
    • "View in System Prompt" link sets ?agent=X&hash=Y URL params for deep-link
  • Tools-changed warning: compares toolsHash with previous main turn in same session; fetches diff on expand
  • allEntries: now stores agent, cwd fields (fixes "Unknown" badge and "?" project name)
  • Focused mode: prompt badge now renders in both non-focused and focused (split-pane) timeline

System Prompt tab (1 file)

  • Provider grouping: agents grouped by provider (Claude Code / Codex) with provider icons
  • Session count: each version shows how many sessions used it
  • Deep-link resolution: reads ?agent=X&hash=Y from URL to auto-select agent and version
  • _hashAgentMap sync: updates the badge's agent map when versions are fetched

Navigation (2 files)

  • pushState: cross-tab navigation (Dashboard↔Usage↔System Prompt) creates history entries
  • popstate listener: Back/Forward buttons restore the correct tab
  • Tab-internal navigation stays replaceState (avoids per-turn history pollution)

Deliberate simplifications

  1. Agent map lazy fetch: _hashAgentMap is seeded on first renderPromptBadgeHtml call. First frame may briefly show entry.agent ("claude") before the map loads; subsequent SSE re-renders show the correct label. No prefetch needed — the flash is imperceptible.

  2. pushState only on cross-tab: Tab-internal turn/section selection uses replaceState. This matches Chrome DevTools / VS Code / Grafana behavior — Back should return to the previous view, not step through 47 turns.

  3. Inline onclick for deep-link: The badge onclick sets two URL params + calls switchTab. This is the terminal state — no additional params or conditional branches are expected. Event delegation would add 15 lines of glue for zero behavioral gain.

Test plan

  • TDD tests 7/7 pass (test/sysprompt-ux.test.js)
  • Full suite 900/0 (flaky OpenAI WS tests excluded)
  • Smoke test with real data (CCXRAY_HOME=~/.ccxray --port 5615)
  • Browser e2e: badge shows "Orchestrator", deep-link navigates correctly, Back button works
  • Verified onclick attribute uses single quotes (no HTML breakout)

Closes #89

🤖 Generated with Claude Code

Justin Lee and others added 6 commits June 19, 2026 13:50
…warning

Server:
- Add `provider` field to versionIndex (anthropic.js, openai.js, restore.js)
- Broadcast `toolsHash` via SSE (sse-broadcast.js)
- Add `provider` + `sessionCount` to /_api/sysprompt/versions
- New /_api/tools-diff endpoint for comparing tool sets between turns
- Add `provider` to version_detected SSE event

Dashboard (Solution 1):
- Prompt badge in timeline showing agent + coreHash + provider dot
- Tools-changed warning with cache miss indicator
- Expandable tools diff (compare added/removed tools)
- Subagent turns show gray badge, not clickable

System Prompt page (Solutions 2 & 3):
- Agent list grouped by provider (Claude Code / Codex / Other)
- Sorted by version count desc within groups
- Session count per version with expandable session list
- URL deep-link support (?agent=X&hash=Y)

Data analysis: sysHash changes 100%/turn (noise), toolsHash 2% (cache nuke),
coreHash 0.15% (CC version). Only coreHash displayed as stable identifier.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
P1: lazy-fetch coreHash→agentLabel map from /_api/sysprompt/versions
    so prompt badge shows "Orchestrator"/"Explorer" instead of "claude"/"codex".
P2: add agent field to allEntries.push() — badge no longer shows "Unknown".
P5: add cwd field to allEntries.push() — project name no longer shows "?".

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
P3: badge onclick sets ?agent=X&hash=Y URL params before switching
    to sysprompt tab, so openSystemPromptPanel resolves the correct
    agent and version.
P7: link text changed from "→ prompt" to "View in System Prompt".

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
P4: cross-tab switchTab now uses pushState instead of replaceState,
    so Back button returns to the previous tab instead of exiting.
    popstate listener restores tab state on Back/Forward.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
P6: renderPromptBadgeHtml was only called in non-focused timeline
    (preview mode). Now also renders in focused split-pane mode.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
dlScript used escaped double quotes inside onclick="..." which broke
the HTML attribute. Switch to single quotes in the inline JS.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lis186 lis186 merged commit 20267e3 into main Jun 20, 2026
2 checks passed
@lis186 lis186 deleted the feat/sysprompt-ux-89 branch June 20, 2026 12:05
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.

feat: System Prompt UX redesign — provider grouping + Dashboard bidirectional navigation

1 participant