Skip to content

fix(thinking-timer): correct thinking timer across session switches - #666

Merged
haiphucnguyen merged 1 commit into
mainfrom
feature/minor-improvements
Aug 23, 2026
Merged

haiphucnguyen merged 1 commit into
mainfrom
feature/minor-improvements

Conversation

@haiphucnguyen

Copy link
Copy Markdown
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.
Copilot AI lite review requested due to automatic review settings August 23, 2026 09:19
@haiphucnguyen
haiphucnguyen merged commit 25bf53b into main Aug 23, 2026
11 checks passed
@haiphucnguyen
haiphucnguyen deleted the feature/minor-improvements branch August 23, 2026 09:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 SupervisorJob so 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()
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