Skip to content

fix(dashboard): persist session close metadata on empty message windows (#4501) - #4623

Open
md-abusayeed wants to merge 1 commit into
kirodotdev:mainfrom
md-abusayeed:fix/empty-slot-close-persist-4501
Open

fix(dashboard): persist session close metadata on empty message windows (#4501)#4623
md-abusayeed wants to merge 1 commit into
kirodotdev:mainfrom
md-abusayeed:fix/empty-slot-close-persist-4501

Conversation

@md-abusayeed

@md-abusayeed md-abusayeed commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Problem / Motivation

Closing a dashboard chat session that contains no messages (e.g. newly created at birth or created programmatically) fails to persist the \closed: true\ and \closed_at\ metadata flags to disk. Consequently, when the gateway restarts, rehydration restores the empty session back into the sidebar despite the user having closed it.

Why it matters

In _save_slot_to_history\ (\src/kiro_crew/dashboard/chat_persistence.py), the function began with an unqualified \if not window: return\ guard. This guard sat directly above the no-op check whose documentation explicitly states that \closed, \ orce, and
ewrite\ must always proceed to disk.

Because \if not window: return\ was evaluated first without checking \closed, closing an empty slot resulted in an early return without writing the updated metadata line containing \closed\ and \closed_at. The caller (\�pi_chat_slot_delete\ via \save_slot_off_loop(..., closed=True, closed_at=closed_at)) treated the operation as successful, but on-disk metadata remained unclosed.

What changed

  • Updated the empty-window early-return guard in _save_slot_to_history\ to \if not window and not closed: return.
  • Added defensive \getattr(state, 'conversation_log', None)\ and safe int checks for resumed count.
  • Plain background saves on empty slots remain cheap no-ops as intended.
  • Explicit session close (\closed=True) on empty message windows now proceeds into the metadata lock and writes the updated metadata line to disk atomically.

Tests

  • Added \ est/test_chat_persistence_empty_slot.py:
    • \ est_closing_empty_slot_persists_closed_metadata: Asserts that closing an empty slot persists \closed: true\ and \closed_at\ to the session JSONL file on disk.
    • \ est_plain_save_on_empty_slot_is_noop: Asserts that plain periodic saves on empty slots remain no-ops and write no files.
  • Ran pytest suite: 2/2 tests pass (\pytest test/test_chat_persistence_empty_slot.py).

Manual verification

N/A — unit coverage sufficient: direct unit tests assert on-disk metadata existence and contents via \ConversationLog.get_metadata.

Screenshots / video

Why no screenshot: backend persistence and session lifecycle fix — no visual UI change.

Related Issues

Closes #4501

Checklist

  • Single commit with a Conventional Commits title (\ eat|fix|docs|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) — N/A, behavior documented in code comments
  • No secrets, credentials, or internal references in the diff

@md-abusayeed
md-abusayeed requested a review from a team as a code owner August 20, 2026 04:54
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Aug 20, 2026
@md-abusayeed
md-abusayeed force-pushed the fix/empty-slot-close-persist-4501 branch from 173b8a3 to bb13523 Compare August 20, 2026 05:50
@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 Aug 20, 2026
@md-abusayeed
md-abusayeed force-pushed the fix/empty-slot-close-persist-4501 branch from bb13523 to 3dbb3f8 Compare August 20, 2026 06:58
@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 Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Closing a session with no messages does not persist the close, so a restart restores it

1 participant