Repository navigation
fix(mobile): choose host for new workspace - #11647
Conversation
Greptile SummaryThis 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
Confidence Score: 5/5Safe 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.
|
| 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]
Reviews (6): Last reviewed commit: "fix(mobile): handle opaque host endpoint..." | Re-trigger Greptile
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughExtracted mobile home quick actions into 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
mobile/src/components/MobileHomeQuickActions.test.ts (1)
1-2: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winPrefer React Native Testing Library for new tests.
@testing-library/react-nativeis available, and React 19’s rendered-tree internals are deprecated, so these tests should avoidreact-test-rendererwhen 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
📒 Files selected for processing (4)
mobile/app/index.tsxmobile/src/components/MobileHomeQuickActions.test.tsmobile/src/components/MobileHomeQuickActions.tsxmobile/src/transport/host-endpoint-label.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
mobile/src/components/MobileHomeQuickActions.test.ts (1)
59-66: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftAvoid adding more usage of deprecated
react-test-renderer.React 19.2.6 deprecates
react-test-renderer. This setup callscreateand suppresses its warning. Prefer@testing-library/react-nativefor 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
📒 Files selected for processing (2)
mobile/src/components/MobileHomeQuickActions.test.tsmobile/src/components/MobileHomeQuickActions.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- mobile/src/components/MobileHomeQuickActions.tsx
| 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() |
There was a problem hiding this comment.
🩺 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.
| 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() | |
| } |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
mobile/src/components/MobileHomeQuickActions.test.ts (1)
145-157: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick winAdd 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
📒 Files selected for processing (3)
mobile/src/components/MobileHomeQuickActions.test.tsmobile/src/components/MobileHomeQuickActions.tsxmobile/src/transport/host-endpoint-label.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- mobile/src/components/MobileHomeQuickActions.tsx
|
Mobile simulator QA on the granted iPhone 17 Pro: Zero connected hosts
Current-branch dev-client retry
Native mobile QA proofThe 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. 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. |
|
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. |
* 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







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
What changed
Verification