Skip to content

fix(app): no duplicate sessions when Enter is pressed again while a new chat starts (#2157) - #2159

Merged
jacktrnr merged 1 commit into
mainfrom
fix-duplicate-new-session
Nov 8, 2026
Merged

jacktrnr merged 1 commit into
mainfrom
fix-duplicate-new-session

Conversation

@jacktrnr

@jacktrnr jacktrnr commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Closes #2157. The delay that makes a second press likely is tracked separately in #2158.

Problem

Starting a new chat sometimes produced two or more identical sessions with the same first message, and each one generated its own response. handleSubmit calls session.create on every submit while the route is still a draft. The composer keeps its text until the create, the navigation transition and the first send have all finished, which took 10–30 s on Jackson's busy engine. So every extra Enter created another session, and each got the same text.

The sessions database has three such clusters today: five "testing" sessions, all sent at the same moment, and two pairs (details in #2157).

Fix

  • new-session-gate.ts is a module-level gate keyed by draft (server scope, project directory, draft id). While one new-session submit from a draft is in flight, further submits from that draft do nothing.
  • The gate is released however the submit ends (sent, failed create, or thrown error), so a failed create can be retried.
  • Two different drafts, such as two panes, can still start sessions at the same time.
  • submit.ts: handleSubmit now runs a draft submit under the gate. A submit in an existing session bypasses the gate, so follow-ups queue as before. The body of the old handleSubmit is unchanged and now lives in submitPrompt.

Verification

  • new-session-gate.test.ts, 7 tests:
    • a second and third submit while the first is in flight create nothing;
    • the draft can submit again once the first settles;
    • a failed create releases the gate;
    • two drafts can run at once;
    • a source pin checks that handleSubmit goes through the gate.
  • Overlay typecheck gate: clean across the 7 packages.
  • Drift gate: PASS after refresh_manifest.
  • ./.notturno/gates: GREEN.
  • The prompt-input suite shows the same 4 failures with and without this change. They are import errors at module load (toaster, base64Decode) in submit.test.ts and harness*.test.ts, unrelated to this diff.
  • Not tested by hand in a live window: this needs a rebuilt engine binary and VSIX.

@jacktrnr jacktrnr added the bug Something isn't working label Nov 8, 2026
@jacktrnr jacktrnr self-assigned this Nov 8, 2026
@coderabbitai

coderabbitai Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d4b52191-09be-4d82-b7e4-d172bee6e56c
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@jacktrnr
jacktrnr merged commit bf84fdd into main Nov 8, 2026
12 checks passed
@jacktrnr
jacktrnr deleted the fix-duplicate-new-session branch November 8, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New chat creates duplicate sessions with the same first message when Enter is pressed again while it starts

1 participant