Skip to content

link: two-step workspace picker + cross-workspace --app-id - #568

Open
netanelgilad wants to merge 1 commit into
mainfrom
claude/cli-link-workspace-picker-h5x81l
Open

link: two-step workspace picker + cross-workspace --app-id#568
netanelgilad wants to merge 1 commit into
mainfrom
claude/cli-link-workspace-picker-h5x81l

Conversation

@netanelgilad

@netanelgilad netanelgilad commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Note

Description

Reworks the existing-app selection in base44 link to be workspace-aware. Interactive linking becomes a two-step flow — pick a workspace (skipped when you belong to only one), then pick an app scoped to that workspace — instead of listing only apps in your personal/active workspace. --app-id is now validated directly via getApp rather than being looked up in the app list, so it links any app you can access, including apps in other workspaces. The server remains the source of truth for permissions; the CLI never filters or validates by role.

Related Issue

Builds on #577 (fix(link): list editor-created apps for linking), which landed on main while this PR was open — editor-created (managed-source) apps stay linkable here. No issue is closed by this PR.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Other (please describe):

Changes Made

  • link.ts — extracted the choose branch into two helpers:
    • resolveExplicitAppId() validates --app-id by fetching the app directly (getApp), making cross-workspace apps linkable; 404/403 surface an InvalidInputError with hints ("Check the app ID is correct", "Run base44 link without --app-id to browse apps by workspace").
    • chooseProjectInteractively() resolves the target workspace via resolveWorkspaceId(), then fetches and prompts for an app scoped to that workspace; returns undefined when the workspace has no apps (falls through to the existing "No projects available for linking" outro).
  • workspace-select.tsresolveWorkspaceId() takes an optional { promptMessage } so link can ask "Which workspace is the app in?" instead of the create-oriented wording; the local options variable was renamed to promptOptions to avoid shadowing. Doc comment updated to cover both the create and link cases.
  • core/project/api.tslistProjects() accepts an optional { workspaceId } and forwards it as the workspace_id search param on GET /api/apps; omitted means the server scopes to the caller's active/personal workspace.
  • --workspace/-w help text — now documents that the flag also scopes the app picker, not just app creation.
  • Tests — added TestAPIServer.mockGetApp() (routes on the response's own id, so tests can mock apps other than the context app); link.spec.ts switched from mockListProjects to mockGetApp for the --app-id / legacy --project-id / --projectId cases, plus new coverage for linking an app in another workspace and for the not-found (404) error path.

Testing

  • I have tested these changes locally
  • I have added/updated tests as needed
  • All tests pass (npm test)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have updated docs/ (AGENTS.md) if I made architectural changes

Additional Notes

  • Backwards compatible: legacy --project-id / --projectId aliases and the --org alias for --workspace still work, and non-interactive runs are unaffected (resolveWorkspaceId returns undefined, so the server applies its default).
  • Behavioral note vs. the pre-rebase version of this PR: the managed-source filter and the --app-id managed-source rejection were dropped to honor fix(link): list editor-created apps for linking #577, so editor-created apps remain linkable. main's editor-created-app test is kept, adapted to mockGetApp.
  • No docs/ updates: this is a behavior change inside an existing command rather than an architectural one; command help text was updated in place.
  • The test-run boxes are left unchecked because the suite was not executed in this analysis environment — only the diff was reviewed.

🤖 Generated by Claude | 2026-08-02 09:37 UTC | c08ba20

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/cli@0.1.7-pr.568.c08ba20

Prefer not to change any import paths? Install using npm alias so your code still imports base44:

npm i "base44@npm:@base44-preview/cli@0.1.7-pr.568.c08ba20"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/cli@0.1.7-pr.568.c08ba20"
  }
}

Preview published to npm registry — try new features instantly!

@netanelgilad
netanelgilad force-pushed the claude/cli-link-workspace-picker-h5x81l branch 2 times, most recently from 33cadb1 to 983dab3 Compare July 15, 2026 15:06
Base automatically changed from claude/cli-workspaces-support-h5x81l to main July 19, 2026 08:37
@netanelgilad
netanelgilad force-pushed the claude/cli-link-workspace-picker-h5x81l branch from 983dab3 to 9beb9a4 Compare July 19, 2026 09:09
The `link` existing-app picker was scoped to the caller's personal workspace
(the server defaults app listing to the active workspace), so apps in other
workspaces were unreachable — and `--app-id` for such an app was rejected by
the personal-scoped pre-validation.

- Interactive "link existing" now picks a workspace first (skipped when you
  belong to only one), then lists apps scoped to that workspace via the new
  listProjects({ workspaceId }) (workspace_id query param).
- `--workspace <id>` scopes that picker (in addition to its --create meaning).
- `--app-id` is now validated by fetching the app directly (getApp), so it
  links any app you can access regardless of workspace; managed-source apps
  are rejected with a clear message, and unknown/inaccessible ids get a
  friendly "not found" error.

Adds resolveListingWorkspaceId (all memberships, since linking only reads),
is_managed_source_code on getApp/AppDetail, and link specs for the
cross-workspace, managed-source, and not-found paths.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0171Y6jogaAWB1suBYaEULp1
@netanelgilad
netanelgilad force-pushed the claude/cli-link-workspace-picker-h5x81l branch from 9beb9a4 to 796f294 Compare August 2, 2026 09:36
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.

2 participants