Skip to content

fix(core): only show a collision summary when it actually disambiguates#225

Merged
guillaumejay merged 1 commit into
mainfrom
fix/disambiguator-shared-summary-v2
Jul 16, 2026
Merged

fix(core): only show a collision summary when it actually disambiguates#225
guillaumejay merged 1 commit into
mainfrom
fix/disambiguator-shared-summary-v2

Conversation

@guillaumejay

Copy link
Copy Markdown
Collaborator

Closes #220. Supersedes #221, which was cut from a stale main and conflicted irreconcilably once core/src/app.rs was split into submodules (#169/#173).

Problem

Two sidebar rows for two genuinely distinct sessions read identically apart from the counter:

Comprendre les vignettes  ·  8   ·  c'est quoi les vignettes ?
Comprendre les vignettes  ·  12  ·  c'est quoi les vignettes ?

The same question asked twice in one project makes the CLI derive the same ai-title for both, so the titles collide and the summaries match. collision_subtitle surfaced the summary regardless — its only condition was that the shown title diverges from the summary, which holds here — so both rows repeated the same text and the relative-age fallback was never reached.

Fix

The summary is shown only when it is unique among the rows sharing that title; otherwise the row falls back to the age, which always differs.

Since that uniqueness check needs the whole group, colliding_titles and collision_subtitle are folded into a single per-group pass, App::session_disambiguators(group) -> HashMap<String, Option<String>>: presence marks a colliding row, the value is the separating summary or None for the age fallback. One traversal instead of two, and the two concepts no longer have to be kept in sync at the call site. Both had exactly one caller.

Uniqueness is checked on the (title, summary) pair rather than the summary alone: a row with a different title that happens to share a summary must not make the colliding pair look ambiguous. A test pins that.

Tests

  • the_same_question_asked_twice_falls_back_to_the_age — the reported case, plus the third-row guard above.
  • Existing collision tests carried to the new API; the /clear title-carryover case (divergent, unique summaries) still surfaces the summary.

Verification

cargo fmt --all --check and cargo test --workspace green. cargo clippy --workspace currently fails on Windows for an unrelated pre-existing reason — crates/pty/src/status.rs, fixed in #224; with that applied, clippy is green here too. The touched crates (termherd-core, termherd-app, 437 tests) are clean.

Not eyeballed in a running build — the change is core logic with unit coverage; the view edit is a mechanical swap of the same two values.

Two distinct sessions with the same first prompt get the same ai-title from
the CLI, so their sidebar rows collide *and* share a summary. The
disambiguator surfaced that summary anyway — its condition was merely that
the shown title diverges from the summary, which is true here — so both rows
repeated identical text and the age fallback was never reached.

Gate the summary on it being unique among the rows sharing that title, and
fold colliding_titles + collision_subtitle into one per-group pass
(session_disambiguators) since the uniqueness check needs the whole group.

Closes #220
@guillaumejay
guillaumejay force-pushed the fix/disambiguator-shared-summary-v2 branch from 886c03b to 1a91cb7 Compare July 16, 2026 19:50
@guillaumejay
guillaumejay merged commit 58fa713 into main Jul 16, 2026
17 checks passed
@guillaumejay
guillaumejay deleted the fix/disambiguator-shared-summary-v2 branch July 16, 2026 19:56
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.

Session disambiguator shows a summary that doesn't disambiguate (identical prompt + identical ai-title)

1 participant