Skip to content

fix(app): new chat shows 'Starting session' at once and sends its first message without waiting for the page to load (#2158) - #2177

Open
jacktrnr wants to merge 1 commit into
mainfrom
fix/2158-first-message-feedback
Open

jacktrnr wants to merge 1 commit into
mainfrom
fix/2158-first-message-feedback

Conversation

@jacktrnr

Copy link
Copy Markdown
Contributor

Closes #2158. Follows #2159 (#2157, the duplicate-session gate), which changed the same new-chat submit path.

Problem

A new chat's first message went out 10–30 s after the session was created on a busy engine. During that time the composer still showed the text and nothing on screen changed.

Root cause

After session.create, submit.ts ran await startTransition(...), which promotes the draft tab to the session and navigates, and only then sent the prompt. In Solid (1.9.10, dist/solid.js), the promise from startTransition resolves only when the transition settles, meaning every resource the new session page reads inside it has loaded. Solid also keeps one global transition: t = Transition || (Transition = {...}), so every transition started while one is pending joins it.

On the busy engine (SSE-TICK lag_ms 3921–4152), each of the session page's reads took seconds, so the send waited for all of them. The shared transition explains the evidence in the issue: five "testing" sessions created over 21 s (15:08:49–15:09:10) all sent their first message at 15:09:14.0. Every one of them was waiting on the same settle.

The send never needed the settle. It only needs the transition callback to have run, so that the route is promoted and the prompt is retargeted.

Fix

  • transition-started.ts (new): whenTransitionStarted(fn) runs fn inside a Solid transition. It resolves as soon as fn has run and returns { settled } separately. If fn throws, it rejects, so a failure surfaces instead of hanging.
  • submit.ts: a new chat now sends its first message as soon as the route is promoted, without waiting for the session page to load. The new-chat gate from New chat creates duplicate sessions with the same first message when Enter is pressed again while it starts #2157 is still held until the navigation settles, so the duplicate-session protection behaves as before.
  • new-session-gate.ts: the in-flight set is now a Solid signal. It is exposed as isNewSessionStarting(key), with newSessionKey(scope, directory, draftId) as the single key builder for both the submit and the view.
  • new-session-starting.tsx (new) + new-session-view.tsx: a "Starting session…" status with a spinner under the new-chat composer. It appears on the same tick as Enter and stays until the session page replaces the view.
    • It uses neutral muted tokens (text-v2-text-text-muted, text-v2-icon-icon-muted) and no accent, per the design system.
    • It is an aria-live="polite" role="status" region that is always mounted. It uses display: contents, so it takes no space until it shows.
  • en.ts: adds prompt.newSession.starting. Other locales fall back to English.

Out of scope: moving engine-side session-start work off the event loop (the issue's item 3; no engine re-architecture for the beta). The Concise toggle code (#1650) is untouched.

Verification

Tests ran from the materialized tree with bun test --conditions=solid --preload ./happydom.ts.

  • new-session-gate.test.ts: 11 pass. The new tests check:
    • "starting" is true from submit until settle, and only for that draft;
    • it is cleared on a failed create;
    • the in-flight set is a signal (pinned by source, because bun resolves solid-js to its server build here and effects do not run);
    • newSessionKey builds the right key.
  • transition-started.test.ts (new): 5 pass. The tests check:
    • against a Solid-like startTransition whose settle is held open, the helper resumes once the callback has run and does not wait for the settle;
    • settled still reports the settle;
    • a callback that throws rejects;
    • wiring pins: submit.ts no longer contains await startTransition(, and the gate is held until navigation settles.
  • new-session-view.test.ts: 7 pass. Three new pins check that the notice renders under the composer, reads the gate with the submit's key, and is an aria-live status with a spinner and an i18n key.
  • Pre-existing failures are identical with and without this change:
    • module-load errors (toaster, base64Decode) in submit.test.ts, submit-concise.test.ts, harness*.test.ts;
    • window.getSelection missing in happy-dom for editor-dom.test.ts;
    • 4 i18n parity and locale tests.
  • overlay_typecheck_gate.sh: clean across 7 packages. tsgo -b in packages/app is clean.
  • refresh_manifest then drift_gate: PASS (1085 overlay files).
  • ./.notturno/gates (drift, typecheck): GREEN.

Not tested by hand in a live window, because that needs a rebuilt engine binary and VSIX. Issue AC 3 (first send within 1 s of create on an idle engine) follows from the send no longer waiting on the page load, but it has not been measured live.

🤖 Generated with Claude Code

… message without waiting for the page to load (#2158)

A new chat's first message waited on `await startTransition(...)` in
submit.ts. Solid resolves that promise only when the transition settles,
i.e. when every resource the new session page reads has loaded, and it
keeps one global transition, so concurrent new chats were all released at
the same instant. On a busy engine (event-loop lag ~4 s) that was 10-30 s
with the composer still showing the text.

- transition-started.ts: run the navigation in the transition but resume
  once its callback has run; the settle is handed back separately.
- submit.ts: send the first message as soon as the route is promoted; the
  new-chat gate is held until the navigation settles.
- new-session-gate.ts: the in-flight set is a signal, exposed as
  isNewSessionStarting(newSessionKey(...)).
- new-session-starting.tsx: a 'Starting session…' status under the new-chat
  composer from the moment Enter is pressed until the session page shows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 23, 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: d28b75c8-1daa-40a8-9759-da64a518df36
  • 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

Copy link
Copy Markdown
Contributor Author

Verified hands-on in the combined 0.4.1-beta test build (test/0.4.1-beta, Developer Tools → Rebuild Locally, macOS arm64) on 2026-11-23: all checks in this PR's manual checklist pass.

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.

New chat: first message sent 10–30 s after the session is created on a busy engine, with no feedback

1 participant