Skip to content

fix(members): land on Mate once, then the ordinary landing, even after a failed welcome - #18904

Merged
bolichen97 merged 1 commit into
mainfrom
fix/crew-open-last-mate
Oct 12, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/crew-open-last-mate

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Mate gets one landing on the Crewmates page, for fresh and existing users alike; once its welcome is sent or attempted, a bare visit opens the crewmate the user last chatted with.

Goal revised 2026-10-11 on the decision owner's ruling (buluoray, review of #18903, recorded in rfc-mate-landing-once.md). The first version yielded whenever another crewmate had been chatted with; the owner rejected that, since existing users would never be introduced to Mate.

A user was moved onto Mate (the first crewmate from #18406) on every bare /members visit, never reaching the conversation they came back for. When Mate's welcome lands this already ends. It never ends when the welcome fails or is never owed: the once-only marker is claimed before the welcome is dispatched, a failed turn leaves the thread empty for good, a Mate with no owed record is refused before the claim, and pendingMate answers Mate on every visit.

Why it matters

A user whose Mate welcome failed (signed-out CLI, no backend) or was never owed is pinned on an empty Mate for good, so the "reopen the last-interacted crewmate" landing (#17808, #17953, backed by crew_recency) never runs for them.

Not a goal

  • Changing Mate's creation, first welcome, rename_self, the once-per-visit rule below md, or the Meet CrewMates hold.
  • Changing the landing once Mate has a message (unchanged).
  • Changing crew_recency or the server's last_chat_ts.

What changed (motivation → approach → change)

Symptom: a user lands on an empty Mate on every visit → cause: resolveMateLanding was pendingMate (thread empty), and an empty thread does not mean a welcome is coming → change: Mate is landed on only while its welcome is still coming, per rfc-mate-landing-once.md (accepted by buluoray on #18903; status flip and owed condition in #19064).

  • src/kiro_crew/dashboard/handlers/members.py _stamp_welcome_claimed: on the roster read, Mate's row (and only Mate's) carries welcome_owed (members.welcome_owed) and welcome_claimed (the welcome_claimed.json marker exists). A marker that cannot be checked leaves welcome_claimed off; an unreadable owed record reads as not owed.
  • website/src/pages/members/MembersPage.tsx resolveMateLanding: Mate only when pendingMate (no row) AND welcome_owed === true AND welcome_claimed === false. Anything else, or a row that does not say, uses the ordinary landing (last-chatted, then remembered).
  • website/src/api/client/agents.ts: the two optional row fields.
  • Unchanged: ?member= wins, default does not count, Mate stays on the roster, pendingMate and the Meet CrewMates hold.

Backwards compatibility

Compatible: two optional fields on Mate's roster row only; nothing main accepts is rejected.

Reader: website/src/pages/members/MembersPage.tsx:resolveMateLanding -- crew page -- a Mate whose welcome is owed and unclaimed still lands for fresh and existing users (an existing user who chatted with a crewmate lands on an unseen Mate once, a default + Assistant roster opens the Assistant…, a never-chatted Mate opens below md too…)
Reader: website/src/hooks/useMeetCrewmatesGate.ts:useMeetCrewmatesGate -- crew page -- unchanged; still reads pendingMate (useMeetCrewmatesGate.test.tsx)

Tests

website/src/pages/members/MembersPage.test.tsx (the assistantRow fixture reports an owed, unclaimed welcome):

  • an existing user who chatted with a crewmate lands on an unseen Mate once
  • after Mate's welcome row exists, the next bare visit lands on the last-chatted crewmate
  • a claimed welcome marker on an empty Mate thread (a failed welcome) lands on the last-chatted crewmate (also: Mate still opens from the roster)
  • an empty Mate with no owed welcome and no marker lands on the ordinary landing
  • a roster that cannot say whether Mate was seen uses the ordinary landing
  • resolveMateLanding unit cases: claimed, unknown claim, not owed, unknown owed.

test/test_members_welcome_claimed.py: Mate's row reports welcome_owed false then true after mark_welcome_owed, welcome_claimed false then true after claim_greeting_marker (thread still empty), no fields on other rows; an unreadable marker leaves welcome_claimed off.

Red-before: on origin/main code with these test files, 4 vitest cases fail (unit, failed welcome, not owed, unknown state) and the backend before/after test fails (KeyError: 'welcome_owed'). On this branch: src/pages/members/, useMeetCrewmatesGate, assistantMember, MeetCrewmatesFlow pass (30 files, 755 tests, --maxWorkers=1); pytest test_members_welcome_claimed, test_crew_starred, test_mate_welcome, test_members_roster_recency, test_welcome_owed pass (75). tsc, eslint --max-warnings 0 on touched files, i18n:check pass.

Manual verification

A built SPA over a stubbed API (scripts/lib/stub-dashboard-api.mjs), Crewmates preview on, bare /members, built from origin/main (before) and this branch (after):

Mate's welcome (+ oncall chatted 1 h ago) Before After
tried and failed (claimed, empty) ?member=mate ?member=oncall
still coming (owed, unclaimed) ?member=mate ?member=mate

Screenshots / video

Failed welcome (marker claimed, Mate's thread empty):

Before: before, failed welcome, light

After: after, failed welcome, light

Dark theme, and a welcome still coming (unchanged: lands on Mate)

before, failed welcome, dark

after, failed welcome, dark

after, welcome still coming, light

after, welcome still coming, dark

Related Issues

Follows #18406. Decision: #18903 (merged), #19064 (accepted status and owed condition).

Pattern harvest

Not generalizable: one landing rule read an empty thread as "a welcome is coming"; the fix reads the welcome's own server state.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • 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

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners October 10, 2026 18:51
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 10, 2026
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 429ade8b83acc97634dcd70e464663070605cea1 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Check that a reload while the welcome is still being sent (marker claimed, no row yet) skipping Mate is acceptable under rfc-mate-landing-once.

[DESIGN-REVIEWED] 429ade8

Description read

[DESCRIPTION-READ] 718b523dcbfe3ef07deab7636d36d3464eb7ed349abfc3d0829d49441d5964ac

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 Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 429ade8b83acc97634dcd70e464663070605cea1 — 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/CONCERNS are advisory.

First-Principles-Verdict: PASS

Both new row fields feed only the one conjunction in resolveMateLanding. The accepted RFC asks for both states on Mate's row, so check that before collapsing them.

What this change ships

Inventory (5 items) — 5 justified

Intent: a user whose Mate welcome failed or was never owed should get the ordinary Crewmates landing instead of being pinned on an empty Mate. FIX.

  1. After a welcome that was claimed but failed (Mate's thread still empty), a bare /members visit opens the last-chatted crewmate, not Mate. — justified
  2. A Mate that was never owed a welcome no longer takes over the bare landing. — justified
  3. If the roster can't say whether Mate was seen (unreadable marker, older gateway), the page uses the ordinary landing. — justified
  4. Mate's roster row now carries welcome_owed and welcome_claimed. Each has one consumer, resolveMateLanding; no other row gets them. — justified
  5. Fresh and existing users with an owed, unclaimed welcome still land on Mate once (unchanged, now pinned by a test). — justified

[FIRST-PRINCIPLES-REVIEWED] 429ade8

Description read

[DESCRIPTION-READ] b41f0f4bc2405ea4148ff5ff0a699d9b04d0ed5267c8061fd2b1999708bdffab

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 Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

Findings (advisory only, nothing blocks the merge).

FINDING — docs/system-specs/modules/crew-mode.md:1160 — the spec still says the page "opens Mate while no message has been exchanged with it (resolveMateLanding: Mate's row has neither has_dm_message nor a live last_message)". resolveMateLanding now also needs welcome_owed === true && welcome_claimed === false. So when the marker is claimed and the thread is empty, or no welcome is owed, the code takes the ordinary landing and announces mc-crewmates-page-entered, while the owning spec says it opens Mate and suppresses that announcement → Fix: in the same commit, update that paragraph to say the landing applies only when the welcome is owed, the marker is unclaimed and the thread is empty, and that any other state, or one the gateway can't read, gets the ordinary landing.

[OPUS-REVIEWED] 429ade8

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 429ade8b83acc97634dcd70e464663070605cea1: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 429ade8b83acc97634dcd70e464663070605cea1 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: PASS

A human should open bare /members after a failed Mate welcome and confirm it opens the last-chatted crewmate. The author's images were removed, so no reviewer saw them.

[UX-REVIEWED] 429ade8

Description read

[DESCRIPTION-READ] a129908d60f1e074daa00e9b20d45540739363de6b049881a037b465ea102014

That sha256 names everything this verdict read: the PR description, plus the 3 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 Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 429ade8

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 429ade8b83acc97634dcd70e464663070605cea1: <one-sentence reason>

@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 Oct 10, 2026
@iamwhatever iamwhatever changed the title fix(members): open the last-chatted crewmate, not a never-chatted Mate, for a returning user fix(members): land on Mate once, then the ordinary landing, even after a failed welcome Oct 11, 2026
@iamwhatever
iamwhatever force-pushed the fix/crew-open-last-mate branch from 5ed7d6c to 38f015b Compare October 11, 2026 08:01
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 11, 2026
@iamwhatever
iamwhatever force-pushed the fix/crew-open-last-mate branch from 38f015b to fe713e7 Compare October 11, 2026 08:28
@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 Oct 11, 2026
@iamwhatever
iamwhatever force-pushed the fix/crew-open-last-mate branch from fe713e7 to 81a4032 Compare October 11, 2026 09:10
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 11, 2026
…r a failed welcome

Mate's landing (#18406) answered Mate while its thread was empty. The
once-only welcome marker is claimed before the welcome is dispatched, so
a failed welcome left the thread empty for good and every bare visit
landed on Mate. The roster row now reports whether Mate's marker is
claimed (welcome_claimed), and resolveMateLanding yields once the marker
is claimed or the thread has a row; an unknown state uses the ordinary
landing (rfc-mate-landing-once, #18903).
@iamwhatever
iamwhatever force-pushed the fix/crew-open-last-mate branch from 81a4032 to 429ade8 Compare October 11, 2026 13:36
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 11, 2026
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 11, 2026

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving at 429ade8.

Checked against the accepted rule: Mate is the landing target only until its welcome has been sent or attempted, then the ordinary landing applies, and ?member= keeps priority.

  • resolveMateLanding (MembersPage.tsx:331-334) lands on Mate only when its thread is empty, welcome_owed === true and welcome_claimed === false. Anything else, including a row that omits the fields, uses the ordinary landing. The rule is evaluated only when no ?member= is present (MembersPage.tsx:3412).
  • Failed welcome: maybe_start_first_greeting claims the O_EXCL marker before dispatching (mate_welcome.py:200-213) and never removes it. A turn that fails leaves the marker claimed and the thread empty, which now reads as seen and lands on the last-chatted crewmate. This is the case that previously pinned users on Mate.
  • _stamp_welcome_claimed (handlers/members.py:952-975) adds the fields only to the built-in Mate row and uses the same members.welcome_owed predicate the greeter checks before claiming, so the landing and the greeter agree on whether a welcome is owed. An unreadable marker leaves welcome_claimed off, and the client treats that as seen, so nobody gets pinned.
  • Existing users who already chatted with Mate: pendingMate is undefined once the thread has history (assistantMember.ts:22-27), so their landing is identical to main.

Each guard is pinned by the suite. Removing welcome_claimed === false, removing welcome_owed === true, removing the server stamp, or reporting an unreadable marker as false each turns a specific named vitest or pytest case red. Locally, the MembersPage and src/lib vitest suites (626 tests) and the four related pytest modules (50 tests) pass at this head. CI is green.

Non-blocking: with a claimed-but-empty Mate, the page now dispatches the Meet CrewMates entry event on that visit, while useMeetCrewmatesGate still reads pendingMate. Worth confirming that this order is what you want for a user whose welcome failed.

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved at head 429ade8: PR Readiness is green, no open change requests, and the review lanes passed. (AI-assisted review at bolichen97's request.)

@bolichen97
bolichen97 merged commit d9557f5 into main Oct 12, 2026
103 checks passed
@bolichen97
bolichen97 deleted the fix/crew-open-last-mate branch October 12, 2026 05:05
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 12, 2026
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.

3 participants