Skip to content

Dev - #27

Merged
MegumiinUwU merged 4 commits into
mainfrom
dev
Jul 2, 2026
Merged

Dev#27
MegumiinUwU merged 4 commits into
mainfrom
dev

Conversation

@MegumiinUwU

Copy link
Copy Markdown
Collaborator

No description provided.

Hemdan47 added 4 commits July 2, 2026 22:48
Thinking events were streaming at the same 45ms per word as assistant
updates, making long reasoning sequences painfully slow. Use 10ms per
word for assistant.thinking events while keeping 45ms for
assistant.update.
When the user cancelled mid-stream, the backend continued sleeping 2
seconds per event and streaming words the client would never see. With
10+ events queued, the AI message wasn't saved to the DB for 20+
seconds — if the user reopened the chat during that window, all
assistant content was missing.

Check res.destroyed at the start of handleEvent. If the client is gone,
skip all writes and sleeps — just push the event to the events array
and return immediately. The AI message is saved right after
readAgentStream completes.
events.push was called before writing to the client, so events that
were never delivered (due to client disconnect or mid-word-loop cancel)
were saved to the DB. On reopen, the user saw events they never
received during the live stream.

Move events.push to after the write completes. For streaming events
(assistant.update/thinking), push only after all words are sent. Check
res.destroyed inside the word loop so a mid-stream disconnect skips the
push. The title.generated session update still runs before the
res.destroyed check so the title is saved regardless.
The run.completed summary was sent as a single NDJSON line, appearing
instantly instead of streaming like other assistant messages. When
run.completed has a summary, stream it as assistant.update word chunks
(45ms each) to the client, then send the run.completed event without
the summary. Push only the original run.completed (with summary) to
the events array for DB saving — no synthetic assistant.update event
is saved, so there is no duplication on reopen.
@MegumiinUwU
MegumiinUwU merged commit 34443e2 into main Jul 2, 2026
2 checks passed
@MegumiinUwU
MegumiinUwU deleted the dev branch July 3, 2026 02: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.

2 participants