Skip to content

chat: add additional timing information on the model#278449

Merged
connor4312 merged 2 commits intomainfrom
connor4312/chatmodel-timestamps
Nov 19, 2025
Merged

chat: add additional timing information on the model#278449
connor4312 merged 2 commits intomainfrom
connor4312/chatmodel-timestamps

Conversation

@connor4312
Copy link
Member

  • Add a public created timestamp on the IChatModel
  • Add a started timestamp and optional completedAt timestamp on
    the IChatResponseModel
  • Make isPendingConfirmation<{startedWaitingAt: number}> | undefined
    to encode the time when the response started waiting for confirmation.
  • Add a confirmationAdjustedTimestamp that can be used to reflect the
    duration a chat response was waiting for user input vs working.

cc @bpasero

- Add a public created `timestamp` on the IChatModel
- Add a started `timestamp` and optional `completedAt` timestamp on
  the IChatResponseModel
- Make `isPendingConfirmation<{startedWaitingAt: number}> | undefined`
  to encode the time when the response started waiting for confirmation.
- Add a `confirmationAdjustedTimestamp` that can be used to reflect the
  duration a chat response was waiting for user input vs working.
Copilot AI review requested due to automatic review settings November 19, 2025 21:52
@connor4312 connor4312 enabled auto-merge (squash) November 19, 2025 21:52
@connor4312 connor4312 self-assigned this Nov 19, 2025
@vs-code-engineering vs-code-engineering bot added this to the November 2025 milestone Nov 19, 2025
Copy link
Contributor

Copilot AI left a comment

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 adds comprehensive timing information to the chat model system to better track when chat responses start, complete, and wait for user confirmation. The changes enable more accurate duration calculations that account for time spent waiting for user input versus time spent actively generating content.

Key Changes

  • Added public timestamp property to IChatModel and IChatResponseModel to record creation time
  • Added completedAt timestamp on IChatResponseModel to track when responses finish
  • Enhanced isPendingConfirmation to include startedWaitingAt timestamp for tracking confirmation wait periods
  • Introduced confirmationAdjustedTimestamp observable that adjusts the response timestamp to exclude user confirmation wait time

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
src/vs/workbench/contrib/chat/test/common/chatModel.test.ts Adds comprehensive test suite for timestamp and confirmationAdjustedTimestamp behavior, including simulation of pending confirmation states using fake timers
src/vs/workbench/contrib/chat/common/chatModel.ts Implements timing infrastructure with timestamp tracking, state-based completion tracking via ResponseModelState enum, and confirmation-adjusted timestamp calculation; updates serialization to persist timing data
src/vs/base/common/types.ts Adds WithDefinedProps utility type to enforce explicit property definition in objects satisfying interfaces with optional properties

Comment on lines +290 to +305
const toolState = observableValue<any>('state', { type: 0 /* IChatToolInvocation.StateKind.WaitingForConfirmation */ });
const toolInvocation = {
kind: 'toolInvocation',
invocationMessage: 'calling tool',
state: toolState
} as Partial<IChatToolInvocation> as IChatToolInvocation;

model.acceptResponseProgress(request, toolInvocation);

// Advance time while pending
clock.tick(2000);
// Timestamp should still be start (it includes the wait time while waiting)
assert.strictEqual(response.confirmationAdjustedTimestamp.get(), start);

// Resolve confirmation
toolState.set({ type: 3 /* IChatToolInvocation.StateKind.Completed */ }, undefined);
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

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

The magic numbers 0 and 3 used for IChatToolInvocation.StateKind make the code less readable and maintainable. The comments indicate these represent WaitingForConfirmation and Completed respectively, but using the actual enum values would be clearer.

Consider importing the enum and using the named values: IChatToolInvocation.StateKind.WaitingForConfirmation and IChatToolInvocation.StateKind.Completed.

Copilot uses AI. Check for mistakes.
@connor4312 connor4312 mentioned this pull request Nov 19, 2025
21 tasks
@connor4312 connor4312 merged commit 39b5dc3 into main Nov 19, 2025
28 checks passed
@connor4312 connor4312 deleted the connor4312/chatmodel-timestamps branch November 19, 2025 23:09
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Jan 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants