Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@julgmz
Copy link
Collaborator

@julgmz julgmz commented Oct 23, 2025

No description provided.

@julgmz julgmz changed the title working, needs cleanup Timing Metric Gathering Oct 23, 2025
@github-actions
Copy link

Resolves #353

@julgmz julgmz marked this pull request as ready for review October 23, 2025 19:26
@@ -0,0 +1,317 @@
import log from 'electron-log'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Check if existing timing libraries offer the same feature + maybe more

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

and replace log.x with console.x

/**
* Get current queue stats (for debugging)
*/
getStats() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

llm bad

itoSessionManager: mockitoSessionManager,
}))

const mockTimingCollector = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

see if i can put it in the preload

@julgmz
Copy link
Collaborator Author

julgmz commented Oct 24, 2025

account for pill kickoff

events: TimingEvent[]
total_duration_ms: number
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

check to see if theres dupe code here from client logs

@@ -0,0 +1,138 @@
import type { FastifyInstance } from 'fastify'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

see if buf works 🔫

const now = Date.now()
const entries = reports.map(report => {
const structured = {
'@timestamp': new Date().toISOString(),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

just change this to the client timestamp


this.activeTimings.set(interactionId, {
interaction_id: interactionId,
start_timestamp: new Date().toISOString(),
Copy link
Collaborator

@fulltimemike fulltimemike Oct 24, 2025

Choose a reason for hiding this comment

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

We should use perf_hooks.performance.now() instead of Date(), since Date() can be adjusted by the system clock. E.g. when daylight savings time hits, we may see anomalous 1 hr+ sessions if we use Date()

Copy link
Collaborator

Choose a reason for hiding this comment

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

One more note -- for the very first interaction, we should use Date().toISOString() as the start_timestamp, so that we know roughly when this happened in human time. But for any other timestamps, we should use performance.now()


// Calculate total duration
const events = Array.from(active.events.values())
const firstEvent = events.find(e => e.name === TimingEventName.HOTKEY_PRESS)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should make this a class constant, and remember that a Pill click might be the actual first click

Comment on lines +222 to +234
const serverUrl =
import.meta.env.VITE_GRPC_BASE_URL || 'http://localhost:3001'
const payload = { reports: reportsToSend }

const token = (store.get(STORE_KEYS.ACCESS_TOKEN) as string | null) || ''
const response = await fetch(`${serverUrl}/timing`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
...(token ? { Authorization: `Bearer ${token}` } : {}),
},
body: JSON.stringify(payload),
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should be able to move this call to the grpcClient

log.error('[itoSessionManager] Failed to fetch/send context:', error)
})

this.interactionId = interactionId
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to set this? Can we just retrieve it when needed from the InteractionManager?

public async initialize(mode: ItoMode): Promise<boolean> {
public async initialize(
mode: ItoMode,
interactionId: string,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not a huge fan of sprinkling interactionId throughout the code. Can we try to keep it isolated to InteractionManager?

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