Skip to content

fix: discover agents across all accessible drives, not just the default#65

Merged
2witstudios merged 1 commit into
mainfrom
fix/discover-agents-all-drives
Jun 10, 2026
Merged

fix: discover agents across all accessible drives, not just the default#65
2witstudios merged 1 commit into
mainfrom
fix/discover-agents-all-drives

Conversation

@2witstudios

@2witstudios 2witstudios commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Problem

Shift+Tab agent cycling only showed agents from the PAGESPACE_DRIVE drive (pagespace-cli) — the 8 AIDD agents in the aidd-skills drive never appeared, because auto-discovery walked a single drive's page tree.

Fix

  • listAgentsByDriveSluglistAgentsAllDrives(preferredSlug?): lists every drive the token can access, walks each page tree in parallel, and returns all AI_CHAT pages with the default drive's agents first.
  • A drive whose page tree fails to load is skipped — discovery degrades, never throws.
  • Duplicate display names across drives get a short page-id suffix (pi model ids are the display names, so duplicates would collide in the registry).
  • Pure helpers (collectAgentPages, orderDrivesPreferredFirst, dedupeAgentNames) extracted and unit-tested.

Verification

  • npm run check green (typecheck · lint · unit tests, incl. new test/unit/agents.test.ts).
  • Live run against pagespace.ai with the agent token: returns all 10 agents — Companion Agent + Curator (pagespace-cli) first, then the 8 AIDD agents (aidd-skills).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Agent discovery has been expanded to search across all available drives, giving you access to a broader set of agents within your workspace.
    • Duplicate agent names are now automatically disambiguated with unique identifier suffixes for improved clarity.
  • Tests

    • Added comprehensive unit test coverage for agent discovery functionality and duplicate name handling.

Shift+Tab agent cycling only showed AI_CHAT pages from PAGESPACE_DRIVE
because discovery walked a single drive. listAgentsAllDrives lists every
drive the token can access (default drive's agents first), skips drives
whose page tree fails to load, and disambiguates duplicate display names
with a short page-id suffix since pi model ids are the display names.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@2witstudios 2witstudios merged commit 871657b into main Jun 10, 2026
1 check passed
@2witstudios 2witstudios deleted the fix/discover-agents-all-drives branch June 10, 2026 03:44
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 60d4b9c5-42b4-4770-87d4-839ec3dc89e5

📥 Commits

Reviewing files that changed from the base of the PR and between a7ca25b and 343d10c.

📒 Files selected for processing (3)
  • extensions/pagespace.ts
  • src/api.ts
  • test/unit/agents.test.ts

📝 Walkthrough

Walkthrough

This PR refactors agent discovery from a single-drive lookup to a multi-drive scan. Pure helpers collect AI_CHAT pages, reorder drives by preference, and deduplicate agent names. These feed a new listAgentsAllDrives orchestrator that loads all drives, handles failures gracefully, and returns a consolidated list. The pagespace extension now uses this new API for broader agent discovery.

Changes

Multi-drive agent discovery refactor

Layer / File(s) Summary
Agent discovery helpers and tests
src/api.ts, test/unit/agents.test.ts
Introduces AgentSpec type contract, collectAgentPages to recursively find AI_CHAT pages by title, orderDrivesPreferredFirst to reorder drives with optional preferred slug prioritization, and dedupeAgentNames to suffix duplicate names with an 8-character ID fragment. Comprehensive tests verify tree traversal depth-first order, drive reordering with missing/unknown preferences, and name deduplication behavior.
Multi-drive agent discovery orchestration
src/api.ts
Implements PageSpaceApi.listAgentsAllDrives(preferredSlug?) to fetch and order all drives, load each drive's page tree concurrently with Promise.allSettled, gracefully skip failed trees, aggregate all AI_CHAT pages, and return a deduplicated agent list.
Extension integration
extensions/pagespace.ts
Auto-discovery now unconditionally invokes api.listAgentsAllDrives(config.defaultDriveSlug) when PAGESPACE_MODEL_PAGES is unset, replacing the previous single-drive conditional logic.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Across all drives the agents now roam,
De-duped and ordered to find a new home,
Pure helpers gather what's nested so deep,
One promise to rule them—then discovery's complete! 🌟

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/discover-agents-all-drives

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 and usage tips.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 343d10c1b4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/api.ts
Comment on lines +81 to +83
return agents.map((a) =>
(counts.get(a.name) ?? 0) > 1 ? { ...a, name: `${a.name} (${a.id.slice(0, 8)})` } : a,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Ensure generated agent names are globally unique

When an existing agent is already titled like a generated name (for example, Curator (abcdefgh) alongside two agents named Curator), or two duplicate-name agents share the same eight-character ID prefix, this produces duplicate pi model IDs. Selecting the later model then still routes through config.models.find(...) to the first matching entry, so requests can be sent to the wrong PageSpace agent; generate suffixes while checking the complete resulting name set rather than only counting the original titles.

Useful? React with 👍 / 👎.

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