Skip to content

fix: dashboard bulk-analyze false failures + codex/copilot message-id collision - #17

Merged
ClaudiaFang merged 1 commit into
masterfrom
worktree-snuggly-riding-sedgewick
Jul 21, 2026
Merged

fix: dashboard bulk-analyze false failures + codex/copilot message-id collision#17
ClaudiaFang merged 1 commit into
masterfrom
worktree-snuggly-riding-sedgewick

Conversation

@ClaudiaFang

Copy link
Copy Markdown
Member

Summary

  • Dashboard's "Needs Attention" / Bulk Analyze list classified sessions as unanalyzed using useInsights(), which the server caps at 5000 rows (ordered by insight timestamp). On large histories (e.g. insights check --days 36500 --analyze), a single session's analysis produces 5-10+ insight rows, so the cap silently drops already-analyzed sessions from the response — they get misclassified as unanalyzed, land in Bulk Analyze, and then genuinely fail there against the dashboard's own configured LLM provider (separate from whatever runner the CLI used).
  • Added GET /api/analysis/analyzed-session-ids, backed by analysis_usage (one row per session, PRIMARY KEY (session_id, analysis_type)) instead — no row-cap risk at this scale. DashboardPage and SessionListPanel now use it for analyzed/unanalyzed classification.
  • Found and fixed a related data-integrity bug while investigating a "session shows 0 messages despite message_count=22" report: CodexProvider and CopilotCliProvider generated message ids like codex-user-0 / copilot-assistant-1 with no session scoping. Since messages.id is a global PRIMARY KEY, INSERT ... ON CONFLICT(id) DO UPDATE silently reassigned earlier sessions' messages to whichever session synced last with the same index — leaving most sessions with a correct message_count on the sessions row but zero actual rows in messages. Message ids are now scoped by session id, so they can no longer collide across sessions.

Test plan

  • pnpm --filter @code-insights/cli build, pnpm --filter @code-insights/server build, pnpm --filter @code-insights/dashboard build all pass
  • cli test suite: 902/902 pass
  • server test suite: 655/655 pass
  • dashboard test suite: 15/15 pass
  • Existing local databases affected by the id-collision bug need a data repair (delete corrupted messages rows for codex-cli/copilot-cli sessions + sync --force to re-populate) — not included in this PR, flagged separately to the user since it mutates their live local DB.

🤖 Generated with Claude Code

…sights query

DashboardPage/SessionListPanel classified sessions as "unanalyzed" using
useInsights() (server-capped at 5000 rows, ordered by insight timestamp).
On large histories a single session's analysis produces 5-10+ insight rows,
so the cap silently drops already-analyzed sessions out of the response,
misclassifying them as unanalyzed and feeding them into Bulk Analyze, where
they then genuinely fail against the dashboard's configured LLM provider.

Add GET /api/analysis/analyzed-session-ids, backed by analysis_usage
(PRIMARY KEY (session_id, analysis_type), one row per session) instead.

Also fix a message-id collision bug found while investigating a related
"no messages" report: CodexProvider and CopilotCliProvider generated
message ids like `codex-user-0` with no session scoping, colliding across
every session from that provider. Since messages.id is a global PRIMARY
KEY, INSERT ... ON CONFLICT DO UPDATE silently reassigned earlier
sessions' messages to whichever session synced last with the same index,
leaving most sessions with a correct message_count but zero actual rows.
Message ids are now scoped by session id.
@ClaudiaFang
ClaudiaFang marked this pull request as ready for review July 21, 2026 13:22
@ClaudiaFang
ClaudiaFang merged commit 8f9ea00 into master Jul 21, 2026
1 check passed
@ClaudiaFang
ClaudiaFang deleted the worktree-snuggly-riding-sedgewick branch July 21, 2026 13:22
ClaudiaFang pushed a commit that referenced this pull request Jul 23, 2026
feat: scaffold Starlight documentation site
ClaudiaFang added a commit that referenced this pull request Jul 23, 2026
…ewick

fix: dashboard bulk-analyze false failures + codex/copilot message-id collision
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