Repository navigation
fix(mobile): refresh folder workspaces in Home catalog - #11767
Conversation
|
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:
📝 WalkthroughWalkthroughFolder workspace create, update, and delete IPC handlers now use a dedicated catalog notification path when available. The path synchronizes the worktree watcher and retains the legacy repository notification as a fallback. Main-window service wiring passes runtime context to the handlers. Host worktree refreshes now queue overlapping requests, suppress superseded responses, and replay queued refreshes. New tests cover IPC mutations, request coordination, and refresh options. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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 |
Greptile SummaryWhen the paired host publishes a
Confidence Score: 5/5Safe to merge — the change is a one-line addition of an already-used read-only call in a single event handler, with no new state, timers, or dependencies. The diff is minimal and narrowly scoped: one new fetchWorktrees() invocation in the reposChanged branch of the event handler, and a matching test assertion. The call is purely read-only, uses no options that other call sites don't already omit, and follows the exact pattern of the worktreesChanged handler directly below it. No existing behavior is altered, and the regression test now covers the full contract of the handler for this event type. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| mobile/src/worktree/host-worktree-refresh.ts | Adds fetchWorktrees() call in the reposChanged handler so folder workspace catalog entries are refreshed alongside repo metadata when the host publishes the event. |
| mobile/src/worktree/host-worktree-refresh.test.ts | Extends the reposChanged regression test to assert both fetchWorktrees and fetchRepoMetadata are called, with mockClear() added before the event to get an accurate call count. |
Sequence Diagram
sequenceDiagram
participant Host as Remote Host
participant Stream as clientEvents Stream
participant Refresh as startHostWorktreeRefresh
participant WT as fetchWorktrees
participant RM as fetchRepoMetadata
Note over Host,RM: Folder workspace created on host
Host->>Stream: reposChanged event
Stream->>Refresh: event listener callback
Note over Refresh: event.type === 'reposChanged'
Refresh->>WT: fetchWorktrees() [NEW]
Refresh->>RM: "fetchRepoMetadata({ force: true, queueIfInFlight: true })"
WT-->>Refresh: catalog updated (folder workspace now visible)
RM-->>Refresh: repo metadata updated
Note over Host,RM: Git worktree change on host
Host->>Stream: worktreesChanged event
Stream->>Refresh: event listener callback
Note over Refresh: event.type === 'worktreesChanged'
Refresh->>WT: fetchWorktrees() [unchanged]
Reviews (7): Last reviewed commit: "fix(mobile): refresh folder workspace ca..." | Re-trigger Greptile
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 935c8076-0327-4aeb-abc6-fb09ecbb10bf
📒 Files selected for processing (2)
src/main/ipc/repos-folder-workspace.test.tssrc/main/window/attach-main-window-services.test.ts
| it('does not publish catalog notifications for missing update or delete targets', async () => { | ||
| mockStore.updateFolderWorkspace.mockReturnValue(null) | ||
| mockStore.removeFolderWorkspace.mockReturnValue(false) | ||
|
|
||
| await handlers.get('folderWorkspaces:update')?.(null, { | ||
| folderWorkspaceId: 'missing-folder', | ||
| updates: { name: 'Missing folder' } | ||
| }) | ||
| await handlers.get('folderWorkspaces:delete')?.(null, { | ||
| folderWorkspaceId: 'missing-folder' | ||
| }) | ||
|
|
||
| expect(folderWorkspaceChangeNotifier.notifyFolderWorkspaceChanged).not.toHaveBeenCalled() | ||
| expect(scheduleWatcherSyncMock).not.toHaveBeenCalled() | ||
| expect(mainWindow.webContents.send).not.toHaveBeenCalledWith('repos:changed') | ||
| }) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Make the missing-target test execute both handlers.
When either handler is missing, optional chaining skips the call and the negative assertions still pass. The test also does not prove that either store mutation was attempted.
Capture both handlers, assert that they are defined, call them directly, and assert that both store methods were called once.
Proposed test fix
+ const update = handlers.get('folderWorkspaces:update')
+ const remove = handlers.get('folderWorkspaces:delete')
+ expect(update).toBeDefined()
+ expect(remove).toBeDefined()
+
- await handlers.get('folderWorkspaces:update')?.(null, {
+ await update!(null, {
folderWorkspaceId: 'missing-folder',
updates: { name: 'Missing folder' }
})
- await handlers.get('folderWorkspaces:delete')?.(null, {
+ await remove!(null, {
folderWorkspaceId: 'missing-folder'
})
+ expect(mockStore.updateFolderWorkspace).toHaveBeenCalledOnce()
+ expect(mockStore.removeFolderWorkspace).toHaveBeenCalledOnce()📝 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.
| it('does not publish catalog notifications for missing update or delete targets', async () => { | |
| mockStore.updateFolderWorkspace.mockReturnValue(null) | |
| mockStore.removeFolderWorkspace.mockReturnValue(false) | |
| await handlers.get('folderWorkspaces:update')?.(null, { | |
| folderWorkspaceId: 'missing-folder', | |
| updates: { name: 'Missing folder' } | |
| }) | |
| await handlers.get('folderWorkspaces:delete')?.(null, { | |
| folderWorkspaceId: 'missing-folder' | |
| }) | |
| expect(folderWorkspaceChangeNotifier.notifyFolderWorkspaceChanged).not.toHaveBeenCalled() | |
| expect(scheduleWatcherSyncMock).not.toHaveBeenCalled() | |
| expect(mainWindow.webContents.send).not.toHaveBeenCalledWith('repos:changed') | |
| }) | |
| it('does not publish catalog notifications for missing update or delete targets', async () => { | |
| mockStore.updateFolderWorkspace.mockReturnValue(null) | |
| mockStore.removeFolderWorkspace.mockReturnValue(false) | |
| const update = handlers.get('folderWorkspaces:update') | |
| const remove = handlers.get('folderWorkspaces:delete') | |
| expect(update).toBeDefined() | |
| expect(remove).toBeDefined() | |
| await update!(null, { | |
| folderWorkspaceId: 'missing-folder', | |
| updates: { name: 'Missing folder' } | |
| }) | |
| await remove!(null, { | |
| folderWorkspaceId: 'missing-folder' | |
| }) | |
| expect(mockStore.updateFolderWorkspace).toHaveBeenCalledOnce() | |
| expect(mockStore.removeFolderWorkspace).toHaveBeenCalledOnce() | |
| expect(folderWorkspaceChangeNotifier.notifyFolderWorkspaceChanged).not.toHaveBeenCalled() | |
| expect(scheduleWatcherSyncMock).not.toHaveBeenCalled() | |
| expect(mainWindow.webContents.send).not.toHaveBeenCalledWith('repos:changed') | |
| }) |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b002b283-38f8-44cb-adc8-a6277d5cc8e8
📒 Files selected for processing (3)
mobile/app/h/[hostId]/index.tsxmobile/src/worktree/host-worktree-refresh.test.tsmobile/src/worktree/host-worktree-refresh.ts
046b51c to
0d15c53
Compare
0d15c53 to
8112265
Compare
AttachmentsExact-head native iPad QA — 8112265
|





Summary
Fix Mobile Home so a runtime-created folder workspace enters the existing workspace catalog when its paired host publishes reposChanged. Search and selection use that same refreshed worktree.ps catalog.
This is a separate catalog invalidation fix from #11751; it does not change native-chat routing or readability.
Before / after
Before: a folder workspace could exist on the paired host while Mobile Home and search continued showing the stale catalog. The reposChanged handler refreshed only decorative repo metadata.
After: reposChanged also requests the authoritative host-scoped worktree catalog, so folder workspaces and Git worktrees converge through the existing Home refresh path.
Scope
The effective diff is two files and 5 additions / 1 deletion. It adds one existing read-only catalog refresh call plus its regression assertion.
There are no new timers, polling loops, caches, dependencies, protocol changes, UI changes, lockfile changes, or native changes. SSH and relay hosts keep using the same connection-scoped worktree.ps request on the host that emitted the event.
Validation
Validated exact head 8112265 atop origin/main 278a4b2:
Native QA
Fresh exact-head native iPad revalidation passed on 8112265. The exact-head Mobile bundle ran on approved iPad C589AF84-2F0C-4978-952B-748933DE6804 at port 3101; the already-running approved iPhone 50FD514C-96F6-446E-AC90-D07A24CAB3A0 remained untouched at port 3100, and no third device or stream was started.
Using an authenticated, isolated direct-LAN Host 9 catalog:
Exactisolated only the folder result./tmp/pr11767-exact-head-ipad/folder-catalogidentity; switching to the Git row showedbrennanb2025/mobile-folder-workspace-catalog-refresh.lastSeenAt, and showed no pairing or reachability error.SSH/Relay was not exercised: the iPad's previously saved targets were offline or stale, and no already-available SSH or Relay mobile target permitted a safe additional lane. The successful revalidation used the supported headless direct-LAN pairing path and did not automate the desktop Electron UI.
AI review
A genuinely fresh same-model gpt-5.6-sol xhigh review on exact head 8112265 returned literal CLEAN. The read-only review traced event and catalog authority, host/client scope, folder-workspace and Git-worktree behavior, SSH/relay semantics, reconnect and polling interactions, regression and performance risk, security scope, tests, and this PR body; its 25 focused tests and git diff --check passed.