refactor: address comments

This commit is contained in:
Catriel Müller
2026-05-01 19:23:10 -03:00
parent c9f68644cc
commit 3384b6736c
23 changed files with 182 additions and 75 deletions
+7 -4
View File
@@ -406,9 +406,10 @@ export const layer: Layer.Layer<
case "start-step":
ctx.stepStart = performance.now() // kilocode_change
// kilocode_change start - pass sessionID + messageID so the slow-repo prompt/progress indicator can attach
if (!ctx.snapshot)
// kilocode_change start - pass sessionID + messageID so the slow-repo prompt/progress indicator can attach
ctx.snapshot = yield* snapshot.track({ sessionID: ctx.sessionID, messageID: ctx.assistantMessage.id }) // kilocode_change end - pass sessionID + messageID
ctx.snapshot = yield* snapshot.track({ sessionID: ctx.sessionID, messageID: ctx.assistantMessage.id })
// kilocode_change end
yield* session.updatePart({
id: PartID.ascending(),
messageID: ctx.assistantMessage.id,
@@ -424,13 +425,15 @@ export const layer: Layer.Layer<
usage: value.usage,
metadata: value.providerMetadata,
})
// kilocode_change start
// kilocode_change start - guard against finish-step without start-step:
// ctx.stepStart is 0 until `start-step` fires, which would feed a
// huge bogus `elapsed` into telemetry. Fall back to now().
KiloSessionProcessor.trackStep({
sessionID: ctx.sessionID,
model: ctx.model,
tokens: usage.tokens,
cost: usage.cost,
elapsed: Math.round(performance.now() - ctx.stepStart),
elapsed: Math.round(performance.now() - (ctx.stepStart || performance.now())),
})
// kilocode_change end
ctx.assistantMessage.finish = value.finishReason