Skip to content

fix(desktop): discard draft on explicit new session - #62579

Open
sitkarev wants to merge 1 commit into
NousResearch:mainfrom
sitkarev:fix/desktop-new-session-draft-reset
Open

fix(desktop): discard draft on explicit new session#62579
sitkarev wants to merge 1 commit into
NousResearch:mainfrom
sitkarev:fix/desktop-new-session-draft-reset

Conversation

@sitkarev

Copy link
Copy Markdown
Contributor

Summary

  • Clear the shared __new__ composer draft only for explicit Desktop New Session actions, preventing a prior unsent prompt from appearing or being submitted in a nominally fresh chat.
  • Preserve drafts during automatic route recovery/resume and ordinary thread changes.
  • Include compression.in_place in the gateway agent-cache signature so changing durable-ID compaction mode reconstructs cached agents.

Details

The composer owns both its live contenteditable state and the persisted scratch scope. New Session now dispatches a deferred, scoped clear after session/route state changes, and the listener only clears while the composer is in the null/new-chat scope. Explicit entry points covered: sidebar New Session, global keybind, /new, profile-driven new sessions, and workspace/project lanes.

Validation

  • npm run test:ui -- src/app/session/hooks/use-session-actions.test.tsx src/store/composer.test.ts — 24 passed
  • npm run typecheck
  • uv run pytest tests/gateway/test_agent_cache.py -q -o 'addopts=' — 79 passed
  • python3 -m py_compile gateway/run.py
  • git diff --check

Risk / rollback

The clear is opt-in per explicit New Session path; automatic recovery preserves unsent drafts. Reverting commit f0b728ce3 restores the prior behavior.

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/desktop Electron desktop app (apps/desktop/*) comp/gateway Gateway runner, session dispatch, delivery sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Jul 11, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for covering the explicit New Session entry points and the cached-agent config gap.

Problems

  • The clear handler gates on activeQueueSessionKeyRef.current === null (PR apps/desktop/src/app/chat/composer/hooks/use-composer-draft.ts), but current main updates that ref during render while draftScopeRef is only updated by the scope-swap effect (use-composer-draft.ts:83-91, 306-329). A deferred clear can therefore empty the old editor before swap cleanup, which then stashes the empty value over the outgoing session draft.

Suggested changes

  • Tie the clear intent to completion of the null-scope swap, and add a real composer integration test proving the outgoing scoped draft survives while the new-chat draft and attachments are discarded.
  • The gateway portion is well targeted: agent/agent_init.py:1572-1574,1837-1839 fixes compression_in_place at construction and gateway/run.py:15672-15683 does not presently include it in cache invalidation.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 11, 2026
@teknium1 teknium1 added the area/sessions Session lifecycle, resume, persistence, history label Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sessions Session lifecycle, resume, persistence, history comp/desktop Electron desktop app (apps/desktop/*) comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants