Repository navigation
fix(diagnostics): measure reconciled IME typing latency - #17171
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe change adds a renderer typing-latency diagnostic. It captures direct keyboard and reconciled IME inputs, attributes terminal output to inputs, records exact and ambiguous latency observations, and aggregates source-specific metrics. It adds bounded sample windows, pane discovery, lifecycle controls, report generation, and a browser diagnostic bridge. It replaces the previous module locations and updates the application import. Tests cover input classification, echo attribution, lifecycle behavior, source tallies, sample limits, and Linux IME trace replay. Merge Risk: 🔵 Low · up to The diagnostic now measures reconciled IME latency with explicit ambiguity and cleanup handling, but active reports can still temporarily omit stale unmatched inputs until another input arrives or sampling stops. This may briefly undercount diagnostic samples, so merge is reasonable with explicit owner awareness or follow-up. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation The changes address issue Full details: Description checkExplanation The description is detailed and relevant. It covers the motivation, changes, linked issues, visual proof, testing evidence, AI disclosure, scope boundaries, residual gaps, and checklist status. Some template headings are renamed or omitted, but the required information is present.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThe PR replaces keydown-based typing diagnostics with reconciled direct/IME input attribution and decomposed dispatch, parse, and paint latency measurements.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| src/renderer/src/lib/typing-latency/diagnostic.ts | Coordinates bounded input attribution, deferred IME accounting, reporting, and symmetric diagnostic lifecycle cleanup. |
| src/renderer/src/lib/typing-latency/input-events.ts | Observes direct keys and reconciled composition commits, settling IME registrations after route propagation. |
| src/renderer/src/lib/typing-latency/echo-instrumentation.ts | Correlates accepted terminal input with dispatch, parse, and paint stages while preserving ambiguous attribution. |
| src/renderer/src/components/terminal-pane/terminal-ime-composition-route.ts | Exposes validated composition-session details without changing the route’s stale-transport ownership checks. |
| src/renderer/src/lib/typing-latency/diagnostic-lifecycle.test.ts | Verifies the previously reported accounting defect across stale, rerouted, timed-out, and queue-capped IME commits. |
Sequence Diagram
sequenceDiagram
participant IME as Browser/xterm IME
participant D as Typing diagnostic
participant R as IME composition route
participant T as Terminal input
participant O as Output instrumentation
IME->>D: composition-session-end (capture)
D->>D: Record pending IME candidate
IME->>R: composition-session-end (bubble)
alt Current route accepts commit
R->>T: terminal.input(committed text)
T->>O: onData dispatch timestamp
R-->>IME: preventDefault
IME->>D: settle prevented after propagation
D->>D: Retain delivered input accounting
else Route drops stale/rebound commit
R-->>IME: preventDefault without terminal.input
IME->>D: settle prevented after propagation
D->>D: Discard pending candidate and source accounting
end
O->>O: onWriteParsed
O->>O: onRender
O->>D: Exact sample or ambiguous burst
Reviews (4): Last reviewed commit: "fix(typing-diagnostic): bound echo settl..." | Re-trigger Greptile
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: cb92cc69-774c-4bb2-a05e-b393b34fb295
📒 Files selected for processing (21)
src/renderer/src/components/terminal-pane/terminal-ime-composition-route.tssrc/renderer/src/components/terminal-pane/terminal-ime-xterm-linux-native-trace-replay.test.tssrc/renderer/src/lib/typing-latency-diagnostic.tssrc/renderer/src/lib/typing-latency-echo-instrumentation.test.tssrc/renderer/src/lib/typing-latency-echo-instrumentation.tssrc/renderer/src/lib/typing-latency/census-probe.tssrc/renderer/src/lib/typing-latency/diagnostic-lifecycle.test.tssrc/renderer/src/lib/typing-latency/diagnostic-summary.test.tssrc/renderer/src/lib/typing-latency/diagnostic-summary.tssrc/renderer/src/lib/typing-latency/diagnostic.tssrc/renderer/src/lib/typing-latency/echo-instrumentation.test.tssrc/renderer/src/lib/typing-latency/echo-instrumentation.tssrc/renderer/src/lib/typing-latency/echo-observation.tssrc/renderer/src/lib/typing-latency/input-events.test.tssrc/renderer/src/lib/typing-latency/input-events.tssrc/renderer/src/lib/typing-latency/input-source.test.tssrc/renderer/src/lib/typing-latency/input-source.tssrc/renderer/src/lib/typing-latency/pane-target.tssrc/renderer/src/lib/typing-latency/sample-window.test.tssrc/renderer/src/lib/typing-latency/sample-window.tssrc/renderer/src/main.tsx
💤 Files with no reviewable changes (3)
- src/renderer/src/lib/typing-latency-diagnostic.ts
- src/renderer/src/lib/typing-latency-echo-instrumentation.ts
- src/renderer/src/lib/typing-latency-echo-instrumentation.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
| while (removeOldestTimedOut(entry, now)) { | ||
| dropped += 1 | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Expire timed-out inputs before an active report.
removeOldestTimedOut runs only when a later keystroke arrives. If the final input has no terminal output, an active report() can show zero unmatched keystrokes after two seconds. stop() then adds that same pending input as unmatched. Expire each pane during reporting, or schedule expiry, so report-then-stop gives consistent accounting.
|
Status refresh: published head is |
Review notes before mergeTwo corrections to this PR's own claims, both verified against The bounds are not new hardening. The "flat modules → directory reorganisation" framing is wrong, which matters because it invites the wrong review. Rename detection at 5% similarity finds exactly one genuine move ( The fix is real, and larger than describedReplayed against recorded hardware traces. The old
So on macOS the probe was reporting 400–1000 ms of human composition time as typing latency, plus stale pendings timing out into One change that does not belong here — follow-up filed
The Impact is one counter in an opt-in DevTools census, so this is not merge-blocking. But a worktree/SSH semantics change arriving inside an IME PR under a rename is exactly the pattern that makes large diffs unreviewable, and it is tracked separately rather than left implicit. Mutation testing: 18 applied, 13 caught, 5 survivedThree survivors are real gaps, and two are worth a follow-up rather than blocking:
The remaining two survivors are not gaps — one clause is doubly redundant ( Input path: clean
|
* fix(diagnostics): measure terminal IME input * fix(diagnostics): settle prevented IME inputs * fix(typing-diagnostic): preserve sample attribution invariants * fix(typing-diagnostic): bound echo settlement state
ELI5
The typing probe now times composed text when it actually reaches the terminal, instead of timing IME key presses that send no text.
Root cause
The prior diagnostic watched echoing keydowns rather than xterm's reconciled composition commit. It therefore recorded zero CJK samples, dropped fast-burst inputs, and could attribute one input's output to another.
The fix observes the existing reconciled xterm composition-session event—the point where committed text has an owner—and keeps uncertain overlaps explicit rather than manufacturing exact latency.
What changed
compositionend.datais empty.typing-latency/feature folder with concrete module names.Linked issue
Fixes #16950
Shared acceptance checklist: #17172.
Visual proof
N/A — this changes an opt-in DevTools diagnostic API and has no user-facing UI. Reports and lifecycle behavior were manually inspected; no visual artifact is claimed.
Exact-head verification
Published head:
d1f14c8a0a721b5a8aa28aea094f6224e22b7777mainnormally with no changed-file overlap.pnpm install --frozen-lockfile: passed.terminal-input.ime-and-synthetic-forwardingslice: 8 files / 178 tests passed.pnpm tc: passed.pnpm run check:code-quality:changed: zero code, type-aware, and React Doctor findings across 18 changed code files.Coverage includes isolated direct/IME input, empty-data reconciliation, mixed-source ambiguity, timeout/cap gaps, UTF-8 byte accounting, stop/drain cleanup, frozen duration, stale prevented commits, successful prevented reroutes, queue-cap settlement, and once-only propagation settlement.
Native-machine status
m4airlive/ native resultunverifiableawinunverifiableopenclawlive/ graphical resultunverifiableDISPLAYandWAYLAND_DISPLAYare unset.Recorded Linux IBus traces prove the reconciliation contract. A fresh graphical native run remains
unverifiable.Readiness and code elegance
Exact-head audit found zero proven P0/P1/P2 findings; counsel was unnecessary because there were no candidates.
isImeOwnedKeyboardEvent; capture + bubble settlement distinguishes stale prevented commits from successfully rerouted prevented commits.start().stop()removes all three window listeners and xterm listeners, conditionally restoresterminal.write, clears queues and pane references, and freezes duration.main; merge-tree and exact diff are clean.Residual test gaps, not proven defects: no explicit injected-throw rollback test for startup hooks, dynamic pane creation after sampling begins, or parsed output that never paints.
AI disclosure
AI-assisted implementation, test construction, and review were used. Claims above are tied to deterministic tests, exact-head gates, or explicitly named residual gaps.
Agent skill upstream boundary
Checklist
d1f14c8a0a7is green (21 successful, 9 skipped, 0 failed or pending); the diff is unchanged and the shared baseline repairs are merged intomain.