Skip to content

Key project drafts by project id so deleting a project clears their state - #365

Merged
Tryanks merged 1 commit into
mainfrom
fix/draft-destination-key
Sep 7, 2026
Merged

Key project drafts by project id so deleting a project clears their state#365
Tryanks merged 1 commit into
mainfrom
fix/draft-destination-key

Conversation

@Tryanks

@Tryanks Tryanks commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Follow-up to #364. Pre-existing bug: ConversationDestination::ProjectDraft was built with the draft's session id by the runtime (conversation_destination) and the UI store (destination), while project deletion, the composer and the persisted draft:<id> preference key all use the project id. Deleting a project therefore never cleared the draft's terminal workspace, terminal preferences or conversation_ui entry, and draft terminal preferences were persisted under an unreachable key.

Change

  • Both producer sites now key drafts by project id. The draft-to-thread handoff in sync_active_conversation_ui matches on the committed thread's project instead of comparing ids.
  • The store's IndexSnapshot arm drops conversation_ui entries whose project or session is no longer listed. The runtime never emits IndexRemoveProject; index replication is snapshot-based, so this is the path Command::DeleteProject actually takes. Archived threads stay listed, so archiving keeps its state.
  • reconcile_destination treats a selected draft whose project left the index like a vanished thread and falls back to another project's draft.

Tests

  • Runtime: deleting_a_project_clears_its_drafts_terminal_state (terminal workspace and draft:<project> preferences gone after delete_project).
  • Store, through Command::DeleteProject on the real host: background draft state cleared without moving the user; viewing the deleted project's draft lands on another project's draft with no stranded state; committing a draft still carries its UI state to the thread.
  • Each of the three steps was reverted in turn and its test fails without it.

Behaviour note

Two live drafts for one project (only reachable through multiple mux clients at different roots) now share per-project draft terminal preferences and one parked terminal-workspace slot, consistent with the documented "an unsent draft follows its project" keying and the composer's existing behaviour.

Checks

cargo fmt --all --check, cargo clippy --workspace --all-targets --locked -- -D warnings, cargo test --workspace --locked pass locally on macOS. Mobile/Web and cargo machete left to CI.

@Tryanks
Tryanks merged commit 9348a25 into main Sep 7, 2026
6 checks passed
@Tryanks
Tryanks deleted the fix/draft-destination-key branch September 7, 2026 20:02
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.

1 participant