Skip to content

Fix integration discovery and options lookup - #84

Merged
khaliqgant merged 17 commits into
mainfrom
fix-integration-discovery-options
Jun 5, 2026
Merged

khaliqgant merged 17 commits into
mainfrom
fix-integration-discovery-options

Conversation

@kjgbot

@kjgbot kjgbot commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

User description

Summary

  • resolve integration option lookups through the Relayfile workspace handle so Slack channel pickers use the connected workspace
  • add a generic listRemoteDir(projectId, remotePath) IPC API backed by Relayfile listTree, so integration pickers can read already-synced remote data without local mounts
  • use remote Relayfile /slack/channels as the Slack picker fallback before local filesystem mounts
  • always sync discovery mounts for connected integrations while keeping historical provider records behind historical sync
  • hide synced-data browsing affordances and mount paths in Account Settings when historical sync is disabled
  • tailor injected integration messages to distinguish writeback discovery from historical records

Tests

  • npm run build
  • npx vitest run src/main/integration-mounts.test.ts
  • npm test

CodeAnt-AI Description

Use remote integration data for Slack pickers and discovery paths

What Changed

  • Slack channel pickers can now load from connected workspace data even when the local history mount is unavailable, and they fall back to the older channel list when needed.
  • Integration browsing now exposes writeback discovery folders separately from historical synced files, and discovery paths are kept for connected integrations even when history download is off.
  • Account and project settings now hide synced-data browsing for integrations without historical files, while showing a loading state and clearer status for connected integrations.
  • Event listening and agent updates now include the correct Slack discovery paths and notify agents when broker startup makes integration data available.

Impact

✅ Fewer blocked Slack channel pickers
✅ Clearer access to synced vs discovery data
✅ Fewer empty integration browsers

🔄 Retrigger CodeAnt AI Review

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@codeant-ai

codeant-ai Bot commented Jun 5, 2026

Copy link
Copy Markdown

CodeAnt AI is reviewing your PR.

@coderabbitai

coderabbitai Bot commented Jun 5, 2026 •

Copy link
Copy Markdown

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

Special-case discovery-prefixed mount paths, add Relayfile remote directory listing and IPC/preload surface, compute agent-workspace discovery (+ optional historical) mount paths and sync them deduplicated per provider, gate the mount-browser UI on historical-download capability, update Slack channel listing flow, and add tests for discovery mounts and remount timing.

Changes

Discovery Mount Paths and Conditional Historical Browsing

Layer / File(s) Summary
Discovery Mount Path Canonicalization
src/main/integration-mounts.ts, src/main/integration-event-bridge.ts
canonicalIntegrationMountPath and canonicalMountPaths add early handling for /discovery... paths and preserve discovery-prefixed layout.
Remote directory listing (server) and helpers
src/main/integrations.ts
Adds typed Relayfile listTree pagination, normalization, containment and path helpers, sorting, and a max-entry cap via IntegrationsManager.listRemoteDirectory.
listOptions workspace request and error handling
src/main/integrations.ts
listOptions now uses workspace-scoped requestJson for listIntegrationOptions and returns [] when the integration is not found.
Mount Path Strategy and Synchronization
src/main/integrations.ts
Agent-workspace mount-path helpers produce discovery writeback roots and conditional historical provider mounts; mountPathsFor/syncLocalMounts dedupe and mount per-provider/integration discovery and optional history; system-message text updated; localMountPaths assignment changed.
IPC / Preload / Types for remote listing
src/main/ipc-handlers.ts, src/preload/index.ts, src/shared/types/ipc.ts
Adds integrations:list-remote-dir IPC handler, exposes integrations.listRemoteDir in preload, and extends PearAPI.integrations types with listRemoteDir.
Frontend: Browsable gating and Slack channel listing
src/renderer/src/components/settings/AccountSettings.tsx, src/renderer/src/components/settings/ProjectSettings.tsx
Gates mount-browser on downloadHistoricalData, refactors browser to accept roots, clears browser state for non-browsable integrations, adjusts toggle/refresh behavior, and adds Slack channel entry normalization plus remote-first listing with fallback.
Tests: discovery mounts and async sequencing
src/main/integration-mounts.test.ts, src/main/__tests__/integration-event-bridge.test.ts
Adds tests validating discovery-style Slack mounts are preserved (mount inputs, relayfile scopes, localPathsFor), an event-bridge discovery subscription test, and inserts a macrotask delay in an expired-token remount test.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🐰
Discovery roots in tidy rows,
Mounts that hop where relay flows,
Browsers sleep till history shows,
Remote lists return with care,
Tests wait a beat — then spring to air.


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Jun 5, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for writeback discovery mounts for connected integrations, ensuring root-level discovery paths are preserved and handled correctly. It also refactors integration options fetching, updates UI settings to restrict browsing to integrations with historical download enabled, and adjusts Slack channel option retrieval. However, a potential regression was identified in src/main/integrations.ts where removing the try-catch block for handling 404 errors in listOptions could cause unhandled exceptions to propagate to the UI.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/main/integrations.ts Outdated
Comment on lines +692 to +696
const payload = await this.withWorkspaceHandle(async (handle) => await handle.requestJson({
operation: 'listIntegrationOptions',
method: 'GET',
path: `api/v1/workspaces/${handle.workspaceId}/integrations/${encodeURIComponent(normalizedProvider)}/options/${encodeURIComponent(normalizedResource)}`
}) as unknown)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Removing the try-catch block that handles 404 errors is a regression. If the integration options endpoint is not found or not implemented for a specific provider, handle.requestJson will throw a 404 error, causing listOptions to fail and propagate an unhandled exception to the UI. Restoring the 404 error handling to return an empty array [] ensures robustness and prevents UI crashes.

    let payload: unknown
    try {
      payload = await this.withWorkspaceHandle(async (handle) => await handle.requestJson({
        operation: 'listIntegrationOptions',
        method: 'GET',
        path: `api/v1/workspaces/${handle.workspaceId}/integrations/${encodeURIComponent(normalizedProvider)}/options/${encodeURIComponent(normalizedResource)}`
      }) as unknown)
    } catch (error) {
      if (isHttpStatus(error, 404) || /\b404\b/u.test(toErrorMessage(error))) return []
      throw error
    }

@codeant-ai

codeant-ai Bot commented Jun 5, 2026

Copy link
Copy Markdown

CodeAnt AI finished reviewing your PR.

@agent-relay-code

Copy link
Copy Markdown
Contributor

Fixed the PR issues I found.

Changes made:

  • Scoped bare /discovery mounts to /discovery/<provider> so mount permissions do not cover the whole discovery namespace.
  • Preserved /discovery/<provider> paths in integration event canonicalization instead of rewriting them to provider-root paths.
  • Added focused coverage for both behaviors.

Local verification passed:

  • npm test
  • npx vitest run
  • npm run build

@agent-relay-code

Copy link
Copy Markdown
Contributor

✅ pr-reviewer applied fixes — committed and pushed a3e2fa0 to this PR. The notes below describe what changed.

Fixed the PR issues I found.

Changes made:

  • Scoped bare /discovery mounts to /discovery/<provider> so mount permissions do not cover the whole discovery namespace.
  • Preserved /discovery/<provider> paths in integration event canonicalization instead of rewriting them to provider-root paths.
  • Added focused coverage for both behaviors.

Local verification passed:

  • npm test
  • npx vitest run
  • npm run build

@agent-relay-code

Copy link
Copy Markdown
Contributor

Fixed the PR issue I found: discovery mounts are now surfaced in localMountPaths because they are actually mounted, while the account settings historical-data browser filters discovery roots so it does not open writeback schemas instead of provider records.

Local verification passed:

  • npx tsc --noEmit
  • npm test
  • npx vitest run src/main/integration-mounts.test.ts
  • npm run build

@agent-relay-code

Copy link
Copy Markdown
Contributor

✅ pr-reviewer applied fixes — committed and pushed b444ff2 to this PR. The notes below describe what changed.

Fixed the PR issue I found: discovery mounts are now surfaced in localMountPaths because they are actually mounted, while the account settings historical-data browser filters discovery roots so it does not open writeback schemas instead of provider records.

Local verification passed:

  • npx tsc --noEmit
  • npm test
  • npx vitest run src/main/integration-mounts.test.ts
  • npm run build

@agent-relay-code

Copy link
Copy Markdown
Contributor

Reviewed the PR artifacts and traced the helper through the cloud-agent box and proactive-runtime callers.

Fixed one real gap in the PR: warmed clones fetched refs correctly, but cold clones still used git clone --branch <ref>, which fails for full refs like refs/heads/main. I changed git-workspace-sync-script.ts so cold and warm workspaces both initialize the repo first, then use the same fetch-to-remote-tracking-ref and checkout path. I also added regression coverage in git-workspace-sync-script.test.ts and updated the affected proactive-runtime assertion.

Local checks run:

  • npm run build:core
  • node node_modules/vitest/vitest.mjs run --config vitest.config.ts packages/web/lib/integrations/git-workspace-sync-script.test.ts
  • node node_modules/vitest/vitest.mjs run --config vitest.config.ts packages/web/lib/proactive-runtime/deployment-trigger-delivery.test.ts
  • node node_modules/vitest/vitest.mjs run --config vitest.config.ts packages/web/lib/proactive-runtime/deployment-trigger-delivery.provisioning.test.ts
  • node node_modules/vitest/vitest.mjs run --config vitest.config.ts 'packages/web/app/api/v1/workspaces/[workspaceId]/cloud-agents/[cloudAgentId]/box/box-manager.test.ts'
  • node node_modules/typescript/bin/tsc -p packages/web/tsconfig.json --noEmit

@agent-relay-code

Copy link
Copy Markdown
Contributor

✅ pr-reviewer applied fixes — committed and pushed b444ff2 to this PR. The notes below describe what changed.

Fixed the PR issue I found: discovery mounts are now surfaced in localMountPaths because they are actually mounted, while the account settings historical-data browser filters discovery roots so it does not open writeback schemas instead of provider records.

Local verification passed:

  • npx tsc --noEmit
  • npm test
  • npx vitest run src/main/integration-mounts.test.ts
  • npm run build

@agent-relay-code

Copy link
Copy Markdown
Contributor

Fixed the PR issues I found:

  • Constrained integrations:list-remote-dir so renderer requests can only list project-visible integration/discovery paths, rejects ./.., and skips the queried root if Relayfile returns it.
  • Filtered root /discovery/... Relayfile changes so discovery metadata does not notify agents.
  • Added coverage for root discovery events staying silent.

Local verification run:

  • npm test
  • npx vitest run
  • npm run build

@agent-relay-code

Copy link
Copy Markdown
Contributor

✅ pr-reviewer applied fixes — committed and pushed 530bceb to this PR. The notes below describe what changed.

Fixed the PR issues I found:

  • Constrained integrations:list-remote-dir so renderer requests can only list project-visible integration/discovery paths, rejects ./.., and skips the queried root if Relayfile returns it.
  • Filtered root /discovery/... Relayfile changes so discovery metadata does not notify agents.
  • Added coverage for root discovery events staying silent.

Local verification run:

  • npm test
  • npx vitest run
  • npm run build

@agent-relay-code

Copy link
Copy Markdown
Contributor

⚠️ pr-reviewer push failed (exit 1) — fixes were not applied to the PR. The notes below are advisory and were not pushed.

Fixed the PR issues I found.

Changed src/main/integrations.ts to:

  • Reject unsafe remote directory paths with . / ...
  • Only allow remote listing under connected integration roots for the project.
  • Use the account workspace id for listTree, matching where integration data is mounted.
  • Skip the listed root entry if Relayfile returns it.

Added focused coverage in src/main/integrations.test.ts.

Local checks run:

  • npm test passed.
  • npx vitest run passed.
  • npm run build passed.

1 similar comment
@agent-relay-code

Copy link
Copy Markdown
Contributor

⚠️ pr-reviewer push failed (exit 1) — fixes were not applied to the PR. The notes below are advisory and were not pushed.

Fixed the PR issues I found.

Changed src/main/integrations.ts to:

  • Reject unsafe remote directory paths with . / ...
  • Only allow remote listing under connected integration roots for the project.
  • Use the account workspace id for listTree, matching where integration data is mounted.
  • Skip the listed root entry if Relayfile returns it.

Added focused coverage in src/main/integrations.test.ts.

Local checks run:

  • npm test passed.
  • npx vitest run passed.
  • npm run build passed.

@agent-relay-code

Copy link
Copy Markdown
Contributor

Fixed a PR regression in src/main/integrations.ts: discovery mount paths are now preserved as /discovery/<provider> instead of being rewritten into provider data paths like /slack/slack. Bare /discovery is scoped to the integration provider, matching IntegrationMountManager.

Local checks run:

  • npm test
  • npm run build
  • npx vitest run src/main/integration-mounts.test.ts

@agent-relay-code

Copy link
Copy Markdown
Contributor

✅ pr-reviewer applied fixes — committed and pushed 450a0f1 to this PR. The notes below describe what changed.

Fixed a PR regression in src/main/integrations.ts: discovery mount paths are now preserved as /discovery/<provider> instead of being rewritten into provider data paths like /slack/slack. Bare /discovery is scoped to the integration provider, matching IntegrationMountManager.

Local checks run:

  • npm test
  • npm run build
  • npx vitest run src/main/integration-mounts.test.ts

@agent-relay-code

Copy link
Copy Markdown
Contributor

⚠️ pr-reviewer push failed (exit 1) — fixes were not applied to the PR. The notes below are advisory and were not pushed.

Reviewed and fixed PR #84 locally.

Fixed:

  • Preserved /discovery/... paths in integrations.ts so they no longer rewrite to invalid provider paths like /slack/slack.
  • Scoped bare /discovery consistently to /discovery/<provider> in event subscriptions, with a regression test.
  • Tightened remote directory listing authorization so selected child mounts can enumerate their immediate parent, without broadly authorizing higher provider roots.
  • Fixed scope picker initialization so Slack channel selections stored as channel IDs, mount segments, or full mount paths render checked when resources come from remote directory listings.

Local verification passed:

  • npm test
  • npx vitest run
  • npm run build

@agent-relay-code

Copy link
Copy Markdown
Contributor

Fixed the Slack channel picker regression in the PR.

Changes made:

  • Broad Slack mounts like /slack/channels now continue to seed the picker as “all channels” instead of selecting zero resources.
  • Concrete Slack channel selections now preselect correctly whether the saved value is the mount path or the channel id.
  • The generic scope picker now canonicalizes initial resource aliases to rendered resource ids so checkbox toggling remains consistent.

Local verification passed:

  • npx tsc --noEmit
  • npm test
  • npm run build

@agent-relay-code

Copy link
Copy Markdown
Contributor

⚠️ pr-reviewer push failed (exit 1) — fixes were not applied to the PR. The notes below are advisory and were not pushed.

Fixed the Slack channel picker regression in the PR.

Changes made:

  • Broad Slack mounts like /slack/channels now continue to seed the picker as “all channels” instead of selecting zero resources.
  • Concrete Slack channel selections now preselect correctly whether the saved value is the mount path or the channel id.
  • The generic scope picker now canonicalizes initial resource aliases to rendered resource ids so checkbox toggling remains consistent.

Local verification passed:

  • npx tsc --noEmit
  • npm test
  • npm run build

@agent-relay-code

Copy link
Copy Markdown
Contributor

Fixed a remote directory scope leak in PR #84: selected Slack channel scopes can no longer enumerate the parent /slack/channels directory or sibling channels. I moved the Relayfile remote path normalization/scope predicate into a small pure helper and added focused tests for traversal rejection, child access, parent denial, sibling denial, and provider-specific discovery access.

Local checks run:

  • npm test
  • npx vitest run src/main/integration-mounts.test.ts
  • npm run build

@agent-relay-code

Copy link
Copy Markdown
Contributor

✅ pr-reviewer applied fixes — committed and pushed 4bdd449 to this PR. The notes below describe what changed.

Fixed a remote directory scope leak in PR #84: selected Slack channel scopes can no longer enumerate the parent /slack/channels directory or sibling channels. I moved the Relayfile remote path normalization/scope predicate into a small pure helper and added focused tests for traversal rejection, child access, parent denial, sibling denial, and provider-specific discovery access.

Local checks run:

  • npm test
  • npx vitest run src/main/integration-mounts.test.ts
  • npm run build

@codeant-ai

codeant-ai Bot commented Jun 5, 2026

Copy link
Copy Markdown

CodeAnt AI is running Incremental review

@codeant-ai codeant-ai Bot added size:XL This PR changes 500-999 lines, ignoring generated files and removed size:L This PR changes 100-499 lines, ignoring generated files labels Jun 5, 2026
@codeant-ai

codeant-ai Bot commented Jun 5, 2026

Copy link
Copy Markdown

CodeAnt AI Incremental review completed.

@agent-relay-code

Copy link
Copy Markdown
Contributor

Reviewed PR #84 and fixed the remote directory listing regression.

Changed:

  • Allowed listing the immediate non-discovery parent of a configured remote mount root, so /slack/channels can be browsed for scoped Slack channel roots.
  • Filtered returned remote directory entries so unscoped sibling channels are not exposed.
  • Added focused tests for parent listing and entry filtering.

Verified locally:

  • npm test
  • npm exec vitest -- run src/main/integration-mounts.test.ts
  • npm run build

@khaliqgant
khaliqgant merged commit 9b434c1 into main Jun 5, 2026
3 checks passed
@khaliqgant
khaliqgant deleted the fix-integration-discovery-options branch June 5, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL This PR changes 500-999 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants