Measure refresh latency independently and retain intended result selection
This commit is contained in:
1 parent
373ed1ed49
commit
8b993b23d7
7 files changed
+188
-11
No files matched your search
@@ -35,8 +35,15 @@ interface Attempt {
|
||||
failed: boolean;
|
||||
ended_at: number;
|
||||
}
|
||||
interface InputTimingSummary {
|
||||
debounce_ms: number;
|
||||
first_results_ms: number | null;
|
||||
latest_displayed_ms: number | null;
|
||||
hybrid_final_results_ms: number | null;
|
||||
}
|
||||
|
||||
export class SearchMeasurement {
|
||||
private originalInput: Readonly<InputTimingSummary> | null = null;
|
||||
debug: boolean;
|
||||
inputAt: number;
|
||||
scheduledAt: number;
|
||||
@@ -67,6 +74,24 @@ export class SearchMeasurement {
|
||||
this.debug = debug;
|
||||
this.context = { ...context };
|
||||
}
|
||||
/** Filesystem updates are independent requests, not elapsed user idle time. */
|
||||
freshForRefresh(now: number): SearchMeasurement {
|
||||
const refreshed = new SearchMeasurement(now, now, this.debug, this.context);
|
||||
// Preserve one fixed-size numeric snapshot, never an ancestor trace/history.
|
||||
// Pending responses on the old request cannot rewrite this snapshot.
|
||||
refreshed.originalInput = Object.freeze({
|
||||
...(this.originalInput ?? {
|
||||
debounce_ms: Math.max(0, this.scheduledAt - this.inputAt),
|
||||
first_results_ms: this.firstDisplayMs,
|
||||
latest_displayed_ms: this.displays.at(-1)?.elapsed_ms ?? null,
|
||||
hybrid_final_results_ms:
|
||||
[...this.displays]
|
||||
.reverse()
|
||||
.find((display) => display.lane === "hybrid")?.elapsed_ms ?? null,
|
||||
}),
|
||||
});
|
||||
return refreshed;
|
||||
}
|
||||
submitted(lane: SearchLane, at: number) {
|
||||
if (!this.submissions.has(lane)) this.submissions.set(lane, at);
|
||||
this.latestSubmission.set(lane, at);
|
||||
@@ -140,6 +165,8 @@ export class SearchMeasurement {
|
||||
export() {
|
||||
return {
|
||||
version: 1,
|
||||
trigger: this.originalInput ? "filesystem_refresh" : "user_search",
|
||||
original_input: this.originalInput ? { ...this.originalInput } : null,
|
||||
context: this.context,
|
||||
clock_note:
|
||||
"UI monotonic elapsed times; native command-relative spans. Nested spans and parallel lanes must not be summed.",
|
||||
|
||||
Reference in new issue
Block a user