Repository navigation
fix(thinking-timer): correct thinking timer across session switches - #666
Merged
Merged
Conversation
haiphucnguyen
commented
Aug 23, 2026
Collaborator
- Introduced optional startTimeMillis parameter to startThinkingTimer to keep accurate elapsed time when a user switches sessions.
- Stored startTimeMillis in SessionManager to preserve timer state across resubscriptions.
- Updated Main to clear chat through sessionManager.getOrCreateChatViewModel, ensuring consistent session handling.
- Bumped Gradle wrapper to version 9.7.0 for improved build stability.
- Introduced optional startTimeMillis parameter to startThinkingTimer to keep accurate elapsed time when a user switches sessions. - Stored startTimeMillis in SessionManager to preserve timer state across resubscriptions. - Updated Main to clear chat through sessionManager.getOrCreateChatViewModel, ensuring consistent session handling. - Bumped Gradle wrapper to version 9.7.0 for improved build stability.
There was a problem hiding this comment.
Pull request overview
This PR improves the accuracy and consistency of the “thinking” timer UI when users switch chat sessions during an in-flight streaming response, and aligns session-scoped actions to the active session’s ViewModel. It also updates the project’s Gradle wrapper.
Changes:
- Preserve “thinking” elapsed time across session switches by persisting a thread start timestamp and passing it into the timer.
- Refactor chat thread subscriptions to use a parent
SupervisorJobso all collectors can be cancelled together on resubscribe/completion. - Update the “New Chat” menu action to clear the active session’s chat via
SessionManager, and bump Gradle wrapper to 9.7.0.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| gradle/wrapper/gradle-wrapper.properties | Bumps Gradle wrapper distribution URL to 9.7.0. |
| desktop/src/main/kotlin/io/askimo/desktop/Main.kt | Clears chat using the active session’s ChatViewModel from SessionManager. |
| desktop-shared/src/main/kotlin/io/askimo/ui/session/SessionManager.kt | Adds startTimeMillis to streaming threads to persist “thinking” start time across resubscriptions. |
| desktop-shared/src/main/kotlin/io/askimo/ui/chat/ChatViewModel.kt | Uses thread start time for timer resubscribe accuracy and introduces a subscription parent job for collector lifecycle management. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
408
to
412
| // Subscribe to thinking/reasoning tokens streamed by models that expose reasoning. | ||
| // Accumulate chunks into a single string; UI renders them in a collapsible section. | ||
| scope.launch { | ||
| subscriptionScope.launch { | ||
| activeThread.pendingApproval.collect { request -> | ||
| if (currentSessionId.value == sessionId) { |
Comment on lines
+812
to
+816
| private fun startThinkingTimer(startTimeMillis: Long = System.currentTimeMillis()) { | ||
| // Compute elapsed from the real start time so that re-subscribing to an | ||
| // already-running thread (e.g. after switching sessions and back) shows | ||
| // the correct elapsed time instead of restarting from 0. | ||
| thinkingElapsedSeconds = ((System.currentTimeMillis() - startTimeMillis) / 1000).toInt() |
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.