Skip to content

fix(mobile): refresh folder workspaces in Home catalog - #11767

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/mobile-folder-workspace-catalog-refresh
Aug 1, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/mobile-folder-workspace-catalog-refresh

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • Focused regression: 5/5 passed.
  • Full Mobile suite: 382 files passed; 2,851 tests passed and 3 skipped.
  • Mobile typecheck, oxlint, and format check passed.
  • Root typecheck and full lint passed, including 58 reliability gates and the max-lines ratchet.
  • All 43 exact-head GitHub checks passed or were intentionally skipped.
  • git diff --check passed.

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:

  • A folder workspace created after the host mounted appeared immediately from reposChanged, alongside the Git worktree, without relaunch or manual refresh.
  • Search for Exact isolated only the folder result.
  • Folder selection showed the correct folder name and /tmp/pr11767-exact-head-ipad/folder-catalog identity; switching to the Git row showed brennanb2025/mobile-folder-workspace-catalog-refresh.
  • A second reposChanged rename converged to exactly one renamed folder row and one Git row: the old folder label count was 0, so there was no stale or duplicate entry.
  • Home-backgrounding, Spotlight foregrounding, and a full runtime stop/restart on the same endpoint remounted the authenticated host. Host 9 retained exactly one folder and one Git row, refreshed its device lastSeenAt, and showed no pairing or reachability error.

Folder workspace appears immediately

Folder workspace search

Folder workspace selected

Git worktree selected

Authenticated runtime reconnect

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.

@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

Folder 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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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
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.
Title check ✅ Passed The title clearly identifies the mobile fix that refreshes folder workspaces in the Home catalog.
Description check ✅ Passed The description provides a clear summary, visual evidence, extensive validation results, native QA details, and an AI review summary.
✨ Finishing Touches 💡 1
📝 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.

@greptile-apps

greptile-apps Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

Greptile Summary

When the paired host publishes a reposChanged event, the handler previously refreshed only repo metadata, leaving the worktree catalog stale for folder workspaces created at runtime. This PR adds a fetchWorktrees() call alongside the existing fetchRepoMetadata call in that event path so the catalog converges immediately.

  • host-worktree-refresh.ts: one-line addition of void fetchWorktrees() in the reposChanged branch, matching the pattern already used by the worktreesChanged and reconnect paths.
  • host-worktree-refresh.test.ts: the existing reposChanged regression test is tightened — a mockClear() is added before the event and a new assertion verifies fetchWorktrees is called exactly once.

Confidence Score: 5/5

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

Important Files Changed

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]
Loading

Reviews (7): Last reviewed commit: "fix(mobile): refresh folder workspace ca..." | Re-trigger Greptile

@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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 935c8076-0327-4aeb-abc6-fb09ecbb10bf

📥 Commits

Reviewing files that changed from the base of the PR and between afa1be5 and f4a89a3.

📒 Files selected for processing (2)
  • src/main/ipc/repos-folder-workspace.test.ts
  • src/main/window/attach-main-window-services.test.ts

Comment on lines +152 to +167
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')
})

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.

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

Suggested change
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')
})

@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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b002b283-38f8-44cb-adc8-a6277d5cc8e8

📥 Commits

Reviewing files that changed from the base of the PR and between f4a89a3 and 549e484.

📒 Files selected for processing (3)
  • mobile/app/h/[hostId]/index.tsx
  • mobile/src/worktree/host-worktree-refresh.test.ts
  • mobile/src/worktree/host-worktree-refresh.ts

Comment thread mobile/app/h/[hostId]/index.tsx Resolved
@brennanb2025
brennanb2025 force-pushed the brennanb2025/mobile-folder-workspace-catalog-refresh branch from 046b51c to 0d15c53 Compare August 1, 2026 06:52
@brennanb2025
brennanb2025 force-pushed the brennanb2025/mobile-folder-workspace-catalog-refresh branch from 0d15c53 to 8112265 Compare August 1, 2026 07:04
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Attachments

Exact-head native iPad QA — 8112265

06-immediate-folder-appearance.png 07-folder-search.png
06-immediate-folder-appearance.png 07-folder-search.png
08-folder-open.png 09-git-worktree-open.png
08-folder-open.png 09-git-worktree-open.png
12-authenticated-runtime-reconnect.png
12-authenticated-runtime-reconnect.png

@brennanb2025
brennanb2025 merged commit 169ec8f into main Aug 1, 2026
43 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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