Skip to content

fix(mobile): choose host for new workspace - #11647

Merged
brennanb2025 merged 10 commits into
mainfrom
brennanb2025/mobile-new-workspace-host-picker
Aug 6, 2026
Merged

brennanb2025 merged 10 commits into
mainfrom
brennanb2025/mobile-new-workspace-host-picker

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

What this fixes

The mobile New Workspace quick action did not make it clear which connected desktop would create the workspace when more than one desktop was available.

Before / after

  • No connected desktops: the action remains disabled.
  • One connected desktop: tapping New Workspace opens the creation flow directly on that desktop.
  • Multiple connected desktops: tapping it first opens a host picker, then creates the workspace on the desktop the user chose.

What changed

  • Build the action from the currently connected host set.
  • Add a host picker when the destination is ambiguous.
  • Show each desktop's endpoint in the picker so similarly named hosts can be distinguished.
  • Preserve the selected host through the workspace-creation route.

Verification

  • Focused quick-action and host-selection tests passed.
  • Mobile typecheck, lint, and formatting passed.
  • Verified the quick-action layout, picker, and accessibility roles on iPad.

@greptile-apps

greptile-apps Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR fixes the mobile New Workspace quick action to correctly handle multiple connected desktops. Previously the action always routed to whichever desktop happened to be first in the sorted list; now it presents a PickerModal host selector when more than one desktop is connected.

  • Multi-host picker: MobileHomeQuickActions replaces the inline quick-actions JSX in index.tsx; it directly invokes onCreateWorkspace for a single connected host and opens a PickerModal for two or more, with collision-aware subtitles that fall back to appending host.id when name+endpoint still collide.
  • Stale-picker safety: The outer MobileHomeQuickActions wrapper re-keys MobileHomeQuickActionsContent whenever the connected-host set changes, resetting hostPickerVisible to false and preventing a picker addressed at a now-gone host.
  • Endpoint label hardening: hostEndpointLabel (extracted to its own module) strips URL paths and query strings before display, preventing bearer tokens embedded in WebSocket paths from appearing in the picker UI.

Confidence Score: 5/5

Safe to merge — the change is well-scoped, the new component is fully unit-tested, and the endpoint-label helper correctly strips sensitive path segments from display.

The logic for 0/1/N host routing is straightforward and backed by dedicated tests for each branch. The key-based remount strategy cleanly handles stale-picker state without custom effects. No data is mutated; the change is additive UI routing logic.

Files Needing Attention: No files require special attention.

Important Files Changed

Filename Overview
mobile/src/components/MobileHomeQuickActions.tsx New component that encapsulates the Quick Actions section; adds host-picker flow for multi-host selection, uses key-based remounting to dismiss a stale picker when the connected-host set changes.
mobile/src/transport/host-endpoint-label.ts Extracts and hardens the endpoint-label helper: strips paths/query strings so bearer tokens in WebSocket paths are not exposed in the picker UI; returns 'Unknown endpoint' for non-parseable strings.
mobile/app/index.tsx Replaces inline quick-actions JSX with MobileHomeQuickActions component and passes the full connectedHosts array; also fixes a stale style reference (quickActionDisabled → taskHomeCardDisabled) and imports the shared hostEndpointLabel helper.
mobile/src/components/MobileHomeQuickActions.test.ts Comprehensive unit tests covering 0/1/N host scenarios, duplicate-name disambiguation, path/token redaction, and stale-picker closure; well-structured with clean setup/teardown.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User taps New Workspace] --> B{connectedHosts.length}
    B -->|0| C[Button disabled — no action]
    B -->|1| D[onCreateWorkspace called with only host ID]
    B -->|>1| E[HostPicker modal shown]
    E --> F{User action}
    F -->|Selects a host| G[onCreateWorkspace called with selected host ID]
    F -->|Dismisses picker| H[hostPickerVisible = false]
    G --> I[router.push to /h/:hostId?action=newWorktree]
    D --> I
    I --> J[Workspace creation screen]
    K[connectedHosts set changes while picker open] --> L[MobileHomeQuickActions remounts via key change]
    L --> M[hostPickerVisible resets to false — picker closed]
Loading

Reviews (6): Last reviewed commit: "fix(mobile): handle opaque host endpoint..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

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
📝 Walkthrough

Walkthrough

Extracted mobile home quick actions into MobileHomeQuickActions with Pair Desktop and host-aware New Workspace actions. Workspace creation is disabled without connected hosts, direct for one host, and picker-based for multiple hosts. Added shared endpoint label formatting, connected-host derivation, disabled task styling, integration wiring, and tests for host selection and picker reset behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the user-visible change and verification, but it omits the required Screenshots, Testing, AI Review Report, Security Audit, and Notes sections. Use the repository template headings and add the missing testing checklist, AI review and cross-platform confirmation, security audit, screenshots statement, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main mobile change: selecting a host for new workspace creation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

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

🧹 Nitpick comments (1)
mobile/src/components/MobileHomeQuickActions.test.ts (1)

1-2: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Prefer React Native Testing Library for new tests.

@testing-library/react-native is available, and React 19’s rendered-tree internals are deprecated, so these tests should avoid react-test-renderer when the project already supports RTL.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f58cbf8b-3946-4cca-906f-7e4c3f3e96a3

📥 Commits

Reviewing files that changed from the base of the PR and between 8eee7f0 and fc3afcb.

📒 Files selected for processing (4)
  • mobile/app/index.tsx
  • mobile/src/components/MobileHomeQuickActions.test.ts
  • mobile/src/components/MobileHomeQuickActions.tsx
  • mobile/src/transport/host-endpoint-label.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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
mobile/src/components/MobileHomeQuickActions.test.ts (1)

59-66: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Avoid adding more usage of deprecated react-test-renderer.

React 19.2.6 deprecates react-test-renderer. This setup calls create and suppresses its warning. Prefer @testing-library/react-native for new component tests, or confirm that this migration is tracked separately.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 77a5a3c9-8afc-43ea-9dbd-4adbb80ca7d5

📥 Commits

Reviewing files that changed from the base of the PR and between fc3afcb and 82334ae.

📒 Files selected for processing (2)
  • mobile/src/components/MobileHomeQuickActions.test.ts
  • mobile/src/components/MobileHomeQuickActions.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • mobile/src/components/MobileHomeQuickActions.tsx

Comment on lines +59 to +67
const consoleError = vi.spyOn(console, 'error').mockImplementation((...args) => {
if (typeof args[0] !== 'string' || !args[0].includes('react-test-renderer is deprecated')) {
throw new Error(String(args[0]))
}
})
await act(async () => {
renderer = create(quickActions(connectedHosts))
})
consoleError.mockRestore()

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Restore the console.error spy when setup fails.

If create or act throws, execution skips consoleError.mockRestore(). The mock can then affect later tests. Restore it in a finally block.

Proposed fix
-    await act(async () => {
-      renderer = create(quickActions(connectedHosts))
-    })
-    consoleError.mockRestore()
+    try {
+      await act(async () => {
+        renderer = create(quickActions(connectedHosts))
+      })
+    } finally {
+      consoleError.mockRestore()
+    }
📝 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.

Suggested change
const consoleError = vi.spyOn(console, 'error').mockImplementation((...args) => {
if (typeof args[0] !== 'string' || !args[0].includes('react-test-renderer is deprecated')) {
throw new Error(String(args[0]))
}
})
await act(async () => {
renderer = create(quickActions(connectedHosts))
})
consoleError.mockRestore()
const consoleError = vi.spyOn(console, 'error').mockImplementation((...args) => {
if (typeof args[0] !== 'string' || !args[0].includes('react-test-renderer is deprecated')) {
throw new Error(String(args[0]))
}
})
try {
await act(async () => {
renderer = create(quickActions(connectedHosts))
})
} finally {
consoleError.mockRestore()
}

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

🧹 Nitpick comments (1)
mobile/src/components/MobileHomeQuickActions.test.ts (1)

145-157: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Add a valid query-string regression case.

The fixtures on Line 147 and Line 148 are malformed or hostless. They do not exercise a valid URL with a query string. Add a valid wss://...?... endpoint and assert that the subtitle contains only the hostname and optional port.

Based on the PR objectives, endpoint paths and bearer/query secrets must remain private.

Suggested coverage
     await renderQuickActions([
       host('desk-a', 'Desk', 'gateway.example.com/v1/connect/bearer-secret?token=query-secret'),
-      host('desk-b', 'Desk', 'localhost:6768/private-secret')
+      host('desk-b', 'Desk', 'localhost:6768/private-secret'),
+      host('desk-c', 'Other', 'wss://gateway.example.com/v1/connect?token=query-secret')
     ])
...
       { value: 'desk-b', label: 'Desk', subtitle: 'Unknown endpoint · desk-b' }
+      { value: 'desk-c', label: 'Other', subtitle: 'gateway.example.com' }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3cafdd2a-8e18-449a-8c9b-91db5247f0ef

📥 Commits

Reviewing files that changed from the base of the PR and between 1366dc6 and 93f8859.

📒 Files selected for processing (3)
  • mobile/src/components/MobileHomeQuickActions.test.ts
  • mobile/src/components/MobileHomeQuickActions.tsx
  • mobile/src/transport/host-endpoint-label.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • mobile/src/components/MobileHomeQuickActions.tsx

@brennanb2025

brennanb2025 commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor Author

Mobile simulator QA on the granted iPhone 17 Pro:

Zero connected hosts

  • New Workspace is visibly disabled and reports enabled: false through accessibility; Pair Desktop remains enabled.
  • Tapping the disabled action did not navigate or present a picker.

Zero connected hosts: New Workspace disabled

Current-branch dev-client retry

  • Retested head 58174fbb86 on iOS 26.5 / iPhone 17 Pro through Metro from this worktree; the bundle completed without a redbox.
  • Exactly one host was connected (Host 26, Direct / Tailscale). Accessibility reported New Workspace as an enabled button.
  • Tapping New Workspace opened the Create Workspace sheet directly on Host 26; no host picker appeared. The destination host remained visible behind the sheet.
  • The controlled environment did not provide a second connected host, so the multi-host picker still has automated/static coverage but no native screenshot in this run.

Current PR branch loaded with Host 26 connected

One connected host opens Create Workspace directly on Host 26

Native mobile QA proof

The prior multiple-connected-host native-QA gap is closed. On the exclusively granted iPhone 17 Pro (50FD514C-96F6-446E-AC90-D07A24CAB3A0), Orca emulator QA verified: zero connected hosts disables New Workspace (including AX enabled=false); one connected host opens Create Workspace directly and retains the selected host; two connected hosts opens an explicit Create Workspace On picker whose host rows are native AX buttons; choosing Host 29 waits for drawer close, opens the destination cleanly, and preserves Host 29 through navigation.

Zero connected hosts: New Workspace disabled

One connected host: direct Create Workspace flow

Two connected hosts: explicit accessible host picker

Chosen Host 29 preserved at Create Workspace destination

Fresh retry after the Orca restart reattached only the granted UDID and confirmed the production host profiles are present, but the restored ad-hoc simulator shell cannot unlock SecureStore/keychain entries (A required entitlement is not present), so reconnecting those production profiles was environment-limited. No credential contents were read or printed; the earlier controlled two-connected-host run above remains the valid proof.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@brennanb2025
brennanb2025 merged commit f6d0bde into main Aug 6, 2026
44 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* fix(mobile): choose host for new workspace

* fix(mobile): close stale workspace host picker

* fix(mobile): disambiguate workspace host choices

* fix(mobile): keep host endpoint paths private

* fix(mobile): redact invalid host endpoints

* fix(mobile): handle opaque host endpoints

* fix(mobile): announce host picker options

* fix(mobile): harden workspace host picker

* fix(mobile): preserve host through workspace creation
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