Skip to content

fix(members): list only crewmates the user chatted with, reopen the last one - #17808

Merged
chenmingwei23 merged 1 commit into
mainfrom
feat/crew-mate-list-recency
Oct 8, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
feat/crew-mate-list-recency

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: The Crewmates page lists only the crewmates the user actually chatted with, newest first, and reopens the last one after a gateway restart.

The crewmate switcher in the Crewmates header lists every roster row: package-installed crews, app-driven crews, crews that only ran crons, wakes or sub-agents. On a busy host that is dozens of rows. Coming back to /members after a restart opens whichever row the old fallback picks, not the crewmate the user last talked to.

Why it matters

The switcher is the only crewmate list on the desktop DM view. When most of its rows are crews the user never talked to, the few they did use are hard to find. Reopening the wrong crewmate after a restart puts the user in a thread they did not come back for.

Not a goal

  • No change to the full roster's filters, teams, star or sort controls.
  • Normal-chat history from before this change is not backfilled. Only Crewmates DM threads are seeded.
  • No change to what a background turn writes or how it is shown.

What changed (motivation → approach → change)

Symptom → cause → change:

Part Before After
Switcher list orderedMembers (every row) the column's own hide rule, via #17835 (this PR builds on it and leaves CrewmateSwitcher untouched)
Listing rule (listedByDefault) DM holds any message, created on the dashboard, starred, or the default crew the user sent this crew a message (last_chat_ts > 0), or starred it
Recent order (sortRoster) last_active_ts (moves on background turns too) last_chat_ts
Default open (resolveDefaultMember, URL sync effect) browser memory, then greatest last_active_ts greatest last_chat_ts first, then browser memory, then last_active_ts

The signal: nothing on main records "a person typed this". DM messages, crew-log recency and the dashboard-created flag also move for crons, wakes, patrols, workers and apps. New src/kiro_crew/crew_recency.py keeps {crew name: epoch} in crew_recency.json under the data home. POST /api/chat (dashboard/chat_handlers.py) writes to it only when the caller is the dashboard user: no app token, no cron attestation. Writes happen off the event loop, at most one per 30 s per crew. A chat with no crew picked is recorded under "", and the default crew owns it. GET /api/members (dashboard/handlers/members.py) ships the value as last_chat_ts, typed in website/src/api/client/agents.ts. On first read, a one-time seed reads each DM thread's newest typed user row. Gateway-injected rows open with [ and are skipped.

The record is written when the send reaches the handler. So a send whose turn later fails still counts as the user chatting with that crew. Every writer refuses to replace a file it cannot read, and a seed that could not read a thread is retried on a later read. On an accepted send, sendTurn (website/src/chat-core/transport/sendTurn.ts) stamps the same value on the roster row bound to that slot and marks the roster stale (noteUserChat in website/src/api/membersQuery.ts). A crewmate the user just messaged therefore stays listed after they switch away. docs/system-specs/modules/crew-mode.md states the new rules. Creating a crewmate counts too: POST /api/agents (dashboard/agent_admin/crew_records.py, owner-only, so never an app token) stamps the new crew unless an attested cron made it, so it is listed at once and sorts first. The decision record is #17816 (rfc-crewmates-chatted-list.md, amending rfc-crewmates-launch.md screen 02) and #17844 (creation counts).

A row with no last_chat_ts (an older gateway) keeps the old rule, so a mixed-version deploy does not blank the list.

Backwards compatibility

Compatible: last_chat_ts is a new optional field; every existing field is still shipped, and a row without it is listed by the old rule.

The diff hides rows the old rule listed (a tighter listing rule):
Reader: website/src/pages/members/MembersPage.tsx:shownMembers -- crew page -- header count and filter tallies read the same rule, so a count never includes a hidden row (MembersPage.filters.test.tsx)
Reader: website/src/pages/members/MembersPage.tsx:listedMembers -- crew page -- auto-open candidates; the last-chatted crewmate leads, and a hidden one is still opened by URL or search (lists only crewmates the user chatted with test)
Reader: website/src/pages/members/MembersPage.tsx:sortedMembers -- crew page -- roster column; hidden rows are reachable through the search box (rosterFilter.test.ts rosterShows)
Reader: website/src/pages/members/CrewmateSwitcher.tsx:population -- crew page -- after #17835 the chip runs rosterPopulation / rosterShows, the same rule as the column; its search reaches every row (#17835's CrewmateSwitcher.test.tsx)

Tests

  • test/test_crew_recency.py: store round trip, write granularity, no backwards move, junk values, unreadable file is never reseeded, seed runs once and a live record wins. api_chat records the slot's crew for the dashboard user and "" for a no-crew chat. It records nothing for an app token or a cron (mutation: forcing the guard to True turns both red). Roster ships last_chat_ts and folds "" into the default crew. The seed counts a typed row and skips a peer [sent by session …] row and assistant speech.
  • rosterFilter.test.ts: listing and Recent order by last_chat_ts; starred still listed; old-gateway fallback unchanged.
  • MembersPage.test.tsx: lastChattedMember outranks memory and background recency; page opens the last-chatted crewmate and the roster lists only chatted rows, newest first; search reaches a hidden one.
  • test/test_crew_recency.py: creating a crewmate lists it and puts it first; a crew a background writer added stays hidden; a cron-attested create records nothing.
  • membersQuery.test.ts: noteUserChat stamps the row bound to the slot and marks the roster stale; a normal-chat slot only marks it stale.
  • test/test_crew_recency.py also pins that no writer replaces an unreadable file, and that a seed hitting a busy transcript is retried, not marked done.

Manual verification

Isolated ./dev-backend.sh home (throwaway KIROCREW_HOME) with 12 crews: 8 package rows, radar (dashboard-made, never chatted), default, plus scribe (chatted most recently) and oncall in crew_recency.json. Fresh browser context on /members each time:

Frontend Opens Switcher
main (before) app-bot all 12 crews
this PR alone scribe 12 rows, scribe and oncall first
this PR on #17835 scribe 2: scribe, oncall
this PR, after a gateway restart, new browser (no localStorage) scribe same as above

That throwaway home set agent.sandbox_allow_unsandboxed_exec so the page would render on a host with no sandbox. No agent turn ran in it.

Screenshots / video

Before (main): the switcher lists every crew and the page opened app-bot.

before switcher

After, on top of #17835: only the crewmates the user chatted with, newest first; the page opened scribe.

after on 17835

This PR alone, full pages, after-restart

This PR alone, before #17835: last-chatted first, but every crew still listed.

after alone

before page

after page

after restart

Related Issues

Designed to land with or after #17835 (one roster reading for the chip and the column), and either order rebases cleanly. This branch is based on main alone and does not contain #17835's commits. Cherry-picking it onto #17835's head 300e746ce5 applies with no conflict, and src/pages/members/ plus membersQuery.test.ts pass there (497 tests).

N/A — requested directly by the user (Crew page polish, item A).

Pattern harvest

Not generalizable: the defect was a missing source (nothing recorded a person's send), not a reusable code shape.

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

@iamwhatever
iamwhatever requested a review from a team as a code owner October 7, 2026 18:09
@iamwhatever
iamwhatever requested a review from buluoray October 7, 2026 18:09
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — 🟡 CONCERNS

Premise-level review of 9e5767d8216d52c3971864a064a8755304fa0a31 — 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: CONCERNS

crew_recency.json re-records a signal main already keeps: rows a person typed carry HUMAN_TURN_META_KEY, and each session stores a last_user_at stamp.

Not justified as shipped

  • Item 4 — duplicate of history.HUMAN_TURN_META_KEY + last_user_at (dashboard/slot_persistence/metadata_line.py:554, read by messaging/sessions_view.py:290): the description says "nothing on main records 'a person typed this'", but chat_handlers.py:1446 already sets _user_row_meta[HUMAN_TURN_META_KEY] = True on every send that has no app token. The RFC rejected deriving the signal from transcripts and never looked at this marker.
    Subtraction: delete crew_recency.py and its two write sites, and derive last_chat_ts from each crew's sessions' last_user_at. Close the cron gap where the marker is set (not request_app and not cron_creator).
    Clears when: the PR names something last_user_at cannot answer, or the store is replaced by it.
  • Item 5 — duplicate of HUMAN_TURN_META_KEY: the seed decides what the user typed with content.lstrip().startswith("["). That is the exclusion rule history.py:998 rules out ("must require this marker rather than exclude the machine callers it happens to know about").
    Subtraction: replace the [ check with meta.get(HUMAN_TURN_META_KEY) is True, or drop the seed along with item 4.
    Clears when: the seed reads the marker.
  • Item 6 — not covered by the base RFC: rfc-crewmates-chatted-list.md (accepted) never mentions creation. The cited docs(rfc): creating a crewmate counts as chatting with it #17844 is not on the base.
    Clears when: an RFC covering "creating a crewmate lists it" is merged non-draft on the base, followed by a push or rebase, or a maintainer posts /ai-review override first-principles 9e5767d8216d52c3971864a064a8755304fa0a31: <decision>.

What this change ships

Inventory (9 items) — 6 justified

Intent: let the user find the crewmates they actually talk to, and reopen the last one after a restart. This is a FIX.

  1. The roster and switcher list only crewmates the user messaged or starred — justified
  2. "Recent" order follows the user's last message — justified
  3. With no ?member=, the page opens the last-chatted crewmate, even in a new browser — justified
  4. New persisted crew_recency.json store, written at most every 30 s per crew — duplicate of last_user_at
  5. One-time seed from typed rows in DM threads — duplicate of HUMAN_TURN_META_KEY
  6. Creating a crewmate lists it at once, first — not in base RFC
  7. A just-messaged crewmate stays listed after switching away (noteUserChat) — justified
  8. A chat with no crew picked counts for the default crew — justified
  9. Rows from an older gateway keep the old listing rule — justified

[FIRST-PRINCIPLES-REVIEWED] 9e5767d

Description read

[DESCRIPTION-READ] 7086b4c3400fc0d324802e9af80af3a55ae031470bf6d6086da63b2136400d9d

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

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Check a host upgraded from main whose user only chatted in normal chat. The seed reads DM threads only, so their switcher may start empty, default crew included.

[DESIGN-REVIEWED] 9e5767d

Description read

[DESCRIPTION-READ] 127b6bf49f0bcd8fa841cad5a84771408a7a62e5612f8ad07c96a8b40ea79b36

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

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — 🟡 CONCERNS

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

UX-Verdict: CONCERNS

The shortened switcher hides 10 of 12 crewmates without saying why, so a first-time reader couldn't tell what "2" counts or what "Show the full roster" adds.

Watch

  • The short list gives no reason for what it leaves out. listedByDefault now lists a crew only if the user sent it a message (last_chat_ts > 0) or starred it, so shot-02 shows just "scribe" and "oncall". The blind reader said: "If the short list is only part of the roster, nothing says which part or why." They also couldn't explain why the count was 2 here and 12 elsewhere. A crew the user just installed, or one that only runs crons, now seems to be missing. That hits every user with unchatted crews, every time they open the switcher, and makes it harder to find those crews.
  • A crewmate the user just opened can be replaced after a refresh. The new order is lastChattedMember(orderedMembers) ?? rememberedRow. If a user opens "oncall" without sending anything and then reloads, the page opens "scribe" instead. This happens whenever someone browses a crewmate without messaging it. Each time, it feels like the page ignored their choice.

Suggestions

  • In the switcher, add a section caption such as "Chatted with" above the list. Rename "Show the full roster" to "All crewmates (12)" so the user can see both what the list contains and what the second option adds.

[UX-REVIEWED] 9e5767d

Description read

[DESCRIPTION-READ] 8c4c35fe938e7e675cafb03100f14abc0352380a9bc65ea5175f86bd58fd81c9

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

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

FINDING -- src/kiro_crew/dashboard/handlers/members.py:922 -- The documented human-only seed uses startswith("["), so the first roster read counts persisted 💓 Heartbeat prompts as human chat but discards human-marked [1, 2, 3] messages (recurring-defect-patterns) -> Fix: select typed rows using existing meta.human provenance instead of their text prefix.
[GPT-REVIEWED] 9e5767d

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

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 9e5767d

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 9e5767d8216d52c3971864a064a8755304fa0a31: <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 7, 2026
@iamwhatever
iamwhatever force-pushed the feat/crew-mate-list-recency branch from b63043c to 629963f Compare October 7, 2026 19:01
@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 7, 2026
@iamwhatever
iamwhatever force-pushed the feat/crew-mate-list-recency branch from 629963f to 006a311 Compare October 7, 2026 19:58
bolichen97 pushed a commit that referenced this pull request Oct 7, 2026
#17816)

Records the product owner's 2026-10-07 decision amending
rfc-crewmates-launch.md screen 02: the Crewmates list and switcher show
only crewmates the user sent a message, ordered by that, and the landing
opens the last one. Implementation: #17808.

Co-authored-by: Joe Guo <zejiangg@amazon.com>
@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 7, 2026
@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 7, 2026
…ast one

The folded crewmate switcher was handed every roster row (orderedMembers),
and the roster's own listing rule counted any DM message, a dashboard create
or the default crew. Record when the PERSON sends a crew a message
(POST /api/chat, no app token / cron / relay) in crew_recency.json, ship it
as last_chat_ts, list and order by it, and reopen the last-chatted crewmate.
A one-time seed reads typed rows from existing DM threads.
@iamwhatever
iamwhatever force-pushed the feat/crew-mate-list-recency branch from 006a311 to 9e5767d Compare October 7, 2026 21:04
@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: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 7, 2026
@iamwhatever

iamwhatever commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor Author
  • span=369bda1ee8d9 Item 4: duplicate of last_user_at / HUMAN_TURN_META_KEY

Outcome: kept, rebutted.
last_user_at is a per-session metadata line. Answering "when did the user last talk to crew X" from it means reading every session's metadata and grouping by agent on every roster read. The Crewmates roster is read on every page visit.
It also cannot answer the second ask the product owner gave: a crewmate the user just CREATED counts. No session exists then (POST /api/agents), so no last_user_at can record it.
crew_recency is one small file keyed by crew. Its writer is the same send path that sets the human marker (api_chat, dashboard user, no app token, no cron attestation), so the two signals cannot drift apart. The seed now reads the marker (see the item 5 answer).

iamwhatever pushed a commit that referenced this pull request Oct 8, 2026
…refix

The one-time crew_recency seed decided a DM row was typed by the user
from content not opening with '[', which counted heartbeat prompts and
skipped human messages like '[1, 2, 3]'. Require meta[HUMAN_TURN_META_KEY],
the allowlist the human send paths set. Follow-up to #17808.
iamwhatever pushed a commit that referenced this pull request Oct 8, 2026
…refix

The one-time crew_recency seed decided a DM row was typed by the user
from content not opening with '[', which counted heartbeat prompts and
skipped human messages like '[1, 2, 3]'. Require meta[HUMAN_TURN_META_KEY],
the allowlist the human send paths set. Follow-up to #17808.
CrysisDeu added a commit that referenced this pull request Oct 8, 2026
Open the built-in `default` row on the Crewmates page, leave, come
back: the page reopened a different crewmate. `activate()` never wrote
`default` to the last-member memory, the restore effect never read it,
and `resolveDefaultMember` skipped it twice, so once `default` was the
row the user actually worked in, the page could never land on it.

`default` is now remembered like any other row, with the open's time
beside it (`mc-members-last-member-ts`). It is never ranked by
`last_chat_ts` (#17808): the default crew's stamp also moves for every
plain chat that picked no crew, so it would win nearly always and bury
the crewmate the user talked to. Instead a remembered `default` opens
when its open is newer than the last chat with any crewmate
(`rememberedDefaultPick`); older, the last-chatted crewmate still
wins. A roster holding only `default` still shows the hero, and the
most-recently-used fallback still never picks `default`.

Supersedes #16311, whose roster-click-only gate (`rowPickRef`) predates
the server-side last-chatted rule.

Closes #17210

Co-authored-by: Helena Stafford <helenars@amazon.com>
chenmingwei23 pushed a commit that referenced this pull request Oct 8, 2026
…refix (#17953)

The one-time crew_recency seed decided a DM row was typed by the user
from content not opening with '[', which counted heartbeat prompts and
skipped human messages like '[1, 2, 3]'. Require meta[HUMAN_TURN_META_KEY],
the allowlist the human send paths set. Follow-up to #17808.

Co-authored-by: Joe Guo <zejiangg@amazon.com>
iamwhatever pushed a commit that referenced this pull request Oct 8, 2026
Amends rfc-crewmates-chatted-list.md (#17816): the user's own create
(POST /api/agents, owner-only, not cron-attested) stamps the new crew so
it is listed at once and sorts first; crews added by the agent sync, an
app or background work are not stamped. Names #17835, whose shared hide
rule the switcher runs. Implementation: #17808.
iamwhatever added a commit that referenced this pull request Oct 8, 2026
Amends rfc-crewmates-chatted-list.md (#17816): the user's own create
(POST /api/agents, owner-only, not cron-attested) stamps the new crew so
it is listed at once and sorts first; crews added by the agent sync, an
app or background work are not stamped. Names #17835, whose shared hide
rule the switcher runs. Implementation: #17808.

Co-authored-by: Joe Guo <zejiangg@amazon.com>
CrysisDeu added a commit that referenced this pull request Oct 8, 2026
Open the built-in `default` row on the Crewmates page, leave, come
back: the page reopened a different crewmate. `activate()` never wrote
`default` to the last-member memory, the restore effect never read it,
and `resolveDefaultMember` skipped it twice, so once `default` was the
row the user actually worked in, the page could never land on it.

`default` is now remembered like any other row, with the roster's chat
mark beside it (`mc-members-last-member-chat-mark`: the greatest
crewmate `last_chat_ts` at that open). It is never ranked by its own
`last_chat_ts` (#17808): the default crew's stamp also moves for every
plain chat that picked no crew, so it would win nearly always and bury
the crewmate the user talked to. Instead a remembered `default` opens
while no crewmate's `last_chat_ts` has moved past the mark
(`rememberedDefaultPick`); once one has, that crewmate wins. Both
sides are the server's clock, so a remote dashboard compares the same.
The mark is the user's own open; a restore re-reads it but never
re-writes it. A roster holding only `default` still shows the hero,
and the most-recently-used fallback still never picks `default`.

Supersedes #16311, whose roster-click-only gate (`rowPickRef`) predates
the server-side last-chatted rule.

Closes #17210

Co-authored-by: Helena Stafford <helenars@amazon.com>
CrysisDeu added a commit that referenced this pull request Oct 8, 2026
Open the built-in `default` row on the Crewmates page, leave, come
back: the page reopened a different crewmate. `activate()` never wrote
`default` to the last-member memory, the restore effect never read it,
and `resolveDefaultMember` skipped it twice, so once `default` was the
row the user actually worked in, the page could never land on it.

`default` is now remembered like any other row, with the roster's chat
mark beside it (`mc-members-last-member-chat-mark`: the greatest
crewmate `last_chat_ts` at that open). It is never ranked by its own
`last_chat_ts` (#17808): the default crew's stamp also moves for every
plain chat that picked no crew, so it would win nearly always and bury
the crewmate the user talked to. Instead a remembered `default` opens
while no crewmate's `last_chat_ts` has moved past the mark
(`rememberedDefaultPick`); once one has, that crewmate wins. Both
sides are the server's clock, so a remote dashboard compares the same.
The mark is the user's own open; a restore re-reads it but never
re-writes it. A roster holding only `default` still shows the hero,
and the most-recently-used fallback still never picks `default`.

Supersedes #16311, whose roster-click-only gate (`rowPickRef`) predates
the server-side last-chatted rule.

Closes #17210

Co-authored-by: Helena Stafford <helenars@amazon.com>
CrysisDeu added a commit that referenced this pull request Oct 9, 2026
…17972)

Open the built-in `default` row on the Crewmates page, leave, come
back: the page reopened a different crewmate. `activate()` never wrote
`default` to the last-member memory, the restore effect never read it,
and `resolveDefaultMember` skipped it twice, so once `default` was the
row the user actually worked in, the page could never land on it.

`default` is now remembered like any other row, with the roster's chat
mark beside it (`mc-members-last-member-chat-mark`: the greatest
crewmate `last_chat_ts` at that open). It is never ranked by its own
`last_chat_ts` (#17808): the default crew's stamp also moves for every
plain chat that picked no crew, so it would win nearly always and bury
the crewmate the user talked to. Instead a remembered `default` opens
while no crewmate's `last_chat_ts` has moved past the mark
(`rememberedDefaultPick`); once one has, that crewmate wins. Both
sides are the server's clock, so a remote dashboard compares the same.
The mark is the user's own open; a restore re-reads it but never
re-writes it. A roster holding only `default` still shows the hero,
and the most-recently-used fallback still never picks `default`.

Supersedes #16311, whose roster-click-only gate (`rowPickRef`) predates
the server-side last-chatted rule.

Closes #17210

Co-authored-by: Helena Stafford <helenars@amazon.com>
CrysisDeu added a commit that referenced this pull request Oct 9, 2026
…ult crewmate

A session is started from a template, a folder and a memory store; a
crewmate is a durable identity with its own three, talked to in its DM
thread. Four seams read "no crewmate picked" as "the default crewmate":
the agent-less create stamped the `default` alias, the resolver answered
an empty or template name with the `default` row's workspace and model
pin, and the recency record credited every plain chat to the `default`
crewmate -- which is why #17972 needed a client-side chat mark to keep
`default` from winning the Crewmates page.

A template session is now first-class in `resolve_agent_bindings`: an
alias hit is the crewmate; anything else binds the named materialized
template, else `default_template(config)` (`agent.default_agent`, then
`kirocrew`), to `default_workspace` and Global Memory V1 with no crewmate
pin, `resolved_alias` empty and `selection_kind="template"`. The default
template always resolves; the "first available alias" fallback is gone.
An agent-less create and an empty `/agent` switch stamp the default
template in the template namespace, and a template session with no name
of its own records its template as the selection. `agent or
config.default_agent` fallbacks in session selection, private-store
pinning and model fallback read the name alone.

What counts as a chat WITH a crewmate is one rule,
`crew_recency.crewmate_for_user_chat`: its DM thread, or a plain session
that explicitly picked it (#17808) -- except the `default` alias outside
its DM, which pre-change agent-less creates stamped on every plain slot.
`""` is refused and the roster no longer folds it into the `default`
row. The Members page drops the #17972 chat mark: `default` is
remembered and last-chatted like any row, the most-recently-used
fallback still skips it (listed by name, not by use), and a default-only
roster still lands on the hero. The doctor's Model section reads the
default template, not the `default` crewmate's binding.

A config whose `default` crewmate binds another template than
`agent.default_agent` changes: new plain sessions run
`agent.default_agent`; existing sessions keep their recorded execution.
Specs updated in `crew-mode.md` and `config.md`.

Closes #18328
CrysisDeu added a commit that referenced this pull request Oct 9, 2026
…ult crewmate

A session is started from a template, a folder and a memory store; a
crewmate is a durable identity with its own three, talked to in its DM
thread. Four seams read "no crewmate picked" as "the default crewmate":
the agent-less create stamped the `default` alias, the resolver answered
an empty or template name with the `default` row's workspace and model
pin, and the recency record credited every plain chat to the `default`
crewmate -- which is why #17972 needed a client-side chat mark to keep
`default` from winning the Crewmates page.

A template session is now first-class in `resolve_agent_bindings`: an
alias hit is the crewmate; anything else binds the named materialized
template, else `default_template(config)` (`agent.default_agent`, then
`kirocrew`), to `default_workspace` and Global Memory V1 with no crewmate
pin, `resolved_alias` empty and `selection_kind="template"`. The default
template always resolves; the "first available alias" fallback is gone.
An agent-less create and an empty `/agent` switch stamp the default
template in the template namespace, and a template session with no name
of its own records its template as the selection. `agent or
config.default_agent` fallbacks in session selection, private-store
pinning and model fallback read the name alone.

What counts as a chat WITH a crewmate is one rule,
`crew_recency.crewmate_for_user_chat`: its DM thread, or a plain session
that explicitly picked it (#17808) -- except the `default` alias outside
its DM, which pre-change agent-less creates stamped on every plain slot.
`""` is refused and the roster no longer folds it into the `default`
row. The Members page drops the #17972 chat mark: `default` is
remembered and last-chatted like any row, the most-recently-used
fallback still skips it (listed by name, not by use), and a default-only
roster still lands on the hero. The doctor's Model section reads the
default template, not the `default` crewmate's binding.

A config whose `default` crewmate binds another template than
`agent.default_agent` changes: new plain sessions run
`agent.default_agent`; existing sessions keep their recorded execution.
Specs updated in `crew-mode.md` and `config.md`.

Closes #18328
CrysisDeu added a commit that referenced this pull request Oct 9, 2026
…ult crewmate

A session is started from a template, a folder and a memory store; a
crewmate is a durable identity with its own three, talked to in its DM
thread. Four seams read "no crewmate picked" as "the default crewmate":
the agent-less create stamped the `default` alias, the resolver answered
an empty or template name with the `default` row's workspace and model
pin, and the recency record credited every plain chat to the `default`
crewmate -- which is why #17972 needed a client-side chat mark to keep
`default` from winning the Crewmates page.

A template session is now first-class in `resolve_agent_bindings`: an
alias hit is the crewmate; anything else binds the named materialized
template, else `default_template(config)` (`agent.default_agent`, then
`kirocrew`), to `default_workspace` and Global Memory V1 with no crewmate
pin, `resolved_alias` empty and `selection_kind="template"`. The default
template always resolves; the "first available alias" fallback is gone.
An agent-less create and an empty `/agent` switch stamp the default
template in the template namespace, and a template session with no name
of its own records its template as the selection. `agent or
config.default_agent` fallbacks in session selection, private-store
pinning and model fallback read the name alone.

What counts as a chat WITH a crewmate is one rule,
`crew_recency.crewmate_for_user_chat`: its DM thread, or a plain session
that explicitly picked it (#17808) -- except the `default` alias outside
its DM, which pre-change agent-less creates stamped on every plain slot.
`""` is refused and the roster no longer folds it into the `default`
row. The Members page drops the #17972 chat mark: `default` is
remembered and last-chatted like any row, the most-recently-used
fallback still skips it (listed by name, not by use), and a default-only
roster still lands on the hero. The doctor's Model section reads the
default template, not the `default` crewmate's binding.

A config whose `default` crewmate binds another template than
`agent.default_agent` changes: new plain sessions run
`agent.default_agent`; existing sessions keep their recorded execution.
Specs updated in `crew-mode.md` and `config.md`.

Closes #18328
CrysisDeu added a commit that referenced this pull request Oct 9, 2026
…ult crewmate

A session is started from a template, a folder and a memory store; a
crewmate is a durable identity with its own three, talked to in its DM
thread. Four seams read "no crewmate picked" as "the default crewmate":
the agent-less create stamped the `default` alias, the resolver answered
an empty or template name with the `default` row's workspace and model
pin, and the recency record credited every plain chat to the `default`
crewmate -- which is why #17972 needed a client-side chat mark to keep
`default` from winning the Crewmates page.

A template session is now first-class in `resolve_agent_bindings`: an
alias hit is the crewmate; anything else binds the named materialized
template, else `default_template(config)` (`agent.default_agent`, then
`kirocrew`), to `default_workspace` and Global Memory V1 with no crewmate
pin, `resolved_alias` empty and `selection_kind="template"`. The default
template always resolves; the "first available alias" fallback is gone.
An agent-less create and an empty `/agent` switch stamp the default
template in the template namespace, and a template session with no name
of its own records its template as the selection. `agent or
config.default_agent` fallbacks in session selection, private-store
pinning and model fallback read the name alone.

What counts as a chat WITH a crewmate is one rule,
`crew_recency.crewmate_for_user_chat`: its DM thread, or a plain session
that explicitly picked it (#17808) -- except the `default` alias outside
its DM, which pre-change agent-less creates stamped on every plain slot.
`""` is refused and the roster no longer folds it into the `default`
row. The Members page drops the #17972 chat mark: `default` is
remembered and last-chatted like any row, the most-recently-used
fallback still skips it (listed by name, not by use), and a default-only
roster still lands on the hero. The doctor's Model section reads the
default template, not the `default` crewmate's binding.

A config whose `default` crewmate binds another template than
`agent.default_agent` changes: new plain sessions run
`agent.default_agent`; existing sessions keep their recorded execution.
Specs updated in `crew-mode.md` and `config.md`.

Closes #18328
CrysisDeu added a commit that referenced this pull request Oct 12, 2026
Leaving the Crewmates page and coming back landed on the crewmate the
user last CHATTED with, not the one they had open. A row that was only
clicked never moves `last_chat_ts`, so ranking the server's last-chatted
crewmate above the browser memory (the order #17808 chose for the
restart case) reopened a different thread on every ordinary return.

The landing now reads the browser memory first (`rememberedMember`: any
row still on the roster, `default` included, never a default-only
roster), then falls back to the last-chatted crewmate, then to the most
recently used one. localStorage survives a gateway restart, so the
restart case lands on the same row the user had open; a new browser or
a cleared storage still gets the server's record.

The `mc-members-last-member-chat-mark` key, `chatMarkOf`,
`rememberedDefaultPick` and the restore-only `stamp` branch of
`activate` existed only to rank a remembered `default` against the last
chat; with the memory first they have no job and are removed.
`resolveDefaultMember` loses its `remembered` parameter for the same
reason: every production caller passed `null`.

Spec (`crew-mode.md`) and the decision record
(`rfc-crewmates-chatted-list.md`, new §3.1) are amended in the same
change. §3.1 also records the product owner's answer to a generalized
chat-mark tie-break: a crewmate's conversation is its Crewmates thread,
there is no other place to chat with one, so the memory alone is the
rule.

Closes #19341
CrysisDeu added a commit that referenced this pull request Oct 12, 2026
Leaving the Crewmates page and coming back landed on the crewmate the
user last CHATTED with, not the one they had open. A row that was only
clicked never moves `last_chat_ts`, so ranking the server's last-chatted
crewmate above the browser memory (the order #17808 chose for the
restart case) reopened a different thread on every ordinary return.

The landing now reads the browser memory first (`rememberedMember`: any
row still on the roster, `default` included, never a default-only
roster), then falls back to the last-chatted crewmate, then to the most
recently used one. localStorage survives a gateway restart, so the
restart case lands on the same row the user had open; a new browser or
a cleared storage still gets the server's record.

The `mc-members-last-member-chat-mark` key, `chatMarkOf`,
`rememberedDefaultPick` and the restore-only `stamp` branch of
`activate` existed only to rank a remembered `default` against the last
chat; with the memory first they have no job and are removed.
`resolveDefaultMember` loses its `remembered` parameter for the same
reason: every production caller passed `null`.

Spec (`crew-mode.md`) and the decision record
(`rfc-crewmates-chatted-list.md`, new §3.1) are amended in the same
change. §3.1 also records the product owner's answer to a generalized
chat-mark tie-break: a crewmate's conversation is its Crewmates thread,
there is no other place to chat with one, so the memory alone is the
rule.

Closes #19341
CrysisDeu added a commit that referenced this pull request Oct 12, 2026
…ne (#19346)

Leaving the Crewmates page and coming back landed on the crewmate the
user last CHATTED with, not the one they had open. A row that was only
clicked never moves `last_chat_ts`, so ranking the server's last-chatted
crewmate above the browser memory (the order #17808 chose for the
restart case) reopened a different thread on every ordinary return.

The landing now reads the browser memory first (`rememberedMember`: any
row still on the roster, `default` included, never a default-only
roster), then falls back to the last-chatted crewmate, then to the most
recently used one. localStorage survives a gateway restart, so the
restart case lands on the same row the user had open; a new browser or
a cleared storage still gets the server's record.

The `mc-members-last-member-chat-mark` key, `chatMarkOf`,
`rememberedDefaultPick` and the restore-only `stamp` branch of
`activate` existed only to rank a remembered `default` against the last
chat; with the memory first they have no job and are removed.
`resolveDefaultMember` loses its `remembered` parameter for the same
reason: every production caller passed `null`.

Spec (`crew-mode.md`) and the decision record
(`rfc-crewmates-chatted-list.md`, new §3.1) are amended in the same
change. §3.1 also records the product owner's answer to a generalized
chat-mark tie-break: a crewmate's conversation is its Crewmates thread,
there is no other place to chat with one, so the memory alone is the
rule.

Closes #19341
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.

2 participants