Skip to content

Fix equipment Back, keyboard navigation, and asynchronous equip ownership - #268

Merged
Hona merged 12 commits into
mainfrom
work/tf2-equipment-navigation-latency
Sep 1, 2026
Merged

Fix equipment Back, keyboard navigation, and asynchronous equip ownership#268
Hona merged 12 commits into
mainfrom
work/tf2-equipment-navigation-latency

Conversation

@Hona

@Hona Hona commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Changes

  • Keep Back and Escape usable during model preparation; cancel uncommitted equip intent without replaying stale navigation after close, reopen, map replacement, or disconnect.
  • Report equipment failures rather than returning unchanged inventory as successful equip. Publish admission only after pipeline preparation, and keep an older failure from poisoning the next request.
  • Restore Source keyboard/page navigation and class-menu close destinations. Preserve focus across page replacement, suppress held-button replay, and leave console/options input with their existing owner.
  • Share bounded immutable raster bitmaps instead of repeatedly uploading identical pixels into each control. Keep the original canvas, shader, alpha, and clipping behavior.

Validation

  • Rebased onto current main; 182 focused tests / 2,052 assertions pass, covering equipment, VGUI, input and application lifecycle.
  • Navigation checked against official Source SDK 88fa198fba3fb85d46d4c95018254693fdc3af0a and configured UI resources.
  • Existing headed Windows interaction evidence covers class/loadout/slot/backpack navigation, PageDown and Escape. The pre-optimization CPU capture attributed approximately 60.69 ms of sampled self time to repeated putImageData, plus 22.00 ms to getContext during a roughly 5.5-second capture. These are attribution estimates, not a claimed end-to-end speedup.
  • The shared-bitmap implementation produced zero differing channels against the original canvas in both client and native-window pixel comparisons, including alpha, scaling, clipping, foreground order and input. The verified rasterizer source blob is unchanged after integration.
  • An intermediate PNG/image-element approach produced 4,385 differing channels and was rejected, not accepted with a relaxed tolerance.

Existing reviewed evidence

Only client-area captures are attached; private desktop captures remain private.

Original canvas reference:
Original canvas reference

Shared bitmap result (byte-identical client capture):
Shared bitmap result

Equipment navigation capture from the existing headed interaction run:
Equipment navigation

Measurement limits

This reuses the retained pixel and interaction evidence. There is no new matched Windows end-to-end latency/retention campaign, and the additional device fault-injection/map-lifecycle cases are not claimed as completed. Asynchronous error, cancellation and focus paths have focused regression coverage. The user approved completing this fix with those additional device measurements documented as limits rather than merge gates. No production or release changes are included.

@Hona
Hona force-pushed the work/tf2-equipment-navigation-latency branch 2 times, most recently from 9605f6d to 89153ef Compare September 1, 2026 02:25
@Hona
Hona marked this pull request as ready for review September 1, 2026 02:27
Copilot AI lite review requested due to automatic review settings September 1, 2026 02:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

It touches core UI/runtime input ownership, async equipment admission, and rendering paths; cleanup error propagation needs adjustment and warrants final human review.

Pull request overview

This PR hardens TF2 equipment/navigation behavior (Back/Escape/key focus, async equip cancellation/ownership) and introduces profiling/parity coverage plus a retained-raster optimization that shares immutable bitmaps across consumers to reduce repeated pixel uploads.

Changes:

  • Fix equipment navigation/focus behavior (Back/Escape, held keys, console/options ownership) and make equip ownership/cancellation robust across close/reopen, map replacement, and disconnect.
  • Make equipment admission/equip failures explicit and non-poisoning for subsequent requests; add regression tests for async cancellation and failure paths.
  • Optimize VGUI retained raster publishing by sharing cached ImageBitmaps; add parity fixtures and profiling runners/configs.
File summaries
File Description
tools/playsrc/src/profile-runner.ts Adds new headed profile entries for equipment navigation variants and VGUI raster parity.
tools/playsrc/profile/vgui-raster-parity.profile.ts New headed parity profile that asserts identical pixels between shared raster and baseline.
tools/playsrc/profile/equipment.profile.ts Updates equipment profiling assertions and strengthens Back/Escape navigation expectations.
tools/playsrc/profile/equipment-navigation.profile.ts New headed navigation/profile capture for trusted input, CPU sampling, transactions, and lifecycle cases.
tools/playsrc/profile/equipment-navigation-analysis.ts New analysis step to compute selection visibility latency from captured native references.
playwright.vgui-raster-parity.config.ts New Playwright config for the raster parity headed profile.
playwright.equipment-navigation.config.ts New Playwright config for the equipment navigation headed profile.
packages/presentation/vgui/tests/runtime.test.ts Adds a regression test for Enter key handling vs default dialog buttons.
packages/presentation/vgui/tests/retained-raster.html New browser fixture HTML for retained-raster parity checks.
packages/presentation/vgui/tests/retained-raster-browser-fixture.ts Updates fixture instrumentation to track retained raster publishes via drawImage.
packages/presentation/vgui/tests/image-renderer.test.ts Adds cache disposal semantics tests and bitmap sharing/lifecycle unit coverage.
packages/presentation/vgui/src/runtime.ts Improves keyboard handling (repeat/press/release), focus ownership during replacement, and cancels held button presses on blur/hidden.
packages/presentation/vgui/src/image-renderer.ts Introduces bitmap-backed raster sharing via cache entries and disposal hooks.
packages/presentation/vgui/scripts/verify-retained-raster-browser.ts Switches verification script to run via the shared headed profile runner.
games/tf2/browser/tests/equipment-profile.test.ts New tests for async equip cancellation, failure isolation, and replacement safety.
games/tf2/browser/tests/equipment-presentation.test.ts Large expansion of navigation/focus/error tests for the equipment UI presentation layer.
games/tf2/browser/src/equipment/profile.ts Adds abort-signal support to queued equipment mutations.
games/tf2/browser/src/equipment/presentation.ts Implements async equip cancellation/ownership, restores keyboard navigation, and adds error reporting hooks.
apps/web/tf2/src/runtime.ts Integrates new equip ownership/error callbacks, preserves focus across replacements, and refines admission lifecycle semantics.
Review details
  • Files reviewed: 19/19 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

this.#equipmentPreparing = false
if (!retained) await this.#client?.releaseResources(configuration.generation).catch(() => {})
const release = [...(!retained ? [configuration.generation] : []), ...(replacedPanel && previous ? previous.sources : [])]
await Promise.all(release.map(source => client.releaseResources(source)))
@Hona
Hona force-pushed the work/tf2-equipment-navigation-latency branch 3 times, most recently from 7ce567f to 192be2a Compare September 1, 2026 02:55
@Hona
Hona force-pushed the work/tf2-equipment-navigation-latency branch from 192be2a to ff1747c Compare September 1, 2026 03:05
@Hona
Hona merged commit afb0849 into main Sep 1, 2026
1 check passed
@Hona
Hona deleted the work/tf2-equipment-navigation-latency branch September 1, 2026 03:15
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