Skip to content

fix(dashboard): show one source-link chip per GitHub PR whatever the owner/repo case - #34650

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/source-chip-github-case
Nov 10, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/source-chip-github-case

Conversation

@kyleseaman

@kyleseaman kyleseaman commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A session card in the Crew sidebar shows one chip per GitHub pull request or issue, even when the chat mentioned it with different owner/repo letter case.

A session that mentioned https://github.com/kirodotdev/KiroCrew/pull/21991 and later https://github.com/kirodotdev/kirocrew/pull/21991 showed two chips, kirodotdev/KiroCrew #21991 and kirodotdev/kirocrew #21991. GitHub treats owner and repository names case-insensitively, so both are the same pull request.

Why it matters

The duplicate chip takes one of the card's three chip slots, inflates the "+N" overflow count, and costs a second provider status read for the same PR. Unlinking one of the two chips left the other on the card, so the user could not remove the PR in one step.

Not a goal

  • Changing GitLab, Jira, Bitbucket Server, Gerrit or plugin identities. GitLab project paths are case-sensitive and stay that way.
  • Sharing one status-cache entry between two different sessions that each spell the same PR differently. Each chip's status is still cached under its own URL, as today.
  • Rewriting dismissal keys already stored on disk. They are folded when read instead.

What changed (motivation → approach → change)

The sidebar dedupes chips on SourceRef.identity, and for GitHub that identity kept owner and repo exactly as written, so two spellings of one PR got two identities.

Piece Change
SourceRef.identity (source_providers/contract.py) For GitHub only, the ASCII letters of host, owner and repo are lowercased in the identity. The ref itself keeps the spelling it was mentioned with, so the chip still links to and shows the newest mention's spelling. Only A-Z fold: GitHub names are ASCII, and full Unicode lowercasing would merge lookalikes (the Kelvin sign becomes k) and can lengthen a key past its 512-character bound.
canonical_source_identity_key (contract.py) Folds a serialized identity key the same way. Unlink tombstones are persisted under the identity key, so a key recorded before this change still names a mixed-case spelling.
Chip derivation (slot_projection.py) Folds every dismissed key before comparing, so a chip the user already unlinked stays hidden whichever spelling mentions it.
Unlink route (chat_api/source_links.py, state_parts/source_links.py) Folds the incoming key after validation. Every check of whether a slot or an on-disk line already holds it folds each stored key and stops at the first match. The tombstone it writes hides every spelling, and a retry of an unlink already stored under an old key stays an idempotent 200 with no write.

The frontend needed no change: sourceLinkKey in website/src/utils/pullRequestLinks.ts already case-folds GitHub URLs, and it treats the backend's identity field as opaque.

Backwards compatibility

Compatible: identity keys for mixed-case GitHub links now serialize lowercase, and keys stored or sent in the old mixed-case form still validate and still match because both readers fold them.

Removes nothing: the change merges chips that named the same GitHub object; every key, route and stored field keeps its shape.

Tests

test/test_source_link_github_case.py covers:

  • Owner-only, repo-only and owner+repo case variants collapse to one chip, counted once in source_links_total and the three-chip budget, and refreshed for status once (_slot_chip_urls).
  • The chip shows the newest mention's spelling.
  • A GitHub Enterprise host with mixed-case host and owner collapses to one chip.
  • /pull/21991 and /issues/21991 stay two chips; GitLab paths that differ only in case stay two.
  • Unlinking one spelling hides every spelling; a tombstone under the old case-sensitive key still hides the chip; the unlink route given an old key records the folded one; retrying an unlink already on disk under an old key returns 200 without a write, and the on-disk scan stops at the match instead of folding the whole line; a slot rebound mid-unlink onto a transcript that holds the object under an old key keeps the dismissal; mentions_source_identity matches across spellings.
  • A non-ASCII lookalike owner stays a separate chip, and folding never lengthens a key.

Each production hunk was reverted on its own: the identity fold is caught by 11 tests, the derivation fold by the old-tombstone test and the route test, the route fold by the route test, the folded already-dismissed checks by the retry, long-line and rebound-slot tests, and the ASCII-only fold by both non-ASCII tests.

Determinism: the new file passes 20 runs at -n0, 10 runs at -n 4 beside test/test_dashboard_source_link_unlink.py, and 3 shuffled orders.

Proof: PROVEN test/test_source_link_github_case.py::TestOneChipPerObject::test_case_variants_collapse_to_one_chip[https://github.com//pull/21991], test/test_source_link_github_case.py::TestOneChipPerObject::test_case_variants_collapse_to_one_chip[https://github.com//pull/21991], test/test_source_link_github_case.py::TestOneChipPerObject::test_case_variants_collapse_to_one_chip[https://github.com//pull/21991], test/test_source_link_github_case.py::TestOneChipPerObject::test_the_chip_shows_the_newest_spelling, test/test_source_link_github_case.py::TestOneChipPerObject::test_variants_count_once_toward_the_three_chip_budget (head c1686df)

Manual verification

N/A — unit coverage sufficient: the chip list is computed server-side by the derivation these tests drive, and the frontend renders that list unchanged.

Related Issues

N/A — no tracking issue.

Sibling sweep

Swept: git grep -nE ".identity\b|source_ref_identity_key|_dismissed_source_links" -- src/kiro_crew/dashboard
Sibling: src/kiro_crew/dashboard/state_parts/source_links.py:355 -- not affected -- mentions_source_identity compares against SourceRef.identity, which now folds
Sibling: src/kiro_crew/dashboard/source_providers/chip_status.py:191 -- not affected -- status and visibility keys follow the one chip URL a session now carries
Sibling: website/src/utils/pullRequestLinks.ts:75 -- not affected -- sourceLinkKey already lowercases GitHub URLs

Pattern harvest

Not generalizable: the case rule is specific to how GitHub resolves names, and it now lives in the one identity every source-link consumer keys on.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@kyleseaman
kyleseaman requested review from a team and KiroCrewCaptain as code owners November 10, 2026 16:34
@kyleseaman
kyleseaman requested a review from buluoray November 10, 2026 16:34
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 10, 2026
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of bf3f702ab01b608af5af032f32b28665c79aad28 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] bf3f702

False positive or not applicable? A repository writer can comment:
/ai-review override gpt bf3f702ab01b608af5af032f32b28665c79aad28 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision bf3f702ab01b608af5af032f32b28665c79aad28 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of bf3f702ab01b608af5af032f32b28665c79aad28 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. The duplicate chip has a reproduction in the description and in tests, and the fix goes into the one identity every chip consumer keys on. That is the cause, not a per-site patch.

Notes

  • Item 1 — oversized: "github": frozenset({"host", "owner", "repo"}) folds host, but links.py:370 and links.py:467 already lowercase the hostname before _github_ref builds the ref. Old keys were written from those refs too, so host is already lowercase in every one. Folding it does nothing.
    Subtraction: drop "host" from _CASE_FOLDED_IDENTITY_FIELDS["github"]. Leave the host part out of the docstring wording to match.

What this change ships

Inventory (5 items) — 4 justified

Intent: one chip per GitHub PR or issue on a session card, however the owner/repo was capitalised — FIX.

  1. Mentions that differ only in owner/repo case collapse into one chip, counted once and refreshed once — oversized (the host fold does nothing)
  2. The merged chip shows the newest mention's spelling — justified
  3. A chip unlinked under the old mixed-case key stays hidden whichever spelling mentions it again — justified
  4. The unlink route folds the key it receives, so a retry under an old key returns 200 with no write — justified
  5. GitLab paths and non-ASCII lookalike owners stay separate chips — justified

[FIRST-PRINCIPLES-REVIEWED] bf3f702

Description read

[DESCRIPTION-READ] 5e2b664e07e796cd44e83969a7d9899a8a2c9008d8ff797c7059771d14818ad3

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of bf3f702ab01b608af5af032f32b28665c79aad28 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the fold lives in the one identity every chip consumer keys on, and dismissal keys already on disk are folded when read, not migrated.

[DESIGN-REVIEWED] bf3f702

Description read

[DESCRIPTION-READ] d9046d41a22cf18f6ded4b424a45dbd4a8793c8d472b7e22013bcd3d6bf3df98

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed bf3f702ab01b608af5af032f32b28665c79aad28 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] bf3f702

Verdict parsed from the review's SHA-scoped output markers for commit bf3f702ab01b608af5af032f32b28665c79aad28.

False positive or not applicable? A repository writer can comment:
/ai-review override fable bf3f702ab01b608af5af032f32b28665c79aad28 false-positive: <reason, 20 to 500 characters>

@kyleseaman

Copy link
Copy Markdown
Contributor Author

Backend Tests reds on c1686df are main's, not this PR's: the Slack code-channel trust tests and test_session_markdown's markdown-it-py case fail identically on a clean origin/main (6cc4e97 and ed80c1d). #34646 fixes both; this PR rebases onto main once it merges. Coverage Gate fails closed only because Backend Tests did.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 10, 2026
@kyleseaman
kyleseaman force-pushed the fix/source-chip-github-case branch from c1686df to bf3f702 Compare November 10, 2026 19:44
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 10, 2026
@kyleseaman

Copy link
Copy Markdown
Contributor Author

Rebased onto main now that #34646 (the fix for main's Backend Tests breaks) has merged. The PR's patch is unchanged; CI is running again.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 10, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 10, 2026 21:56

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. On this head the review read the full unlink handler and the derivation in slot_projection.py. It confirmed that every membership test that can meet an old mixed-case GitHub key now folds it, and that GitLab, Jira, Bitbucket and Gerrit keys keep their case. It ran the new test file (20 passed) and 321 related source-link tests (all passed), and applied single-line mutations that showed the identity fold and the route fold are pinned.
Done well: the fix lives in SourceRef.identity, the one key every chip reader uses. Old tombstones are folded when read instead of rewritten on disk, and the ASCII-only fold keeps lookalike owners apart and keeps keys inside the 512-character bound.
Optional:

  • The folded cap check in chat_api/source_links.py (line 580) has no test. A retry of an old-key unlink on a slot that already holds 512 dismissed keys should return 200. A test for that case would pin it.
  • "host" in the GitHub fold set (contract.py:158) changes nothing, because links.py already lowercases the host. You could drop it, or correct the body's coverage sentence, which also credits the pending-set fold that no test exercises.
  • When the in-memory set holds no spelling of an old key, the persist path can store both spellings of one tombstone. Skipping the write when the key is already durably dismissed would avoid the extra slot.

@KiroCrewCaptain
KiroCrewCaptain merged commit 7322107 into main Nov 10, 2026
97 of 98 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/source-chip-github-case branch November 10, 2026 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants