Skip to content

Fix inline VS Code command palette and WebSocket startup - #5595

Merged
lawrencecchen merged 6 commits into
mainfrom
task-cmd-shift-p-inline-vscode-errors
Jun 8, 2026
Merged

lawrencecchen merged 6 commits into
mainfrom
task-cmd-shift-p-inline-vscode-errors

Conversation

@lawrencecchen

@lawrencecchen lawrencecchen commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Route Cmd-Shift-P to WebKit only when the focused browser page is cmux's tracked inline VS Code serve-web origin.
  • Prefer VS Code's cached direct code-server binary for inline VS Code startup; keep code-tunnel serve-web as the cache-miss fallback.
  • Preserve cmux's command palette for untracked localhost pages and unrelated shortcuts.

Root cause

  • WKWebView is not the compression problem: direct cached code-server works in WKWebView with normal WebSocket negotiation.
  • The failing path is the native code-tunnel serve-web wrapper. In verbose mode it logs server (upgrade expected but low level API in use) websocket upgrade failed; the browser sees the WebSocket open, sends the first VS Code auth frame, then gets a 1006 close and later reports the remote-connection handshake timeout.
  • Launching direct code-server bypasses that wrapper bridge and lets the Management and ExtensionHost sockets complete.

Testing

  • git diff --check HEAD~4..HEAD
  • ./scripts/ensure-ghosttykit.sh && xcodebuild -project cmux.xcodeproj -scheme cmux-unit -configuration Debug -destination 'platform=macOS' -derivedDataPath /tmp/cmux-cvix-rootcause test -only-testing:cmuxTests/VSCodeCLILaunchConfigurationBuilderTests -only-testing:cmuxTests/VSCodeServeWebURLBuilderTests -only-testing:cmuxTests/AppDelegateShortcutRoutingTests/testInlineVSCodeCommandPaletteShortcutRoutesThroughWebContentForTrackedServeWebOrigin -only-testing:cmuxTests/AppDelegateShortcutRoutingTests/testInlineVSCodeCommandPaletteShortcutDoesNotRouteForUntrackedLocalhostPage -only-testing:cmuxTests/AppDelegateShortcutRoutingTests/testInlineVSCodeCommandPaletteShortcutDoesNotRouteUnrelatedShortcut
  • ./scripts/reload-cloud.sh --tag cvrx
  • cvrx WKWebView verification on surface:2: direct cached code-server loaded /Users/lawrence/fun; Management and ExtensionHost sockets connected; browser errors list returned No browser errors.

Regression commits


Note

Medium Risk
Changes inline VS Code process launch and global Cmd+Shift+P routing; origin matching limits palette regressions but WebSocket/startup behavior still depends on the new binary selection path.

Overview
Fixes inline VS Code by changing how serve-web is launched and how Cmd+Shift+P is routed.

Launch: VSCodeCLILaunchConfigurationBuilder now prefers VS Code’s cached code-server binary under the user data folder’s cli/serve-web cache (honoring lru.json, then newest executable), and only falls back to code-tunnel with a serve-web argument prefix when no cache hit. Direct code-server runs without ELECTRON_RUN_AS_NODE; the tunnel wrapper still sets it. VSCodeServeWebController builds process arguments from that prefix instead of always embedding serve-web. Inline availability checks only that code-tunnel exists (no cache scan on menu/palette).

Shortcuts: When the focused browser URL matches the tracked serve-web loopback origin (VSCodeServeWebController.isServeWebURL), the configured command-palette shortcut is forwarded to WebKit in CmuxWebView and not handled by cmux’s app-level palette in AppDelegate. Other localhost pages and non-palette shortcuts are unchanged.

Tests cover launch binary selection and shortcut routing boundaries.

Reviewed by Cursor Bugbot for commit 7e40494. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • New Features

    • Inline VS Code command-palette shortcuts are now routed to in-page web content first when appropriate, improving shortcut responsiveness.
    • Launch behavior for opening VS Code web content now prefers cached code-server binaries when available, falling back to the bundled tunnel otherwise for more reliable launches.
  • Tests

    • Added and updated tests covering command-palette routing and VS Code launch/binary selection behavior.

@vercel

vercel Bot commented Jun 8, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cmux Ready Ready Preview, Comment Jun 8, 2026 5:32am
cmux-staging Building Building Preview, Comment Jun 8, 2026 5:32am

@coderabbitai

coderabbitai Bot commented Jun 8, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 365a0e1f-d019-486e-80a8-2cec1c717658

📥 Commits

Reviewing files that changed from the base of the PR and between 9794961 and 7e40494.

📒 Files selected for processing (1)
  • Sources/App/TerminalDirectoryOpenSupport.swift

📝 Walkthrough

Walkthrough

Adds web-content-first routing for Inline VS Code command-palette shortcuts (Cmd/Cmd+Shift) when the focused page matches the serve-web origin, and refactors VSCode CLI launch configuration to prefer a cached code-server binary from serve-web caches with updated environment/arguments and tests.

Changes

Inline VS Code Command Palette Web-Content-First Routing

Layer / File(s) Summary
Loopback origin matching foundation
Sources/App/TerminalDirectoryOpenSupport.swift
VSCodeServeWebController adds urlsShareLoopbackOrigin(_:_:) and isServeWebURL(_:) to determine whether a page URL shares the serve-web loopback origin.
Inline VS Code command palette routing policy
Sources/App/ShortcutRoutingSupport.swift
shouldRouteInlineVSCodeCommandPaletteShortcutThroughWebContentFirst returns true when the event matches the configured .commandPalette shortcut and the page URL passes the loopback origin matcher.
AppDelegate shortcut dispatch integration
Sources/AppDelegate.swift
handleCustomShortcut short-circuits to yield to web-content-first routing when policy matches and there's no focused address bar.
CmuxWebView keyboard event forwarding
Sources/Panels/CmuxWebView.swift
performKeyEquivalent and keyDown forward matching shortcuts to WebKit (super) and return early, preventing cmux/app fallback handling.
Shortcut routing test validation
cmuxTests/AppDelegateShortcutRoutingTests.swift
Three tests validate routing for tracked serve-web origin, untracked localhost, and unrelated shortcuts.

Cached code-server launch selection

Layer / File(s) Summary
Launch configuration injection and cached selection
Sources/App/TerminalDirectoryOpenSupport.swift
VSCodeCLILaunchConfigurationBuilder.launchConfiguration(...) now accepts injected filesystem callbacks and may return a configuration that uses a cached code-server executable when discovered.
Cached serve-web discovery helpers
Sources/App/TerminalDirectoryOpenSupport.swift
Helpers read Resources/app/product.json, load cli/serve-web cache state and lru.json, apply path-component safety filters, and pick the most-recent executable candidate.
Serve-web launch integration
Sources/App/TerminalDirectoryOpenSupport.swift
launchServeWebProcess uses launchConfiguration.argumentsPrefix and the builder adjusts environment/arguments for cached code-server (e.g., remove ELECTRON_RUN_AS_NODE) or uses ["serve-web"] for code-tunnel; .vscodeInline availability uses a cheap bundled code-tunnel check.
Launch configuration tests
cmuxTests/OmnibarAndToolsTests.swift
Tests assert preference for cached code-server with environment cleanup; fallback test verifies code-tunnel path and ["serve-web"] argumentsPrefix.

Sequence Diagram

sequenceDiagram
  participant User
  participant CmuxWebView
  participant ShortcutRoutingSupport
  participant VSCodeServeWebController
  participant WebKit
  User->>CmuxWebView: Key press (Cmd/Cmd+Shift)
  CmuxWebView->>ShortcutRoutingSupport: shouldRouteInlineVSCodeCommandPaletteShortcutThroughWebContentFirst(event,pageURL)
  ShortcutRoutingSupport->>VSCodeServeWebController: isServeWebURL(pageURL)
  VSCodeServeWebController->>VSCodeServeWebController: urlsShareLoopbackOrigin(pageURL,serveWebURL)
  VSCodeServeWebController-->>ShortcutRoutingSupport: true
  ShortcutRoutingSupport-->>CmuxWebView: policy match (true)
  CmuxWebView->>WebKit: super.performKeyEquivalent / super.keyDown
  WebKit-->>User: Command palette handled in page
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • Ari4ka

Poem

🐰 I hopped a key from paw to page,

Forwarded to WebKit on the stage,
Loopback matched, the palette awoke,
Cached servers whispered in a yolk,
A rabbit cheers — shortcuts engage!

🚥 Pre-merge checks | ✅ 4 | ❌ 15

❌ Failed checks (1 warning, 14 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.69% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Cmux Swift Actor Isolation ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Cmux Swift Blocking Runtime ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Cmux No Hacky Sleeps ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Cmux Algorithmic Complexity ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Cmux Swift Concurrency ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Cmux Swift @Concurrent ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Cmux Swift File And Package Boundaries ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Cmux Swift Logging ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Cmux User-Facing Error Privacy ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Cmux Full Internationalization ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Cmux Swiftui State Layout ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Cmux Architecture Rethink ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Cmux Swift Auxiliary Window Close Shortcuts ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Cmux Source Artifacts ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix inline VS Code command palette and WebSocket startup' accurately summarizes the main changes: routing improvements for the command palette and WebSocket startup fixes via preferred binary selection.
Description check ✅ Passed The description is comprehensive and follows the template structure with Summary, Testing, and detailed context. All required sections are completed with clear information about what changed, why, and how it was tested.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch task-cmd-shift-p-inline-vscode-errors

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 659bd5a. Configure here.

Comment thread Sources/App/TerminalDirectoryOpenSupport.swift
Comment thread Sources/AppDelegate.swift
Comment thread Sources/Panels/CmuxWebView.swift

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 659bd5ac05

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +714 to +716
if shouldRouteInlineVSCodeCommandPaletteShortcutThroughWebContentFirst(event, pageURL: url) {
_ = super.performKeyEquivalent(with: event)
return finish(true)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Do not consume unclaimed VS Code shortcuts

When an inline VS Code page receives Cmd+Shift+P but WKWebView.performKeyEquivalent returns false, this branch still returns true, so AppKit will not continue to the later keyDown path that was added to forward the shortcut to WebKit. In that case the event is swallowed before either VS Code's DOM key handler or cmux's fallback can handle it; this matters for WebKit paths where arbitrary page shortcuts are delivered via keyDown rather than claimed as key equivalents. Preserve the super.performKeyEquivalent result or explicitly forward keyDown before marking the event handled.

Useful? React with 👍 / 👎.

@greptile-apps

greptile-apps Bot commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes two independent regressions in inline VS Code: WebSocket startup failures caused by the code-tunnel serve-web wrapper, and Cmd+Shift+P being swallowed by cmux's command palette when the focused page is the live VS Code serve-web origin.

  • Launch path: VSCodeCLILaunchConfigurationBuilder now tries VS Code's cached code-server binary first (reading lru.json with mtime fallback), with code-tunnel serve-web kept as the fallback. serve-web is moved from a hard-coded argument into the code-tunnel-only argumentsPrefix, and ELECTRON_RUN_AS_NODE is omitted on the direct code-server path.
  • Shortcut routing: A new shouldRouteInlineVSCodeCommandPaletteShortcutThroughWebContentFirst predicate gates on VSCodeServeWebController.isServeWebURL (loopback host + port match against the tracked serve-web URL). Both AppDelegate and CmuxWebView consult this before acting on the command palette shortcut, so only the tracked VS Code origin intercepts Cmd+Shift+P — other localhost pages and unrelated shortcuts are unaffected.

Confidence Score: 5/5

Safe to merge. The changes are well-scoped, fully injectable for testing, and cover both the launch and shortcut routing paths with dedicated tests.

Both changed behaviours — VS Code binary selection and command palette shortcut routing — are exercised by new tests using injected dependencies. The shortcut routing is layered defensively across AppDelegate and both CmuxWebView hook points. The cached binary discovery gracefully falls back through lru.json → mtime scan → code-tunnel, and all path components are validated before use.

No files require special attention.

Important Files Changed

Filename Overview
Sources/App/TerminalDirectoryOpenSupport.swift VSCodeCLILaunchConfigurationBuilder now prefers a cached code-server binary (via lru.json or mtime fallback) over the code-tunnel wrapper, fixing WebSocket negotiation. isAvailable simplified to a single code-tunnel check with explicit comment. New isServeWebURL helper exposes tracked loopback origin check.
Sources/App/ShortcutRoutingSupport.swift Adds shouldRouteInlineVSCodeCommandPaletteShortcutThroughWebContentFirst — a small, fully-injectable routing predicate gating on the tracked serve-web URL and the configured command palette shortcut.
Sources/AppDelegate.swift Inserts an early-return false before matchConfiguredShortcut(.commandPalette) so AppDelegate does not consume Cmd+Shift+P when the focused browser page is the live VS Code serve-web origin.
Sources/Panels/CmuxWebView.swift Handles the command palette shortcut in both performKeyEquivalent and keyDown. The two checks are harmlessly redundant: once performKeyEquivalent returns true, keyDown is never called for that event.
cmuxTests/AppDelegateShortcutRoutingTests.swift Adds three focused tests covering tracked-origin, untracked-origin, and unrelated-shortcut cases using injectable closures.
cmuxTests/OmnibarAndToolsTests.swift Replaces the single launch-config test with two: lru.json-guided code-server selection and code-tunnel fallback, verifying argumentsPrefix and ELECTRON_RUN_AS_NODE in each case.

Sequence Diagram

sequenceDiagram
    participant User
    participant AppDelegate
    participant CmuxWebView
    participant VSCodeServeWebController
    participant WebKit

    Note over User,WebKit: Cmd+Shift+P while VS Code serve-web page is focused
    User->>AppDelegate: sendEvent (Cmd+Shift+P)
    AppDelegate->>VSCodeServeWebController: isServeWebURL(pageURL)
    VSCodeServeWebController-->>AppDelegate: true
    AppDelegate-->>AppDelegate: return false (don't consume)
    AppDelegate->>CmuxWebView: performKeyEquivalent
    CmuxWebView->>VSCodeServeWebController: isServeWebURL(url)
    VSCodeServeWebController-->>CmuxWebView: true
    CmuxWebView->>WebKit: super.performKeyEquivalent
    WebKit-->>CmuxWebView: handled
    CmuxWebView-->>AppDelegate: finish(true)
Loading

Reviews (5): Last reviewed commit: "Keep inline VS Code availability cheap" | Re-trigger Greptile

Comment on lines +547 to +553
func isServeWebURL(_ candidateURL: URL?) -> Bool {
guard let candidateURL else { return false }
let serveWebURL = queue.sync {
self.serveWebURL
}
return Self.urlsShareLoopbackOrigin(candidateURL, serveWebURL)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Blocking queue.sync on keyboard-event hot path

isServeWebURL is called on every keyboard shortcut evaluation from the main thread (via CmuxWebView.performKeyEquivalent and keyDown). The queue.sync blocks the main thread until the serial queue can service the read, turning every keystroke into a main-thread contention point. While the critical section is tiny, this pattern goes against the project's rule of avoiding new blocking synchronization in production Swift. The existing class already tracks serveWebURL behind a serial queue; an actor-isolated property (or a @MainActor-cached snapshot updated asynchronously when serveWebURL changes) would expose the same information without blocking the event-dispatch thread.

Rule Used: Flag new blocking or timing-based synchronization ... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Sources/App/TerminalDirectoryOpenSupport.swift`:
- Line 729: Add an inline comment immediately above the guard that reads "guard
lhs.port == rhs.port, lhs.port != nil else { return false }" in
TerminalDirectoryOpenSupport.swift explaining that we intentionally require
explicit, non-nil ports (rather than treating absent ports as default 80/443)
because this check targets VS Code serve-web instances which bind to ephemeral
explicit ports (e.g., 54321), so treating missing ports as defaults would be
incorrect for our use case.
- Around line 547-553: Add a doc comment for the new public method
isServeWebURL(_:) explaining its purpose: it checks whether the supplied URL
matches the origin of the currently running VS Code serve-web instance (i.e.,
compares loopback origin against the stored serveWebURL using
urlsShareLoopbackOrigin). Place the comment immediately above the
isServeWebURL(_:) declaration, describe parameters and return value (returns
true when the candidate URL shares the loopback origin with serveWebURL, false
otherwise), and note that nil candidateURL returns false.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4befe689-6731-43d7-9e2a-fe178b7cde89

📥 Commits

Reviewing files that changed from the base of the PR and between 7135f32 and 659bd5a.

📒 Files selected for processing (5)
  • Sources/App/ShortcutRoutingSupport.swift
  • Sources/App/TerminalDirectoryOpenSupport.swift
  • Sources/AppDelegate.swift
  • Sources/Panels/CmuxWebView.swift
  • cmuxTests/AppDelegateShortcutRoutingTests.swift

Comment on lines +547 to +553
func isServeWebURL(_ candidateURL: URL?) -> Bool {
guard let candidateURL else { return false }
let serveWebURL = queue.sync {
self.serveWebURL
}
return Self.urlsShareLoopbackOrigin(candidateURL, serveWebURL)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial | 💤 Low value

Add documentation for the new public method.

The isServeWebURL(_:) method is a new public API but lacks a doc comment explaining its purpose and behavior. A brief comment would clarify that it checks whether a given URL matches the origin of the currently-running VS Code serve-web instance.

📝 Suggested documentation
+    /// Returns `true` if the candidate URL shares the same loopback origin as the
+    /// currently running VS Code serve-web instance. Origin matching requires both
+    /// URLs to be HTTP with the same explicit port on loopback addresses.
+    ///
+    /// - Parameter candidateURL: The URL to test, typically a browser's current page URL.
+    /// - Returns: `true` if the candidate matches the serve-web origin, `false` otherwise.
     func isServeWebURL(_ candidateURL: URL?) -> Bool {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Sources/App/TerminalDirectoryOpenSupport.swift` around lines 547 - 553, Add a
doc comment for the new public method isServeWebURL(_:) explaining its purpose:
it checks whether the supplied URL matches the origin of the currently running
VS Code serve-web instance (i.e., compares loopback origin against the stored
serveWebURL using urlsShareLoopbackOrigin). Place the comment immediately above
the isServeWebURL(_:) declaration, describe parameters and return value (returns
true when the candidate URL shares the loopback origin with serveWebURL, false
otherwise), and note that nil candidateURL returns false.

rhs.scheme?.lowercased() == "http" else {
return false
}
guard lhs.port == rhs.port, lhs.port != nil else { return false }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial | 💤 Low value

Document the strict port requirement.

The port check requires both URLs to have explicit non-nil ports. This is stricter than typical origin comparison (which treats http://host/ as equivalent to http://host:80/). While this is appropriate for VS Code serve-web (which always binds to an ephemeral port like 54321), an inline comment would clarify why we require explicit ports rather than allowing default-port URLs.

📝 Suggested clarifying comment
+    // Require both URLs to have explicit non-nil ports. VS Code serve-web always
+    // binds to an ephemeral port (e.g., :54321), so both the stored serve-web URL
+    // and any matching browser navigation will have explicit ports. This strict
+    // check avoids false matches with default-port (implicit :80) localhost URLs.
     guard lhs.port == rhs.port, lhs.port != nil else { return false }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Sources/App/TerminalDirectoryOpenSupport.swift` at line 729, Add an inline
comment immediately above the guard that reads "guard lhs.port == rhs.port,
lhs.port != nil else { return false }" in TerminalDirectoryOpenSupport.swift
explaining that we intentionally require explicit, non-nil ports (rather than
treating absent ports as default 80/443) because this check targets VS Code
serve-web instances which bind to ephemeral explicit ports (e.g., 54321), so
treating missing ports as defaults would be incorrect for our use case.

@lawrencecchen lawrencecchen changed the title Let inline VS Code own Cmd-Shift-P Fix inline VS Code command palette and WebSocket handshake Jun 8, 2026
@lawrencecchen
lawrencecchen force-pushed the task-cmd-shift-p-inline-vscode-errors branch from 91cc595 to bfd5319 Compare June 8, 2026 04:15

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bfd531914d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 692 to 695
process.arguments = launchConfiguration.argumentsPrefix + [
"serve-web",
"--accept-server-license-terms",
"--host", "127.0.0.1",
"--port", "0",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Pass the WebSocket compression flag to VS Code

When the cached code-server path is selected, argumentsPrefix is empty and this shared list is the only place server flags are added. The PR summary says the handshake fix depends on --disable-websocket-compression, but neither the cached code-server nor the code-tunnel serve-web fallback receives that flag here, so the Management/ExtensionHost WebSockets can still negotiate compression and fail in the inline WKWebView path this change is meant to fix.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Sources/App/TerminalDirectoryOpenSupport.swift`:
- Around line 356-363: The availability check is performing heavy file I/O via
preferredCachedCodeServerURL during TerminalDirectoryOpenTarget.isAvailable
(which still calls launchConfiguration(...)); remove synchronous cache discovery
from the hot UI path by ensuring preferredCachedCodeServerURL is not called from
isAvailable: either (a) make isAvailable return quickly without invoking
preferredCachedCodeServerURL and let launchConfiguration/prepareLaunch
asynchronously query preferredCachedCodeServerURL off the main/UI queue, or (b)
change preferredCachedCodeServerURL to early-return nil when called on the UI
thread and schedule its full disk work on a background queue, then have
launchConfiguration observe the async result; update references in
TerminalDirectoryOpenSupport.swift (the calls around
preferredCachedCodeServerURL and the launchConfiguration invocation) accordingly
so all heavy file I/O (enumerating serve-web cache, reading
product.json/lru.json, stat-ing bin/code-server) happens off the UI isolation
path.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: bff73396-5608-497f-8224-6e54edd1c5cb

📥 Commits

Reviewing files that changed from the base of the PR and between 91cc595 and bfd5319.

📒 Files selected for processing (2)
  • Sources/App/TerminalDirectoryOpenSupport.swift
  • cmuxTests/OmnibarAndToolsTests.swift

Comment thread Sources/App/TerminalDirectoryOpenSupport.swift
@lawrencecchen lawrencecchen changed the title Fix inline VS Code command palette and WebSocket handshake Fix inline VS Code command palette and WebSocket startup Jun 8, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9794961afd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +424 to +425
if isExecutableAtPath(codeServerURL.path) {
return codeServerURL

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Verify cached server build before launching it

For users whose ~/.vscode/cli/serve-web cache contains an executable server from a different VS Code build (for example after code serve-web auto-downloaded a newer server while the installed app is still older), this returns the first LRU entry without checking that the cache id matches the current VS Code app commit. A mismatched direct code-server can still print the Web UI URL and then fail during startup, so launchServeWebProcess treats the launch as successful and never falls back to the wrapper path that would resolve the correct server.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Sources/AppDelegate.swift`:
- Around line 14514-14517: Pre-compute a Set of current tab IDs to avoid the
nested linear scan: create tabIds from tabManager.tabs (e.g., using map(\.id)
into a Set) and then redefine eligibleIds to filter candidateIds by checking
tabIds.contains(id) and !existingAnchorIds.contains(id); update the logic that
currently uses tabManager.tabs.contains(where:) so it uses tabIds.contains
instead.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: b18e66f9-9365-4bbb-9d87-cadbbaa87eb6

📥 Commits

Reviewing files that changed from the base of the PR and between bfd5319 and 9794961.

📒 Files selected for processing (1)
  • Sources/AppDelegate.swift

@coderabbitai coderabbitai Bot 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.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Sources/AppDelegate.swift`:
- Around line 14514-14517: Pre-compute a Set of current tab IDs to avoid the
nested linear scan: create tabIds from tabManager.tabs (e.g., using map(\.id)
into a Set) and then redefine eligibleIds to filter candidateIds by checking
tabIds.contains(id) and !existingAnchorIds.contains(id); update the logic that
currently uses tabManager.tabs.contains(where:) so it uses tabIds.contains
instead.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: b18e66f9-9365-4bbb-9d87-cadbbaa87eb6

📥 Commits

Reviewing files that changed from the base of the PR and between bfd5319 and 9794961.

📒 Files selected for processing (1)
  • Sources/AppDelegate.swift
🛑 Comments failed to post (1)
Sources/AppDelegate.swift (1)

14514-14517: 🧹 Nitpick | 🔵 Trivial | 💤 Low value

Consider pre-computing tab IDs as a Set to avoid O(n×m) complexity.

The filter performs a linear contains(where:) scan of tabManager.tabs for each candidate ID. While the practical impact is minimal given that candidateIds is typically small (user-selected workspaces), the pattern can be optimized:

let tabIds = Set(tabManager.tabs.map(\.id))
let eligibleIds = candidateIds.filter { id in
    tabIds.contains(id) && !existingAnchorIds.contains(id)
}

This reduces complexity from O(n×m) to O(n+m).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Sources/AppDelegate.swift` around lines 14514 - 14517, Pre-compute a Set of
current tab IDs to avoid the nested linear scan: create tabIds from
tabManager.tabs (e.g., using map(\.id) into a Set) and then redefine eligibleIds
to filter candidateIds by checking tabIds.contains(id) and
!existingAnchorIds.contains(id); update the logic that currently uses
tabManager.tabs.contains(where:) so it uses tabIds.contains instead.

Source: Coding guidelines

This branch was successfully deployed

1 active deployment
Preview – cmux — 7e404948 Deployed Jun 8, 2026 by vercel[bot]
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.

1 participant