Skip to content

feat(builder): add connect-your-agent card and default first workspace - #1577

Merged
realcodesiman merged 4 commits into
mainfrom
feat/connect-agent-mcp-token
Oct 28, 2026
Merged

realcodesiman merged 4 commits into
mainfrom
feat/connect-agent-mcp-token

Conversation

@realcodesiman

@realcodesiman realcodesiman commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Users with no workspace membership get a default workspace when they open /, so MCP/CLI setup no longer waits on connecting a channel. Invited users are not given an extra one.
  • First-workspace creation is serialized per owner with a transaction-scoped pg_advisory_xact_lock, so two tabs opening / cannot create duplicates.
  • When a known create error blocks it (workspace limit, trial expired, MAC limit), / falls through to the workspace list instead of failing.

Changes

  • packages/database/src/repositories/workspace/repository.ts: lockFirstWorkspace (advisory lock) and findActiveByOwner (live workspace, excludes soft-deleted, ordered by id).
  • packages/business/src/workspace/service.ts: ensureFirstForOwner locks, reads through the repository, and creates when the owner has none. findActiveByOwner delegates to the repository.
  • apps/builder/src/lib/workspace/create-first-workspace.ts: shared callEnsure; new non-redirecting ensureFirstWorkspace (returns null on a known create error); createFirstWorkspace redirects to /channels/create?error=….
  • apps/builder/src/app/page.tsx: auto-create and redirect for users without membership.
  • docs/tenancy.md: "Default workspace" section.
  • i18n: workspaces.defaultName ("{name}'s workspace") in all 20 locales.
  • Tests: workspace-ensure-first-for-owner, main-page-default-workspace, updated workspace service and channel route mocks.

Test plan

  • pnpm lint
  • pnpm --filter builder check-types && pnpm --filter @chatbotx.io/business check-types
  • pnpm --filter builder test; pnpm --filter @chatbotx.io/business test
  • manual: new user with no membership lands on a fresh workspace dashboard
  • manual: two tabs opening / at once create a single workspace

Agent-first note (invariant 23): no new operation or feature surface. This is sign-in landing plumbing only, so no public API procedure is added.

🤖 Generated with Claude Code

New users with no membership get a default workspace on `/` so MCP/CLI
setup does not wait on connecting a channel. Super admins see a "Connect
your AI agent" card on the contacts dashboard that mints an MCP token and
shows hosted-server snippets (NEXT_PUBLIC_MCP_SERVER_URL).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@github-actions github-actions Bot added the feature New feature or request label Oct 28, 2026
realcodesiman and others added 3 commits October 28, 2026 21:02
…tion

- connect-agent snippets pass the token via x-workspace-token instead of the URL query string
- extract mintWorkspaceToken shared by the MCP and workspace token actions
- serialize ensureFirstForOwner with a transaction-scoped advisory lock so a caller-owned tx is fenced too
- fall back to the email for the default workspace name when the user name is empty
…pace creation

Remove the "Connect your AI agent" card, the MCP token action, and the
NEXT_PUBLIC_MCP_SERVER_URL env; only the first-workspace default remains.
Workspace token creation inlines minting again.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ify first-workspace flow

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@realcodesiman
realcodesiman merged commit 4f71bcf into main Oct 28, 2026
14 checks passed
@realcodesiman
realcodesiman deleted the feat/connect-agent-mcp-token branch October 28, 2026 23:23
hello-jackytruong referenced this pull request in hello-jackytruong/ChatWorkAI Nov 22, 2026
…e (#1577)

* feat(builder): add connect-your-agent card and default first workspace

New users with no membership get a default workspace on `/` so MCP/CLI
setup does not wait on connecting a channel. Super admins see a "Connect
your AI agent" card on the contacts dashboard that mints an MCP token and
shows hosted-server snippets (NEXT_PUBLIC_MCP_SERVER_URL).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* fix(builder): send MCP token as header and fence first-workspace creation

- connect-agent snippets pass the token via x-workspace-token instead of the URL query string
- extract mintWorkspaceToken shared by the MCP and workspace token actions
- serialize ensureFirstForOwner with a transaction-scoped advisory lock so a caller-owned tx is fenced too
- fall back to the email for the default workspace name when the user name is empty

* refactor(builder): drop connect-agent MCP card and keep default workspace creation

Remove the "Connect your AI agent" card, the MCP token action, and the
NEXT_PUBLIC_MCP_SERVER_URL env; only the first-workspace default remains.
Workspace token creation inlines minting again.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* refactor(workspace): move findActiveByOwner into repository and simplify first-workspace flow

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

---------

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant