Repository navigation
perf(desktop): compute the turn's elapsed time in its own component - #165
Merged
GoDiao merged 5 commits intoOct 23, 2026
Merged
Conversation
A 1s interval in chatStore wrote elapsedSeconds into the session while a turn ran, so every subscriber of the session re-rendered once a second. Both intervals (the one started on send and the one started when a mirror turn begins running) are gone, together with the elapsedSeconds and elapsedTimer fields and the clearInterval calls that went with them. The elapsed time now comes from turn.startedAt in the server's session state.
ElapsedTime keeps its own 1s timer and computes the value from the turn start the server reports, so only it re-renders each second, and the time stays right after switching sessions, a reconnect or a refresh. Test fixtures drop the removed session fields.
GoDiao
approved these changes
Oct 23, 2026
GoDiao
left a comment
Owner
There was a problem hiding this comment.
Thanks, this looks good to merge.
GoDiao
added a commit
that referenced
this pull request
Oct 23, 2026
Owner
|
Merged, thanks @princecherry9905! This was a clean first PR. Reading the start time from the server's We added the CHANGELOG entry. If DreamCoder is useful to you, a ⭐ on the repo would mean a lot. Hope to see you around for more! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #156. Part of #153.
Why
While a reply ran, a 1s interval in
chatStorewroteelapsedSecondsinto the session, so the page, the message list, the composer and the streaming indicator all re-rendered once a second for the whole turn.What changed
sendMessageand the oneapplyMirrorstarted when a turn began running. TheelapsedSecondsandelapsedTimersession fields go with them, along with everyclearIntervalthat only existed to stop those timers (stop, message complete, error, history reload,/clear, disconnect).turn.startedAtin the mirrored session state, not from a value recorded on the client.ElapsedTime(new,components/chat/ElapsedTime.tsx) keeps its own 1s timer and computes the value fromstartedAt, so only that span re-renders each second.StreamingIndicatorrenders it while the mirrored turn isn't idle. The format (42s,1m 5s) and the "hidden at 0s" rule are unchanged.teamStore's member session default drops them too.Behaviour difference: the time now starts when the server marks the turn as running, not at the moment you press send. Before that the indicator shows the verb with no time, which is what the old code showed during the first second anyway.
Tests
chatStore.test.ts: "leaves the store unchanged while a turn runs" sends a message, starts a running turn and advances fake timers 5s, then checks thesessionsobject is the same reference.StreamingIndicator.test.tsx(new): counts from the server's start and ticks each second (1m 5sthen1m 6s), shows the right time after switching sessions, keeps counting from the same start after a reconnect snapshot, and shows no time when no turn has started.main(the 5th checks the idle case, which already passed) and all pass with this change.Checks run locally (bun 1.4.2):
cd desktop && bun run lint: passcd desktop && bun run test -- --run: 115 files, 1195 passed, 4 skippedcd desktop && bun run build: passbun test(server): 1343 pass, 2 fail. The failures areh5-access-service.test.ts(getDiagnostics) ande2e/business-flow.test.ts(echo message), and both fail the same way on unchangedmainin my environment. This PR doesn't touch server code.I couldn't run
bun run tauri devin my environment, so I haven't watched it in the app.