Skip to content

fix(visualization): parse origins array for event highlighting - #7

Open
MsfPablo wants to merge 1 commit into
se-sic:masterfrom
MsfPablo:fix/event-type-highlighting
Open

fix(visualization): parse origins array for event highlighting#7
MsfPablo wants to merge 1 commit into
se-sic:masterfrom
MsfPablo:fix/event-type-highlighting

Conversation

@MsfPablo

Copy link
Copy Markdown

Root cause

eventOriginFromSummary in src/visualization/coloring.ts scanned the commit body for /"origin"\s*:\s*"([^"]+)"/g — a singular "origin" string field accepting only "agent-edit" or "inline-completion".

But formatWindowCommitMessage in src/recording/staging-tracker.ts writes the assistant commit metadata as:

JSON.stringify({ ..., origins: commit.origins, ... })

commit.origins is the plural "origins" array of EditOrigin values ("assistant-inline-completion", "assistant-agent-chat", "assistant-tool-edit", "mixed", …). The singular regex never matched, so origins.size === 0 and every commit was classified "unknown", breaking the "Event type" coloring mode entirely.

Fix

Parse the "origins":[...] array instead of the singular field, and map each serialized EditOrigin value to its EventOriginKind:

  • assistant-inline-completioninline-completion
  • assistant-agent-chat / assistant-tool-editagent-edit
  • mixedmixed
  • everything else (assistant-unknown, human, …) → unknown

The existing contract is preserved: "unknown" is still returned when the field is absent (e.g. human commits), and "mixed" is returned when the array contains more than one distinct kind (after mapping, so two agent-edit origins collapse to agent-edit rather than mixed).

Verification

  • npm run compile — clean (tsc -p .)
  • npm run lint — 0 errors (13 pre-existing warnings in src/utils/paths.ts, untouched by this change)
  • npm run test:unit — 42/42 pass, including 8 new tests in test/coloring.test.ts covering each mapping, the same-kind collapse, the distinct-kinds mixed case, and the absent-field unknown fallback.

Closes #5

eventOriginFromSummary regexed "origin":"..." (singular) but
formatWindowCommitMessage writes JSON.stringify({ origins: [...] })
with the plural "origins" array of EditOrigin values, so the regex
never matched and every commit fell back to "unknown".

Parse the "origins":[...] array and map each EditOrigin value to
its EventOriginKind (assistant-inline-completion -> inline-completion,
assistant-agent-chat/assistant-tool-edit -> agent-edit, mixed -> mixed,
everything else -> unknown). Preserves the existing "unknown"
fallback when the field is absent and the "mixed" result when
multiple distinct kinds are present.

Adds test/coloring.test.ts covering each mapping and the
multi-kind collapse/mixed cases.
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.

Event type highlighting broken

1 participant