Skip to content

feat(desktop): defer new task session creation until first message (#746) - #767

Open
mazongYY wants to merge 2 commits into
vastsa:mainfrom
mazongYY:feat/defer-new-task-session
Open

mazongYY wants to merge 2 commits into
vastsa:mainfrom
mazongYY:feat/defer-new-task-session

Conversation

@mazongYY

Copy link
Copy Markdown
Contributor

Closes #746
Supersedes #750

What changed

Reinstates the deferred session creation mechanism originally defined in ADR 0084:

  • New Task (store.newSession): Resets the renderer to an unpersisted draft state (activeSessionId: undefined, empty messages, scope retained) instead of eagerly persisting an empty session slot to SQLite and the sidebar.
  • Sidebar history filter: Filters out sessions whose title is still the default untitled value (including legacy empty drafts), keeping history clean of uncommitted tasks.
  • Materialization on demand: The existing materializeDraftSession workflow remains active and automatically creates/persists the session as soon as the user sends their first prompt or attaches files.
  • Auto-discard on click outside / navigate away: When a user clicks "New Task" and then clicks another session, switches projects, or leaves without sending a message, no empty session row is left behind.

Why

Under ADR 0113, clicking "New Task" eagerly wrote an empty session row (新建任务 / "New task") into the database and sidebar. When users accidentally clicked "New Task" or decided not to proceed, abandoned empty rows accumulated in the history and on disk until manually deleted.

Reinstating deferred creation ensures only tasks that actually receive user input are recorded in history and persisted to SQLite.

Affected surfaces

  • apps/desktop/src/stores/slices/session-slice.tsnewSession resets renderer state to unpersisted draft.
  • apps/desktop/src/components/Sidebar.tsx — restores title filtering for empty default drafts.
  • Unit tests in app-store-sidebar.test.mjs, composer-send-state.test.mjs, and session-create.test.mjs updated to verify unpersisted draft behavior.
  • Architecture docs docs/adr/0084 and docs/adr/0113 updated.

Validation

node --test test/app-store-sidebar.test.mjs test/composer-send-state.test.mjs test/session-create.test.mjs test/composer-paste-files.test.mjs test/thinking-ui.test.mjs
pass (56/56 tests passing)

…astsa#746)

Clicking New Task now resets the composer to an unpersisted draft instead of eagerly writing an empty session row to SQLite and the sidebar. The session is materialized upon the first prompt or attachment. Abandoning the draft leaves no empty session row in history.

This branch has not been deployed

No deployments
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.

[Feature] Defer new-task session creation until the first message to avoid abandoned empty sessions

1 participant