Skip to content

fix: improve mobile link modifier handling - #5597

Merged
Jinwoo-H merged 4 commits into
stablyai:mainfrom
carlosbaraza:carlosbaraza/add-cmd-key-option
Jun 18, 2026
Merged

Jinwoo-H merged 4 commits into
stablyai:mainfrom
carlosbaraza:carlosbaraza/add-cmd-key-option

Conversation

@carlosbaraza

@carlosbaraza carlosbaraza commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

HUMAN VERIFIED

Summary

Fixes mobile link opening from terminal sessions and browser panes when the desktop host is macOS. The PR adds the missing Cmd modifier path and preserves OSC 8 URL metadata so first-load terminal links are tappable before any scroll repaint.

Changes

  • Add Cmd as a default terminal shortcut key after Arrow Right
  • Add mobile browser pointer modifier controls for Cmd, Ctrl, Alt, and Shift clicks
  • Send pointer modifiers through browser RPC/CDP mouse events
  • Preserve OSC 8 link ranges in headless terminal snapshots and use them during mobile initial replay
  • Focus the newly created browser tab when a terminal link opens from mobile
  • Split large mobile terminal/browser code into focused modules

Testing

  • pnpm exec oxlint on touched files
  • pnpm exec oxfmt --check on touched files
  • pnpm vitest run mobile/src/terminal/terminal-accessory-keys.test.ts src/main/browser/agent-browser-bridge.test.ts src/main/daemon/headless-emulator.test.ts --config config/vitest.config.ts
  • pnpm run typecheck:node
  • pnpm exec tsc --noEmit in mobile/
  • Manual simulator test: first-load Claude terminal links open the Orca browser without scrolling first

Open in Stage

@ghost

ghost commented Jun 17, 2026 •

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR implements end-to-end OSC 8 hyperlink support in the mobile terminal: a new TerminalOscLinkRange type is defined in a shared module, extracted from the headless xterm emulator via a private _oscLinkService scan, persisted in checkpoint history, propagated through all serializeTerminalBuffer and terminal.subscribe snapshot RPC paths, forwarded to the mobile TerminalWebView via an extended init(...) API, and resolved during tap gestures using a new near-cell URL lookup with an initialOscLinks fallback. On the desktop, the isTerminalLinkActivation modifier gate is removed from handleOscLink so ordinary clicks always route OSC 8 links, and open-hint strings are updated from ⌘+click/Ctrl+click to ⇧+click/Shift+click wording. In parallel, the mobile browser pane gains pointer modifier key UI (MobileBrowserPointerModifiers, MobileBrowserKeyRow) backed by a cdpMouseModifierMask bitmask forwarded through AgentBrowserBridge.mouseClick. The terminal accessory row refactors to use direct modifiers.includes() checks, removes the hasModifier helper, and adds a Cmd modifier key entry with optional bytes typing.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.82% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'fix: improve mobile link modifier handling' directly and specifically describes the core change: adding mobile browser pointer modifier support and fixing link opening on macOS.
Description check ✅ Passed The PR description is comprehensive and complete. It provides a clear summary of the fix (mobile link opening on macOS), lists specific changes including Cmd modifier, browser pointer modifiers, OSC 8 link preservation, and browser tab focusing. Testing section confirms linting, type checking, and manual simulator testing were performed.
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.


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.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
mobile/src/browser/MobileBrowserPane.tsx (1)

655-690: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid downgrading modified clicks to plain clicks on fallback.

Line 661 sends modifiers through browser.mouseClick, but if that request fails, Lines 679-689 retry via mouseMove/mouseDown/mouseUp without modifiers. That can turn an intended Cmd/Ctrl-click into a plain click and trigger the wrong action.

💡 Suggested fix
-      if (clickResult !== null) {
+      if (clickResult !== null || pointerModifiers.length > 0) {
         return
       }

Also applies to: 697-697

🧹 Nitpick comments (2)
src/main/daemon/headless-osc-link-ranges.ts (1)

21-22: ⚡ Quick win

Document why private terminal internals are intentionally read here.

This extractor depends on non-public buffer/link internals; please add a short “Why” comment at the _oscLinkService and extended.urlId access points so future cleanup/refactors don’t accidentally break OSC range capture.

Suggested patch
 export function collectHeadlessOscLinkRanges(
   terminal: Terminal,
   scrollbackRows: number | undefined
 ): TerminalOscLinkRange[] {
+  // Why: headless xterm exposes OSC 8 metadata only via private core link service.
+  // Keep this boundary explicit so xterm upgrades are audited here.
   const service = (terminal as TerminalWithOscLinks)._core?._oscLinkService
   if (!service) {
     return []
   }
@@
 function getOscLinkIdAtCell(line: { getCell: (col: number) => unknown }, col: number): number {
   const cell = line.getCell(col) as CellWithOscLink | undefined
+  // Why: OSC link IDs are stored in extended cell attrs; missing attrs means no link.
   return cell?.hasExtendedAttrs?.() && cell.extended?.urlId ? cell.extended.urlId : 0
 }

As per coding guidelines, “When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does.”

Also applies to: 55-57

Source: Coding guidelines

mobile/app/h/[hostId]/session/[worktreeId].tsx (1)

3434-3442: 💤 Low value

Consider memoizing handleCreateBrowser to stabilize handleTerminalLink.

handleCreateBrowser is a regular async function that gets recreated on every render. Since handleTerminalLink depends on it, the callback also changes on every render, potentially causing unnecessary re-renders of TerminalPaneView.

This is a low-priority optimization since the mobile terminal already handles frequent prop updates, but worth noting for future cleanup.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5085b14c-339b-4692-bd79-3bd8b409e8b4

📥 Commits

Reviewing files that changed from the base of the PR and between 6cea158 and 699af226b3ec6dc31fa9ad36395ec4154615ad20.

📒 Files selected for processing (27)
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/src/browser/MobileBrowserKeyRow.tsx
  • mobile/src/browser/MobileBrowserPane.tsx
  • mobile/src/browser/MobileBrowserPointerModifiers.tsx
  • mobile/src/session/TerminalPaneView.tsx
  • mobile/src/terminal/TerminalWebView.tsx
  • mobile/src/terminal/default-terminal-theme.ts
  • mobile/src/terminal/terminal-accessory-keys.test.ts
  • mobile/src/terminal/terminal-accessory-keys.ts
  • mobile/src/terminal/terminal-osc-link-ranges.ts
  • mobile/src/terminal/terminal-webview-protocol.ts
  • mobile/src/terminal/terminal-webview-styles.ts
  • src/main/browser/agent-browser-bridge.test.ts
  • src/main/browser/agent-browser-bridge.ts
  • src/main/daemon/headless-emulator.test.ts
  • src/main/daemon/headless-emulator.ts
  • src/main/daemon/headless-osc-link-ranges.ts
  • src/main/daemon/types.ts
  • src/main/runtime/orca-runtime-browser.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/browser-extras.ts
  • src/main/runtime/rpc/methods/terminal.ts
  • src/renderer/src/components/terminal-pane/terminal-link-handlers.test.ts
  • src/renderer/src/components/terminal-pane/terminal-link-open-hints.ts
  • src/renderer/src/components/terminal-pane/terminal-osc-link-routing.ts
  • src/renderer/src/lib/pane-manager/pane-lifecycle.ts
  • src/shared/terminal-osc-link-ranges.ts

Comment thread mobile/src/terminal/TerminalWebView.tsx Outdated
Comment on lines 206 to 207
var initialOscLinks = [];
var mouseModeScanTail = '';

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Stale initialOscLinks rows can open the wrong URL after scrollback eviction.

initialOscLinks is captured once at init and then used as a row/col fallback, but row indices shift once xterm starts evicting lines (scrollback cap reached). At that point, fallback lookups can resolve taps against outdated ranges and misroute link opens.

💡 Proposed fix
@@
   var oscLinkService = null;
   var initialOscLinks = [];
+  var initialOscLinkRowOffset = 0;
@@
   function init(cols, rows, initialData, nextTheme, nextOscLinks) {
@@
     initialOscLinks = Array.isArray(nextOscLinks) ? nextOscLinks : [];
+    initialOscLinkRowOffset = 0;
@@
   function logFeedAndEvict() {
     linesEverWritten++;
+    if (isBufferFull()) initialOscLinkRowOffset += 1;
     if (selMode === 'select' && sel && isBufferFull()) {
       sel.anchor.row -= 1;
       sel.focus.row -= 1;
@@
   function getInitialOscLinkAtCell(row, col) {
     for (var i = 0; i < initialOscLinks.length; i++) {
       var link = initialOscLinks[i];
-      if (link && link.row === row && col >= link.startCol && col < link.endCol && typeof link.uri === 'string') return link.uri.trim();
+      if (!link || typeof link.uri !== 'string') continue;
+      if (link.row < initialOscLinkRowOffset) continue;
+      var shiftedRow = link.row - initialOscLinkRowOffset;
+      if (shiftedRow === row && col >= link.startCol && col < link.endCol) return link.uri.trim();
     } return '';
   }

Also applies to: 608-608, 1504-1509

Routes ordinary clicks on embedded terminal hyperlinks through Orca's existing link-routing policy instead of letting Electron open the system browser directly.

- Handle OSC 8 links without requiring Cmd/Ctrl-click
- Preserve Shift-click as the system browser/default app escape hatch
- Update terminal link hover hints and coverage for ordinary clicks
Adds the missing mobile controls needed to open links from macOS hosts and fixes first-load terminal links that visually rendered as links without carrying URL metadata.

- Add Cmd to the terminal shortcut bar after Arrow Right by default
- Add mobile browser pointer modifiers for Cmd, Ctrl, Alt, and Shift clicks
- Preserve OSC 8 link ranges in terminal snapshots for immediate mobile taps
- Focus newly created browser tabs after terminal link activation
- Split large mobile terminal/browser code into focused modules
@carlosbaraza
carlosbaraza force-pushed the carlosbaraza/add-cmd-key-option branch from 699af22 to 0cb22b6 Compare June 17, 2026 15:44

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 3

🧹 Nitpick comments (1)
mobile/src/terminal/terminal-webview-html.ts (1)

838-851: 💤 Low value

Consider resetting initialOscLinks on clear to avoid stale link state.

The clear handler resets mouse tracking state but leaves initialOscLinks and initialOscLinkRowOffset intact. While clear() is typically followed by init() which resets these, an explicit reset here would be more defensive.

💡 Optional fix
     } else if (msg.type === 'clear') {
       terminalGeneration++;
       resetWriteQueue();
       afterDrainCallbacks = [];
       writesDraining = false;
       mouseModeScanTail = ''; trackedMouseTrackingMode = 'none';
       sgrMouseMode = false; sgrMousePixelsMode = false;
+      initialOscLinks = []; initialOscLinkRowOffset = 0;
       if (term) { term.clear(); term.reset(); }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2077e047-3749-4175-a64b-3bea8bb5c7dc

📥 Commits

Reviewing files that changed from the base of the PR and between 699af226b3ec6dc31fa9ad36395ec4154615ad20 and 0cb22b6.

📒 Files selected for processing (20)
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/src/browser/MobileBrowserKeyRow.tsx
  • mobile/src/browser/MobileBrowserPane.tsx
  • mobile/src/browser/MobileBrowserPointerModifiers.tsx
  • mobile/src/terminal/TerminalWebView.tsx
  • mobile/src/terminal/terminal-accessory-keys.test.ts
  • mobile/src/terminal/terminal-accessory-keys.ts
  • mobile/src/terminal/terminal-osc-link-ranges.ts
  • mobile/src/terminal/terminal-webview-html.ts
  • mobile/src/terminal/terminal-webview-messages.ts
  • mobile/src/terminal/terminal-webview-url-tap.ts
  • src/main/browser/agent-browser-bridge.test.ts
  • src/main/browser/agent-browser-bridge.ts
  • src/main/daemon/headless-emulator.test.ts
  • src/main/daemon/headless-emulator.ts
  • src/main/daemon/headless-osc-link-ranges.ts
  • src/main/daemon/types.ts
  • src/main/runtime/orca-runtime-browser.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/browser-extras.ts
💤 Files with no reviewable changes (7)
  • src/main/daemon/headless-emulator.test.ts
  • src/main/daemon/types.ts
  • src/main/runtime/orca-runtime-browser.ts
  • src/main/daemon/headless-emulator.ts
  • src/main/runtime/rpc/methods/browser-extras.ts
  • src/main/daemon/headless-osc-link-ranges.ts
  • src/main/runtime/orca-runtime.ts
✅ Files skipped from review due to trivial changes (1)
  • mobile/src/terminal/terminal-webview-messages.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • mobile/src/terminal/terminal-accessory-keys.test.ts
  • mobile/src/browser/MobileBrowserPointerModifiers.tsx
  • mobile/src/browser/MobileBrowserKeyRow.tsx
  • src/main/browser/agent-browser-bridge.ts
  • mobile/src/terminal/terminal-accessory-keys.ts
  • mobile/src/terminal/terminal-osc-link-ranges.ts

@coderabbitai coderabbitai Bot left a comment

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.

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: 3

🧹 Nitpick comments (1)
mobile/src/terminal/terminal-webview-html.ts (1)

838-851: 💤 Low value

Consider resetting initialOscLinks on clear to avoid stale link state.

The clear handler resets mouse tracking state but leaves initialOscLinks and initialOscLinkRowOffset intact. While clear() is typically followed by init() which resets these, an explicit reset here would be more defensive.

💡 Optional fix
     } else if (msg.type === 'clear') {
       terminalGeneration++;
       resetWriteQueue();
       afterDrainCallbacks = [];
       writesDraining = false;
       mouseModeScanTail = ''; trackedMouseTrackingMode = 'none';
       sgrMouseMode = false; sgrMousePixelsMode = false;
+      initialOscLinks = []; initialOscLinkRowOffset = 0;
       if (term) { term.clear(); term.reset(); }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2077e047-3749-4175-a64b-3bea8bb5c7dc

📥 Commits

Reviewing files that changed from the base of the PR and between 699af226b3ec6dc31fa9ad36395ec4154615ad20 and 0cb22b6.

📒 Files selected for processing (20)
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/src/browser/MobileBrowserKeyRow.tsx
  • mobile/src/browser/MobileBrowserPane.tsx
  • mobile/src/browser/MobileBrowserPointerModifiers.tsx
  • mobile/src/terminal/TerminalWebView.tsx
  • mobile/src/terminal/terminal-accessory-keys.test.ts
  • mobile/src/terminal/terminal-accessory-keys.ts
  • mobile/src/terminal/terminal-osc-link-ranges.ts
  • mobile/src/terminal/terminal-webview-html.ts
  • mobile/src/terminal/terminal-webview-messages.ts
  • mobile/src/terminal/terminal-webview-url-tap.ts
  • src/main/browser/agent-browser-bridge.test.ts
  • src/main/browser/agent-browser-bridge.ts
  • src/main/daemon/headless-emulator.test.ts
  • src/main/daemon/headless-emulator.ts
  • src/main/daemon/headless-osc-link-ranges.ts
  • src/main/daemon/types.ts
  • src/main/runtime/orca-runtime-browser.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/browser-extras.ts
💤 Files with no reviewable changes (7)
  • src/main/daemon/headless-emulator.test.ts
  • src/main/daemon/types.ts
  • src/main/runtime/orca-runtime-browser.ts
  • src/main/daemon/headless-emulator.ts
  • src/main/runtime/rpc/methods/browser-extras.ts
  • src/main/daemon/headless-osc-link-ranges.ts
  • src/main/runtime/orca-runtime.ts
✅ Files skipped from review due to trivial changes (1)
  • mobile/src/terminal/terminal-webview-messages.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • mobile/src/terminal/terminal-accessory-keys.test.ts
  • mobile/src/browser/MobileBrowserPointerModifiers.tsx
  • mobile/src/browser/MobileBrowserKeyRow.tsx
  • src/main/browser/agent-browser-bridge.ts
  • mobile/src/terminal/terminal-accessory-keys.ts
  • mobile/src/terminal/terminal-osc-link-ranges.ts
🛑 Comments failed to post (3)
mobile/app/h/[hostId]/session/[worktreeId].tsx (2)

2869-2917: ⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, locate and read the file
fd -t f "worktreeId\].tsx" --max-one-result

Repository: stablyai/orca

Length of output: 291


🏁 Script executed:

# Get file size to determine how to read it
wc -l "mobile/app/h/[hostId]/session/[worktreeId].tsx"

Repository: stablyai/orca

Length of output: 109


🏁 Script executed:

# Read the relevant section (lines 2869-2931)
sed -n '2869,2931p' "mobile/app/h/[hostId]/session/[worktreeId].tsx"

Repository: stablyai/orca

Length of output: 2468


🏁 Script executed:

# Also check where handleCreateBrowser is defined
grep -n "const handleCreateBrowser\|function handleCreateBrowser" "mobile/app/h/[hostId]/session/[worktreeId].tsx"

Repository: stablyai/orca

Length of output: 143


🏁 Script executed:

# Check if handleCreateBrowser uses any dependencies that change frequently
sed -n '3691,3710p' "mobile/app/h/[hostId]/session/[worktreeId].tsx"

Repository: stablyai/orca

Length of output: 754


Add handleCreateBrowser to useCallback dependency arrays in both tap handlers.

Lines 2916 and 2930 omit handleCreateBrowser from their dependency arrays. Since this function is defined in component scope and uses client and creatingBrowser state, the memoized callbacks capture stale closures after these state changes, causing silent failures when firing subsequent taps.

Additionally, the file URL construction at line 2894 ('file://' + resolved.absolutePath) assumes forward slashes; on Windows, absolutePath will contain backslashes, creating invalid file:// URLs. Use a path utility or normalize the path to forward slashes before constructing the URL.

💡 Suggested fixes
   const handleFileTap = useCallback(
@@
-    [client, worktreeId, scheduleDelayedAction, fetchSessionTabs]
+    [client, worktreeId, scheduleDelayedAction, fetchSessionTabs, handleCreateBrowser]
   )

   const handleTerminalOpenUrl = useCallback(
@@
-    [terminalLinkOpenMode]
+    [terminalLinkOpenMode, handleCreateBrowser]
   )

For the file URL construction, ensure the path uses forward slashes:

-            void handleCreateBrowser('file://' + resolved.absolutePath)
+            void handleCreateBrowser('file://' + resolved.absolutePath.replaceAll('\\', '/'))
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  const handleFileTap = useCallback(
    (handle: string, pathText: string) => {
      if (handle !== activeHandleRef.current || !client) {
        return
      }
      void (async () => {
        try {
          const worktree = `id:${worktreeId}`
          const response = await client.sendRequest(
            'files.resolveTerminalPath',
            { worktree, pathText },
            { timeoutMs: 10_000 }
          )
          if (!response.ok) {
            return
          }
          const resolved = (response as RpcSuccess).result as RuntimeTerminalPathResolution
          if (!resolved.exists || resolved.isDirectory || !resolved.relativePath) {
            return
          }
          // Confirm the tap landed on something openable before giving feedback.
          triggerSelection()
          // Why: HTML opens in a browser pane (streamed from the desktop),
          // matching desktop's terminal-click behavior, instead of a file view.
          if (classifyMobileArtifact(resolved.relativePath) === 'html' && resolved.absolutePath) {
            void handleCreateBrowser('file://' + resolved.absolutePath)
            return
          }
          const openResponse = await client.sendRequest(
            'files.open',
            { worktree, relativePath: resolved.relativePath },
            { timeoutMs: 15_000 }
          )
          if (!openResponse.ok) {
            return
          }
          // Why: the desktop creates the file tab asynchronously; a single poll
          // can race it, so refresh a few times to reliably pick it up and
          // switch to it (the file browser gets this for free via router.back).
          scheduleDelayedAction(() => void fetchSessionTabs(), 300)
          scheduleDelayedAction(() => void fetchSessionTabs(), 900)
          scheduleDelayedAction(() => void fetchSessionTabs(), 1800)
        } catch {
          // Resolution/open is best-effort; a failed tap silently no-ops.
        }
      })()
    },
    [client, worktreeId, scheduleDelayedAction, fetchSessionTabs, handleCreateBrowser]
  )
  const handleFileTap = useCallback(
    (handle: string, pathText: string) => {
      if (handle !== activeHandleRef.current || !client) {
        return
      }
      void (async () => {
        try {
          const worktree = `id:${worktreeId}`
          const response = await client.sendRequest(
            'files.resolveTerminalPath',
            { worktree, pathText },
            { timeoutMs: 10_000 }
          )
          if (!response.ok) {
            return
          }
          const resolved = (response as RpcSuccess).result as RuntimeTerminalPathResolution
          if (!resolved.exists || resolved.isDirectory || !resolved.relativePath) {
            return
          }
          // Confirm the tap landed on something openable before giving feedback.
          triggerSelection()
          // Why: HTML opens in a browser pane (streamed from the desktop),
          // matching desktop's terminal-click behavior, instead of a file view.
          if (classifyMobileArtifact(resolved.relativePath) === 'html' && resolved.absolutePath) {
            void handleCreateBrowser('file://' + resolved.absolutePath.replaceAll('\\', '/'))
            return
          }
          const openResponse = await client.sendRequest(
            'files.open',
            { worktree, relativePath: resolved.relativePath },
            { timeoutMs: 15_000 }
          )
          if (!openResponse.ok) {
            return
          }
          // Why: the desktop creates the file tab asynchronously; a single poll
          // can race it, so refresh a few times to reliably pick it up and
          // switch to it (the file browser gets this for free via router.back).
          scheduleDelayedAction(() => void fetchSessionTabs(), 300)
          scheduleDelayedAction(() => void fetchSessionTabs(), 900)
          scheduleDelayedAction(() => void fetchSessionTabs(), 1800)
        } catch {
          // Resolution/open is best-effort; a failed tap silently no-ops.
        }
      })()
    },
    [client, worktreeId, scheduleDelayedAction, fetchSessionTabs]
  )

2891-2895: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Avoid string-building file:// URLs from absolute paths.

Line 2894 uses 'file://' + resolved.absolutePath, which is not path-safe across hosts (Windows separators/drive letters, escaping). This can break HTML-tab opening from terminal file taps.

💡 Suggested direction
-          if (classifyMobileArtifact(resolved.relativePath) === 'html' && resolved.absolutePath) {
-            void handleCreateBrowser('file://' + resolved.absolutePath)
+          if (classifyMobileArtifact(resolved.relativePath) === 'html' && resolved.absolutePath) {
+            const normalized = resolved.absolutePath.replace(/\\/g, '/')
+            const rooted = normalized.startsWith('/') ? normalized : `/${normalized}`
+            const fileUrl = encodeURI(`file://${rooted}`)
+            void handleCreateBrowser(fileUrl)
             return
           }

As per coding guidelines, "Use path.join or Electron/Node path utilities for file paths — never assume / or \ for cross-platform compatibility."

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

          // Why: HTML opens in a browser pane (streamed from the desktop),
          // matching desktop's terminal-click behavior, instead of a file view.
          if (classifyMobileArtifact(resolved.relativePath) === 'html' && resolved.absolutePath) {
            const normalized = resolved.absolutePath.replace(/\\/g, '/')
            const rooted = normalized.startsWith('/') ? normalized : `/${normalized}`
            const fileUrl = encodeURI(`file://${rooted}`)
            void handleCreateBrowser(fileUrl)
            return

Source: Coding guidelines

mobile/src/browser/MobileBrowserPane.tsx (1)

675-676: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Modifier clicks can be dropped when browser.mouseClick returns null.

With the current guard, any active modifier skips fallback entirely, so taps can no-op if the primary click RPC returns null.

Suggested fix
-      if (clickResult !== null || pointerModifiers.length > 0) {
+      if (clickResult !== null) {
         return
       }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

      if (clickResult !== null) {
        return

@AmethystLiang
AmethystLiang requested a review from Jinwoo-H June 17, 2026 17:44
@AmethystLiang AmethystLiang added P1 bug Something isn't working labels Jun 17, 2026
carlosbaraza and others added 2 commits June 18, 2026 22:28
* upstream/main: (78 commits)
  Show and Filter Automation-Created Workspaces (stablyai#5697)
  Fix premature project header truncation
  Send review notes to any running agent of a worktree (stablyai#5654)
  Fix workspace sidebar appearance setting (stablyai#5725)
  Highlight the open file in the Source Control sidebar (stablyai#5667)
  release: v1.4.80-rc.1
  Fix premature Codex completion notifications (stablyai#5682)
  Improve Codex startup prompt reliability (stablyai#5686)
  Keep hibernated agent completions visible (stablyai#5689)
  Move Prompt Cache Timer setting to Agents pane, simplify expired state (stablyai#5691)
  release: v1.4.80-rc.0
  Skip GitHub CLI preflight checks if no GitHub projects exist
  fix: restore font family keyboard navigation in settings
  Update README downloads badge
  fix(landing): make GitHub CLI setup nudge dismissible and provider-aware (stablyai#5688)
  Fix nested workspace card indentation (stablyai#5684)
  Fix flaky e2e tests (stablyai#5680)
  Replace plus icon with play button on quick command entry (stablyai#5674)
  Use managed Pi and OMP extensions (stablyai#5681)
  Narrow computer-use e2e trigger (stablyai#5685)
  ...

# Conflicts:
#	mobile/app/h/[hostId]/session/[worktreeId].tsx
#	mobile/src/terminal/TerminalWebView.tsx
#	mobile/src/terminal/terminal-webview-html.ts

@Jinwoo-H Jinwoo-H left a comment

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.

Thanks! I reviewed this and added follow-up fixes for the terminal/browser link edge cases:

  • preserve OSC link metadata through replay, resize, checkpoint, and cold restore
  • keep ordinary HTTP/OSC clicks working without Cmd/Ctrl while preserving macOS Ctrl-click context menus
  • pass browser pointer modifiers through CDP without accidental DOM activation
  • cover the mobile tap routing, daemon restore, and renderer link fallback cases with regression tests

Validation passed: formatting, lint, root/mobile typechecks, targeted root/mobile vitest suites, and Electron launch smoke validation.

@coderabbitai coderabbitai Bot left a comment

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
mobile/src/terminal/terminal-accessory-keys.ts (1)

1-9: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Restore Cmd modifier support in terminal accessory key types.

TerminalAccessoryKey now requires bytes, and TerminalShortcutModifier no longer includes 'cmd'. That removes the ability to model a modifier-only Cmd key and prevents Cmd from flowing through normalized shortcut modifiers, which conflicts with the stated macOS Cmd-key behavior for this cohort.

Suggested fix
 export type TerminalAccessoryKey = {
   id: string
   label: string
-  bytes: string
+  bytes?: string
+  modifier?: 'cmd'
   accessibilityLabel?: string
   repeatable?: boolean
 }

-export type TerminalShortcutModifier = 'ctrl' | 'alt' | 'shift'
+export type TerminalShortcutModifier = 'cmd' | 'ctrl' | 'alt' | 'shift'

Also applies to: 379-381

mobile/app/h/[hostId]/session/[worktreeId].tsx (1)

4633-4637: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Guard accessory sends when bytes is missing.

Line 4636 and Line 4648 call handleAccessoryKey(key.bytes) without validating bytes. With modifier-style keys now supporting optional bytes in this PR stack, this path can pass undefined into terminal.send and silently fail under the current catch block.

💡 Suggested patch
                         onPressIn={() => {
-                          if (!key.repeatable) {
+                          if (!key.repeatable || typeof key.bytes !== 'string' || key.bytes.length === 0) {
                             return
                           }
                           void handleAccessoryKey(key.bytes)
                           startAccessoryRepeat(key.bytes)
                         }}
@@
                         onPress={() => {
-                          if (key.repeatable) {
+                          if (key.repeatable || typeof key.bytes !== 'string' || key.bytes.length === 0) {
                             return
                           }
                           void handleAccessoryKey(key.bytes)
                         }}

Also applies to: 4645-4648

src/main/daemon/headless-osc-link-ranges.ts (1)

25-27: ⚠️ Potential issue | 🟡 Minor

Move restored links processing outside the service check.

The early return at line 26 bypasses the restored links projection logic (lines 55–71), even though that logic doesn't depend on the service and only performs clamping and validation. In the degraded path when the service is unavailable, recovered OSC metadata from restoredLinks should still be included in the result.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e15c5dbc-584d-4a63-8e8a-14b3a242d7fd

📥 Commits

Reviewing files that changed from the base of the PR and between 0821267 and 1a86c4d.

📒 Files selected for processing (29)
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/src/terminal/terminal-accessory-keys.test.ts
  • mobile/src/terminal/terminal-accessory-keys.ts
  • mobile/src/terminal/terminal-webview-html.ts
  • mobile/src/terminal/terminal-webview-tap-routing.test.ts
  • mobile/src/terminal/terminal-webview-url-tap.ts
  • src/main/browser/agent-browser-bridge.test.ts
  • src/main/browser/agent-browser-bridge.ts
  • src/main/daemon/daemon-pty-adapter.test.ts
  • src/main/daemon/daemon-pty-adapter.ts
  • src/main/daemon/headless-emulator.test.ts
  • src/main/daemon/headless-emulator.ts
  • src/main/daemon/headless-osc-link-ranges.ts
  • src/main/daemon/history-manager.test.ts
  • src/main/daemon/history-manager.ts
  • src/main/daemon/history-reader.test.ts
  • src/main/daemon/history-reader.ts
  • src/main/daemon/terminal-history-incremental-restore.test.ts
  • src/main/daemon/types.ts
  • src/main/ipc/pty.test.ts
  • src/main/ipc/pty.ts
  • src/main/providers/types.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/terminal.ts
  • src/main/runtime/rpc/terminal-subscribe-buffer.test.ts
  • src/renderer/src/components/terminal-pane/terminal-link-handlers.test.ts
  • src/renderer/src/components/terminal-pane/terminal-link-open-hints.ts
  • src/renderer/src/components/terminal-pane/terminal-osc-link-routing.ts
  • src/renderer/src/components/terminal-pane/terminal-url-link-hit-testing.ts
✅ Files skipped from review due to trivial changes (1)
  • src/renderer/src/components/terminal-pane/terminal-link-open-hints.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • mobile/src/terminal/terminal-webview-html.ts
  • src/renderer/src/components/terminal-pane/terminal-osc-link-routing.ts
  • src/main/runtime/orca-runtime.ts

@Jinwoo-H
Jinwoo-H merged commit d46349c into stablyai:main Jun 18, 2026
5 checks passed
@Jinwoo-H Jinwoo-H mentioned this pull request Jun 19, 2026
3 tasks done
nwparker added a commit that referenced this pull request Sep 1, 2026
Cold restore seeded a checkpoint's OSC-8 link ranges and then replayed records
that resize, so any resize record after the checkpoint dropped them and
restored hyperlinks in scrollback lost clickability. Same-size resize records
reach the durable log routinely, because every attach re-asserts the pane's
dimensions and session-output-plane records each one without a same-size
dedupe — so an ordinary reattach was enough to lose the links.

Restored ranges are row-indexed, so clearing them on a reflow is right; a
resize to the size already applied is not a reflow. Gate on the dimensions
actually changing.

Introduced in d46349c ("fix: improve mobile link modifier handling",
#5597), which added setRestoredOscLinks along with unconditional clearing in
both resize() and clearScrollback(). clearScrollback's clearing is correct and
is unchanged, with a test pinning it.

Found during adversarial review of #17752 and filed as #17756. Not a
regression from that PR: #17667 had incidentally masked it by gating no-op
resizes to protect a snapshot cache, and removing the cache removed the gate.
The same gate returns here on its own terms — as a correctness fix with tests,
rather than as a side effect of a cache.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…lyai#17759)

Cold restore seeded a checkpoint's OSC-8 link ranges and then replayed records
that resize, so any resize record after the checkpoint dropped them and
restored hyperlinks in scrollback lost clickability. Same-size resize records
reach the durable log routinely, because every attach re-asserts the pane's
dimensions and session-output-plane records each one without a same-size
dedupe — so an ordinary reattach was enough to lose the links.

Restored ranges are row-indexed, so clearing them on a reflow is right; a
resize to the size already applied is not a reflow. Gate on the dimensions
actually changing.

Introduced in 10fe9a0 ("fix: improve mobile link modifier handling",
stablyai#5597), which added setRestoredOscLinks along with unconditional clearing in
both resize() and clearScrollback(). clearScrollback's clearing is correct and
is unchanged, with a test pinning it.

Found during adversarial review of stablyai#17752 and filed as stablyai#17756. Not a
regression from that PR: stablyai#17667 had incidentally masked it by gating no-op
resizes to protect a snapshot cache, and removing the cache removed the gate.
The same gate returns here on its own terms — as a correctness fix with tests,
rather than as a side effect of a cache.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants