Skip to content

Reduce Agent-key navigation latency - #2

Merged
user3301 merged 2 commits into
mainfrom
perf-agent-navigation
Oct 2, 2026
Merged

user3301 merged 2 commits into
mainfrom
perf-agent-navigation

Conversation

@user3301

@user3301 user3301 commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

Reduce AI Micro Agent-key navigation latency in GitHub Copilot App by avoiding redundant App queries and per-keypress PowerShell startup.

Changes

  • Reuse successful session-status snapshots for up to 2.5 seconds for Agent-key, previous/next, and focus navigation. Refresh expired snapshots or retry after polling failures.
  • Cache the App-provided session URL catalogue for 30 seconds. Clear the cache after configuration changes, read failures, or navigation failures.
  • Prewarm and reuse a hidden PowerShell URI helper while the bridge runs, instead of launching PowerShell for every keypress.
  • Preserve strict session URL validation, serialized requests, explicit errors, a 10-second timeout, and shutdown cleanup. Failed or timed-out navigation is not automatically replayed.
  • Add regression coverage and document cache behavior and limitations.

Performance

Measured Windows URI dispatch time across five calls on the same machine:

Implementation Samples (ms) Median
Previous: PowerShell started per call 705, 710, 695, 842, 1082 710 ms
Updated: prewarmed helper 97, 37, 44, 48, 43 44 ms

The helper's startup cost was approximately 619 ms, paid once when the bridge starts.

These measurements cover URI dispatch acknowledgment, not end-to-end App rendering latency. Physical USB testing also confirmed noticeably faster switching.

Validation

  • All 52 tests passed, with no skipped tests.
  • Syntax checks and Git whitespace checks passed.
  • Existing bounded App-output reader regression tests remain intact.
  • USB bridge restarted successfully with existing bindings unchanged.

Scope and known limitations

  • No firmware changes, new dependencies, or private configuration included.
  • Existing HID input/polling serialization is preserved; slow in-flight polling can still delay navigation.
  • One bound session still exhibits additional delay through the App's deep-link path, despite fast URI dispatch and fast sidebar navigation. Logs show additional peek_session / open_session_by_id handling. This issue remains unresolved.
  • The helper is owned by the extension; this does not solve bridge shutdown caused by App host-session recycling.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

Copilot review overview

🟡 Changes recommended

The helper rejects valid URL casing accepted by the JavaScript validators.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Reduces Agent-key navigation latency through short-lived caches and a reusable PowerShell URI helper.

Changes:

  • Caches session status and validated session URLs.
  • Reuses a prewarmed, serialized PowerShell helper.
  • Adds lifecycle cleanup, regression tests, and documentation.
File Description
controller.mjs Reuses recent status snapshots.
extension.mjs Integrates caches and URI-helper lifecycle.
navigation.mjs Adds session URL catalogue caching.
windows-uri.mjs Implements reusable PowerShell URI dispatch.
tests/​bridge.test.mjs Tests navigation and caching behavior.
tests/​windows-uri.test.mjs Tests helper serialization and failures.
README.md Documents caching and helper limitations.
package.json Adds syntax checking for the helper.

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

Exercise the production PowerShell validator with mixed-case App URLs and invalid suffixes while stubbing only the OS launch.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

Copilot review overview

🟢 Approval recommended

The cache and helper lifecycles preserve validation and failure semantics with comprehensive regression coverage.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@user3301
user3301 merged commit f394f87 into main Oct 2, 2026
3 checks passed
@user3301
user3301 deleted the perf-agent-navigation branch October 2, 2026 04:33
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