Skip to content

fix(dashboard): keep an idle chat's project change across a restart - #36784

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/projclaim-20261113
Nov 14, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/projclaim-20261113

Conversation

@rnoack1

@rnoack1 rnoack1 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A project cleared or changed on an idle chat stays that way after a restart.

Clear an idle chat's project (or move it to another directory), send nothing more, and restart. The chat comes back scoped to the old directory, and its next session spawns there. This happens through both the project endpoint and the agent's set_project directive.

Why it matters

Nothing errors. The user sees the clear succeed, and after a restart the agent runs in the directory they removed, reading and writing files there.

Not a goal

What changed (motivation → approach → change)

Symptom After a restart, an idle chat whose project was cleared or moved restores the old directory.
Cause The periodic flush writes a slot's metadata line only while _dirty is set. A project change on an idle chat appends no transcript row, and neither project writer marked the slot, so the line kept the old project.
Change api_chat_slot_project and the set_project directive (_set_project) set slot._dirty when the project actually changes, as the workspace and agent switches already do.

A same-value set still changes nothing and marks nothing.

Backwards compatibility

Compatible: the only effect is that a slot whose project changed is written by the next flush.

Removes nothing: the change only adds a save.

Tests

Proof: PROVEN test/test_cleared_project_survives_restart.py::test_an_idle_chats_cleared_project_stays_cleared_after_a_restart[http], test/test_cleared_project_survives_restart.py::test_an_idle_chats_cleared_project_stays_cleared_after_a_restart[directive], test/test_cleared_project_survives_restart.py::test_an_idle_chats_new_project_survives_a_restart[http], test/test_cleared_project_survives_restart.py::test_an_idle_chats_new_project_survives_a_restart[directive] (head 31b06a8)

test/test_cleared_project_survives_restart.py (new) restores a real open tab with a stored project, changes the project over HTTP or by directive, runs the periodic flush, then restores again from disk:

  • a clear comes back as no project;
  • a move comes back as the new directory.

All 4 fail on main and pass with the fix. They pass 10 times in a row and in reversed order. The #11722 suites (test_cleared_project_drops_stored_cwd.py, test_cleared_project_not_resurrected.py) still pass.

Manual verification

N/A — the tests drive the real restore, flush and both writers; only the session map is faked.

Related Issues

Closes #36772

Sibling sweep

Swept: git grep -nE "slot.project = " -- src/
Sibling: src/kiro_crew/dashboard/chat_api/session_relaunch.py:552 -- not affected -- the workspace switch already sets _dirty
Sibling: src/kiro_crew/dashboard/chat_api/agent_switch.py:965 -- not affected -- the agent switch already sets _dirty
Sibling: src/kiro_crew/dashboard/crewmate_worktree_scope.py:92 -- not affected -- sets _dirty beside the write
Sibling: src/kiro_crew/dashboard/handlers/members_thread.py -- not affected -- line 104 sets _dirty beside the write; line 347 stamps a newborn slot, persisted at birth
Sibling: src/kiro_crew/apps/builtins/spec_builder/backend/runtime.py:201 -- not affected -- re-derived from the spec on every worker start, never a user choice

Pattern harvest

Rule candidate: review-prompt
Pattern: a handler that mutates a persisted slot field without setting _dirty is lost on restart when no transcript row follows.

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

@rnoack1
rnoack1 requested review from a team and KiroCrewCaptain as code owners November 13, 2026 17:48
@rnoack1
rnoack1 requested a review from mbriones98 November 13, 2026 17:48
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 13, 2026
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 676201595b22064f9d35023aed97ae8b40bdb261 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 13, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

This fixes the root cause by marking the slot dirty where the project actually changes, the same way the sibling writers already do. It takes nothing away and adds no new surface.

[DESIGN-REVIEWED] 6762015

Description read

[DESCRIPTION-READ] 236c7350e5aa4c0d6d3bfeb263f08886d2235148fad008fc3445d9fb022232d3

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 676201595b22064f9d35023aed97ae8b40bdb261 — 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

Both project writers that skipped the dirty flag now set it, using the convention every other slot-field writer already follows. Nothing new is added.

What this change ships

Inventory (3 items) — 3 justified

Intent: when a user clears or changes an idle chat's project, it stays that way after a restart. FIX.

  1. Clearing or changing a project from the dashboard on an idle chat now survives a restart — justified
  2. Clearing or changing a project with the agent's set_project directive on an idle chat now survives a restart — justified
  3. A new regression test covers the HTTP and directive paths for both a clear and a move — justified

[FIRST-PRINCIPLES-REVIEWED] 6762015

Description read

[DESCRIPTION-READ] 5fce5b332b9406d63ad39af255e6bd5f465615194ad13f55d4322d89241f6d11

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 6762015

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

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

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 6762015

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

@KiroCrewCaptain

KiroCrewCaptain commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: the decider estimates a 7% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes.

I recommend approving. The bug is real and the fix is narrow: the dashboard saves a chat's settings to disk only when the chat (internally a "slot") is marked _dirty. Neither way of changing a project set that mark (the project endpoint api_chat_slot_project, nor the agent's set_project directive), so on an idle chat a cleared or changed project was lost on restart. The PR adds the mark in both places.

Checked in the code:

  • Endpoint: the mark is set at session_relaunch.py:891, inside if project != old_project. That is after both rollback exits (slot replaced while the recent-project save was running, and the session-rebound 409), so a request that gets rolled back never marks the slot.
  • Directive, clear: the mark is set only when there was a project to clear.
  • Directive, set: the mark is set only when rp != old_project. Setting the same value still marks nothing, as the PR description says.
  • Save path: the periodic save (dashboard_persistence.py:153) runs only when the slot is dirty, and keeps the mark if a newer change lands during the save (it compares _dirty_gen). The metadata codec writes project both ways. The full line omits an empty

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit 676201595b · 101 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@rnoack1

rnoack1 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Coverage Gate is red on main, not from this diff: src/kiro_crew/agent_ipc_client.py is at 75.7% against the 80% per-file floor, and this PR does not touch that file. #36804 adds the missing coverage. This PR will be rebased once that merges.

@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 13, 2026
@rnoack1
rnoack1 force-pushed the fix/projclaim-20261113 branch from 31b06a8 to a4fec8b Compare November 14, 2026 17:52
@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 Nov 14, 2026
@rnoack1
rnoack1 force-pushed the fix/projclaim-20261113 branch from a4fec8b to 6762015 Compare November 14, 2026 19:22
@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 Nov 14, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 14, 2026 20:59

@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.

Thanks for the fix. We checked this head: the new test passes 4 of 4 here and fails 4 of 4 with the two source files reverted to the merge base. Removing any one of the three added _dirty marks turns at least one case red. In the HTTP handler, the mark comes after every rollback exit and the 409, so a rejected change is never saved. A same-value set still marks nothing. The flush consumer keeps a mark that is set during a flush.
Well done: the test drives the real path (restore from disk, change over HTTP or by directive, periodic flush, restore again) for both clear and move, and it asserts what the user sees after a restart.
Optional:

  • In _set_project, re-read old_project just before slot.project = rp, as the clear branch already does after its await. A concurrent project change during the awaits could otherwise skip the mark. That stale read was already on main.
  • Add a case that sets the project the slot already holds and asserts slot._dirty stays False. Right now the "a same-value set marks nothing" claim has no test.
  • The body's sibling sweep lists fewer writers than its own grep finds (for example slot_create.py, worker_slots.py, chat_fork.py and transcript_binding.py). None of them needs a code change. A one-line reason for each would make the list complete.

@KiroCrewCaptain
KiroCrewCaptain merged commit 1830b3a into main Nov 14, 2026
99 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/projclaim-20261113 branch November 14, 2026 21:00
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 14, 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.

A project clear or move on an idle chat is lost on restart

2 participants