Skip to content

Support Coder workspace snapshot inputs#1432

Merged
potofpie merged 6 commits intomainfrom
feat/coder-workspace-session-sdk
May 2, 2026
Merged

Support Coder workspace snapshot inputs#1432
potofpie merged 6 commits intomainfrom
feat/coder-workspace-session-sdk

Conversation

@potofpie
Copy link
Copy Markdown
Member

@potofpie potofpie commented May 2, 2026

Summary

  • adds SDK support for Coder workspace dependency/setup-script snapshot inputs
  • exposes workspace update, snapshot refresh, and dependency validation APIs
  • extends Coder workspace CLI create/get/list plus adds update, refresh, and validate-dependencies subcommands
  • documents workspace-backed sessions and workspace snapshot input management

Test

  • bun test packages/core/test/coder-client.test.ts
  • bun run --filter='./packages/core' typecheck
  • bun run --filter='./packages/cli' typecheck

Summary by CodeRabbit

  • New Features

    • CLI: added workspace subcommands — update, refresh (snapshot rebuild), validate-dependencies; create/update accept dependencies and setup-script, and parse comma lists.
  • User Experience

    • Unified workspace summary for get/create; list shows Deps and Snapshot columns; commands return clearer validation errors and concise summaries.
  • Documentation

    • Quick Start updated with workspace session, snapshot, dependency validation, and setup-script examples.
  • Tests

    • Expanded coverage for workspace payloads, setup-script handling, updates, refresh, and dependency validation.

@agentuity-agent
Copy link
Copy Markdown

agentuity-agent Bot commented May 2, 2026

The latest Agentuity deployment details.

Project Deployment Preview Updated (UTC)
docs 🟢 Ready (deploy_f38b578f195835f88320b6e94dd1001f) - 2026-05-02T16:47:39Z

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 2, 2026

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

Adds workspace snapshot inputs (dependencies, setupScript), new workspace APIs and client methods for update/refresh/validation, shared CLI helpers and new/updated workspace subcommands (create/get/list/update/refresh/validate-dependencies), expanded tests, and a README Quick Start demonstrating workspace-based session and snapshot workflows.

Changes

Workspace snapshot inputs, API surface, CLI, tests, and docs

Layer / File(s) Summary
Data Shape / Schemas
packages/core/src/services/coder/types.ts
Adds dependencies?: string[] and setupScript?: string to CoderWorkspaceDetailSchema; extends CoderCreateWorkspaceRequestSchema; introduces CoderUpdateWorkspaceRequestSchema (partial update refine) and CoderWorkspaceDependencyValidationResponseSchema.
API Endpoints / Service Functions
packages/core/src/services/coder/workspaces.ts
Adds coderUpdateWorkspace (PATCH), coderRefreshWorkspaceSnapshot (POST), and coderValidateWorkspaceDependencies (POST) plus response wrapper schemas; functions return unwrapped workspace/data.
Client Surface
packages/core/src/services/coder/client.ts
Adds CoderClient.updateWorkspace(...), refreshWorkspaceSnapshot(...), and validateWorkspaceDependencies(...) delegating to the new service functions.
CLI Shared Utilities
packages/cli/src/cmd/coder/workspace/common.ts
New exports: EMPTY_WORKSPACE_ERROR, SetupScriptValidationError, parseCommaList, readSetupScript (mutual-exclusivity and file-read with structured error), hasWorkspaceSelections, hasWorkspaceUpdate, formatWorkspaceValidationMessage, and printWorkspaceSummary.
CLI Create / Get / List Output
packages/cli/src/cmd/coder/workspace/create.ts, .../get.ts, .../list.ts
create accepts --dependency, --setup-script, --setup-script-file, uses shared helpers and prints via printWorkspaceSummary; get delegates to printWorkspaceSummary; list adds Deps and Snapshot columns.
CLI Update / Refresh / Validate Subcommands
packages/cli/src/cmd/coder/workspace/update.ts, .../refresh.ts, .../validate-dependencies.ts
Adds update (partial updates: metadata, repo resolution, dependencies, setupScript, enabledAgents), refresh (queue snapshot refresh), and validate-dependencies (APT dependency validation) subcommands with request validation and targeted error handling.
CLI Command Composition
packages/cli/src/cmd/coder/workspace/index.ts
Registers new update, refresh, and validate-dependencies subcommands and adds a validate-dependencies example.
Tests / Contract Coverage
packages/core/test/coder-client.test.ts, packages/cli/test/cmd/coder/workspace.test.ts
Expands tests: asserts createSession includes workspaceId; createWorkspace/updateWorkspace accept/patch dependencies and setupScript; updates validation error expectations; adds CLI tests for create (deps/setupScript/file), update (patch), refresh, and validate-dependencies.
Documentation / Quick Start
packages/coder/README.md
Adds Quick Start snippet demonstrating creating a session from a saved workspaceId, logging workspaceSession.sessionId, validating workspace dependencies, creating/updating a workspace with dependencies and setupScript, and refreshing the workspace snapshot.
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Review rate limit: 2/5 reviews remaining, refill in 30 minutes and 31 seconds.

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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 2, 2026

📦 Canary Packages Published

version: 2.0.12-ce26d25

Packages
Package Version URL
@agentuity/db 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-db-2.0.12-ce26d25.tgz
@agentuity/runtime 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-runtime-2.0.12-ce26d25.tgz
@agentuity/schema 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-schema-2.0.12-ce26d25.tgz
@agentuity/migrate 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-migrate-2.0.12-ce26d25.tgz
@agentuity/task 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-task-2.0.12-ce26d25.tgz
@agentuity/webhook 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-webhook-2.0.12-ce26d25.tgz
@agentuity/react 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-react-2.0.12-ce26d25.tgz
@agentuity/schedule 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-schedule-2.0.12-ce26d25.tgz
@agentuity/sandbox 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-sandbox-2.0.12-ce26d25.tgz
@agentuity/opencode 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-opencode-2.0.12-ce26d25.tgz
@agentuity/core 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-core-2.0.12-ce26d25.tgz
@agentuity/auth 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-auth-2.0.12-ce26d25.tgz
@agentuity/vector 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-vector-2.0.12-ce26d25.tgz
@agentuity/email 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-email-2.0.12-ce26d25.tgz
@agentuity/coder-tui 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-coder-tui-2.0.12-ce26d25.tgz
@agentuity/claude-code 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-claude-code-2.0.12-ce26d25.tgz
@agentuity/coder 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-coder-2.0.12-ce26d25.tgz
@agentuity/frontend 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-frontend-2.0.12-ce26d25.tgz
@agentuity/workbench 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-workbench-2.0.12-ce26d25.tgz
@agentuity/queue 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-queue-2.0.12-ce26d25.tgz
@agentuity/postgres 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-postgres-2.0.12-ce26d25.tgz
@agentuity/server 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-server-2.0.12-ce26d25.tgz
@agentuity/evals 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-evals-2.0.12-ce26d25.tgz
@agentuity/drizzle 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-drizzle-2.0.12-ce26d25.tgz
@agentuity/cli 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-cli-2.0.12-ce26d25.tgz
@agentuity/keyvalue 2.0.12-ce26d25 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-keyvalue-2.0.12-ce26d25.tgz
Install

Add to your package.json:

{
  "dependencies": {
    "@agentuity/db": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-db-2.0.12-ce26d25.tgz",
    "@agentuity/runtime": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-runtime-2.0.12-ce26d25.tgz",
    "@agentuity/schema": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-schema-2.0.12-ce26d25.tgz",
    "@agentuity/migrate": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-migrate-2.0.12-ce26d25.tgz",
    "@agentuity/task": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-task-2.0.12-ce26d25.tgz",
    "@agentuity/webhook": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-webhook-2.0.12-ce26d25.tgz",
    "@agentuity/react": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-react-2.0.12-ce26d25.tgz",
    "@agentuity/schedule": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-schedule-2.0.12-ce26d25.tgz",
    "@agentuity/sandbox": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-sandbox-2.0.12-ce26d25.tgz",
    "@agentuity/opencode": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-opencode-2.0.12-ce26d25.tgz",
    "@agentuity/core": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-core-2.0.12-ce26d25.tgz",
    "@agentuity/auth": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-auth-2.0.12-ce26d25.tgz",
    "@agentuity/vector": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-vector-2.0.12-ce26d25.tgz",
    "@agentuity/email": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-email-2.0.12-ce26d25.tgz",
    "@agentuity/coder-tui": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-coder-tui-2.0.12-ce26d25.tgz",
    "@agentuity/claude-code": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-claude-code-2.0.12-ce26d25.tgz",
    "@agentuity/coder": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-coder-2.0.12-ce26d25.tgz",
    "@agentuity/frontend": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-frontend-2.0.12-ce26d25.tgz",
    "@agentuity/workbench": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-workbench-2.0.12-ce26d25.tgz",
    "@agentuity/queue": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-queue-2.0.12-ce26d25.tgz",
    "@agentuity/postgres": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-postgres-2.0.12-ce26d25.tgz",
    "@agentuity/server": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-server-2.0.12-ce26d25.tgz",
    "@agentuity/evals": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-evals-2.0.12-ce26d25.tgz",
    "@agentuity/drizzle": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-drizzle-2.0.12-ce26d25.tgz",
    "@agentuity/cli": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-cli-2.0.12-ce26d25.tgz",
    "@agentuity/keyvalue": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-keyvalue-2.0.12-ce26d25.tgz"
  }
}

Or install directly:

bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-db-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-runtime-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-schema-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-migrate-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-task-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-webhook-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-react-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-schedule-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-sandbox-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-opencode-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-core-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-auth-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-vector-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-email-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-coder-tui-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-claude-code-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-coder-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-frontend-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-workbench-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-queue-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-postgres-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-server-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-evals-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-drizzle-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-cli-2.0.12-ce26d25.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.12-ce26d25/agentuity-keyvalue-2.0.12-ce26d25.tgz

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/coder/README.md`:
- Around line 31-36: The README example uses client.createSession with a
workspaceId field which is not yet part of the session-create contract; remove
the workspaceId property from the example (or replace it with a supported field
like task only) so the documented usage matches the current createSession
validation, and keep the reference to workspaceSession.sessionId and
client.createSession unchanged; add a short note or TODO comment that
workspaceId will be added once the API/schema is updated.

In `@packages/core/test/coder-client.test.ts`:
- Around line 495-530: The test is asserting that CoderClient.createSession
forwards workspaceId, but CoderCreateSessionRequestSchema currently
strips/rejects that field so fetch() will never see it; either (A) update the
test to use only fields allowed by CoderCreateSessionRequestSchema (remove
workspaceId from the payload passed to CoderClient.createSession and assert the
expected body), or (B) if workspaceId must be supported, extend
CoderCreateSessionRequestSchema to include workspaceId and update
CoderClient.createSession to preserve/forward that field so the mocked fetch
receives it; locate references to CoderClient.createSession and
CoderCreateSessionRequestSchema in the diff and apply the chosen change
consistently (schema + client change for option B, or test-only change for
option A).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 73d02916-3516-4c11-b33f-d842fb30df02

📥 Commits

Reviewing files that changed from the base of the PR and between b28f9ff and 520bb4d.

📒 Files selected for processing (2)
  • packages/coder/README.md
  • packages/core/test/coder-client.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
  • GitHub Check: Framework Integration Tests (TanStack & Next.js)
  • GitHub Check: Package Installation & Usage Test
  • GitHub Check: Queue SDK Tests
  • GitHub Check: Queue CLI Tests
  • GitHub Check: Cloud Deployment Tests
  • GitHub Check: Standalone Agent Test
  • GitHub Check: Playwright E2E Smoke Test
  • GitHub Check: Template Integration Tests
  • GitHub Check: Sandbox CLI Tests
  • GitHub Check: Storage CLI Tests
  • GitHub Check: Postgres SSL Integration Test
  • GitHub Check: SDK Integration Test Suite
  • GitHub Check: Pack & Upload
  • GitHub Check: Build
  • GitHub Check: Windows WSL CLI Smoke Test
  • GitHub Check: Agentuity Deployment
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use Biome as code formatter with tabs (width 3), single quotes, semicolons, lineWidth 100, and trailingCommas es5

Files:

  • packages/core/test/coder-client.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript Strict mode with ESNext target and bundler moduleResolution
Use StructuredError from @agentuity/core for error handling

Files:

  • packages/core/test/coder-client.test.ts
**/test/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/test/**/*.{ts,tsx}: Place tests in test/ folder, never in src/ or __tests__/ directories
Import from ../src/ in test files
Use @agentuity/test-utils for mocks in tests

Files:

  • packages/core/test/coder-client.test.ts
packages/core/**/*.test.ts

📄 CodeRabbit inference engine (packages/core/AGENTS.md)

Use Bun's built-in test runner with bun test command

Files:

  • packages/core/test/coder-client.test.ts
🧠 Learnings (2)
📚 Learning: 2025-12-21T00:31:41.858Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 274
File: packages/cli/src/cmd/build/vite/server-bundler.ts:12-41
Timestamp: 2025-12-21T00:31:41.858Z
Learning: In Bun runtime, BuildMessage and ResolveMessage are global types and are not exported from the bun module. Do not import { BuildMessage } from 'bun' or similar; these types are available globally and should be used without import. This applies to all TypeScript files that target the Bun runtime within the repository.

Applied to files:

  • packages/core/test/coder-client.test.ts
📚 Learning: 2026-02-21T02:05:57.982Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 1010
File: packages/drizzle/test/proxy.test.ts:594-603
Timestamp: 2026-02-21T02:05:57.982Z
Learning: Do not rely on StructuredError from agentuity/core in test files or simple error handling paths. In tests and straightforward error handling, use plain Error objects to represent failures, reserving StructuredError for more complex error scenarios in application logic.

Applied to files:

  • packages/core/test/coder-client.test.ts

Comment thread packages/coder/README.md
Comment on lines +31 to +36
// Create a session from a saved workspace
const workspaceSession = await client.createSession({
task: 'Test workspace startup',
workspaceId: 'ws_...',
});
console.log(`Created workspace session: ${workspaceSession.sessionId}`);
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.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Don't document workspaceId until the session-create contract accepts it.

createSession() is still validated against the current session request schema, which does not include workspaceId, so this example will mislead users unless the underlying API change lands in the same PR.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/coder/README.md` around lines 31 - 36, The README example uses
client.createSession with a workspaceId field which is not yet part of the
session-create contract; remove the workspaceId property from the example (or
replace it with a supported field like task only) so the documented usage
matches the current createSession validation, and keep the reference to
workspaceSession.sessionId and client.createSession unchanged; add a short note
or TODO comment that workspaceId will be added once the API/schema is updated.

Comment on lines +495 to +530
test('createSession sends workspaceId in the request body', async () => {
mockFetch(async (url, init) => {
expect(url).toBe('https://coder.example/api/hub/session');
expect(init?.method).toBe('POST');
expect(JSON.parse(String(init?.body))).toMatchObject({
task: 'Start from workspace',
workspaceId: 'hworkspace_test123',
});
return new Response(
JSON.stringify({
sessionId: 'codesess_workspace_create',
status: 'creating',
}),
{
status: 201,
headers: { 'content-type': 'application/json' },
}
);
});

const client = new CoderClient({
apiKey: 'ag_test',
url: 'https://coder.example',
orgId: 'org_test',
});

await expect(
client.createSession({
task: 'Start from workspace',
workspaceId: 'hworkspace_test123',
})
).resolves.toMatchObject({
sessionId: 'codesess_workspace_create',
status: 'creating',
});
});
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.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

This test asserts behavior the current session schema doesn't support.

CoderClient.createSession() will only forward fields accepted by CoderCreateSessionRequestSchema, so workspaceId will be rejected or stripped before fetch() sees it unless the schema/client changes first.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/core/test/coder-client.test.ts` around lines 495 - 530, The test is
asserting that CoderClient.createSession forwards workspaceId, but
CoderCreateSessionRequestSchema currently strips/rejects that field so fetch()
will never see it; either (A) update the test to use only fields allowed by
CoderCreateSessionRequestSchema (remove workspaceId from the payload passed to
CoderClient.createSession and assert the expected body), or (B) if workspaceId
must be supported, extend CoderCreateSessionRequestSchema to include workspaceId
and update CoderClient.createSession to preserve/forward that field so the
mocked fetch receives it; locate references to CoderClient.createSession and
CoderCreateSessionRequestSchema in the diff and apply the chosen change
consistently (schema + client change for option B, or test-only change for
option A).

@potofpie potofpie changed the title Cover Coder workspace session creation Support Coder workspace snapshot inputs May 2, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/cli/src/cmd/coder/workspace/common.ts`:
- Around line 24-26: Replace the plain Error thrown when both input.setupScript
and input.setupScriptFile are provided with a StructuredError-based error:
import StructuredError from '@agentuity/core', create a factory like
SetupScriptValidationError = StructuredError('SetupScriptValidationError'), and
throw a new SetupScriptValidationError with an object containing the message
"Use either --setup-script or --setup-script-file, not both." — update the check
in the same block that references input.setupScript and input.setupScriptFile to
use this new StructuredError factory.

In `@packages/cli/src/cmd/coder/workspace/create.ts`:
- Around line 109-114: The current truthy guard after calling readSetupScript in
createWorkspace (setupScript variable in
packages/cli/src/cmd/coder/workspace/create.ts) drops valid explicit
empty-string values; change the conditional from a truthy check to an explicit
undefined check (i.e., only skip assigning when setupScript === undefined) so
that '' and other falsy but intentional values are preserved when setting
body.setupScript.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cca10220-02f6-46b4-bdc4-cc3e4df28acb

📥 Commits

Reviewing files that changed from the base of the PR and between 520bb4d and fef98fa.

📒 Files selected for processing (13)
  • packages/cli/src/cmd/coder/workspace/common.ts
  • packages/cli/src/cmd/coder/workspace/create.ts
  • packages/cli/src/cmd/coder/workspace/get.ts
  • packages/cli/src/cmd/coder/workspace/index.ts
  • packages/cli/src/cmd/coder/workspace/list.ts
  • packages/cli/src/cmd/coder/workspace/refresh.ts
  • packages/cli/src/cmd/coder/workspace/update.ts
  • packages/cli/src/cmd/coder/workspace/validate-dependencies.ts
  • packages/coder/README.md
  • packages/core/src/services/coder/client.ts
  • packages/core/src/services/coder/types.ts
  • packages/core/src/services/coder/workspaces.ts
  • packages/core/test/coder-client.test.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/coder/README.md
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
  • GitHub Check: Pack & Upload
  • GitHub Check: Build
  • GitHub Check: Sandbox CLI Tests
  • GitHub Check: Standalone Agent Test
  • GitHub Check: Windows WSL CLI Smoke Test
  • GitHub Check: Template Integration Tests
  • GitHub Check: Framework Integration Tests (TanStack & Next.js)
  • GitHub Check: Postgres SSL Integration Test
  • GitHub Check: Storage CLI Tests
  • GitHub Check: Playwright E2E Smoke Test
  • GitHub Check: Cloud Deployment Tests
  • GitHub Check: Queue CLI Tests
  • GitHub Check: Package Installation & Usage Test
  • GitHub Check: Queue SDK Tests
  • GitHub Check: SDK Integration Test Suite
  • GitHub Check: Agentuity Deployment
🧰 Additional context used
📓 Path-based instructions (8)
packages/cli/src/cmd/**/index.ts

📄 CodeRabbit inference engine (packages/cli/AGENTS.md)

packages/cli/src/cmd/**/index.ts: Each command must be structured as a directory in src/cmd/ with an index.ts file as the entry point
Always define interfaces or Zod schemas for command options; never use any type for type safety
Use tui.* helpers (header, info, success, warning, error, table, progress) for formatted TUI output instead of raw console methods
Use ctx.logger for logging instead of console methods; use logger.fatal() for fatal errors which logs and exits with code 1
Always check isJSONMode() before outputting data and provide machine-readable output when in JSON mode
Use requireAuth(ctx) for commands that require authentication or optionalAuth(ctx) for commands that support optional authentication

Files:

  • packages/cli/src/cmd/coder/workspace/index.ts
packages/cli/**/*.ts

📄 CodeRabbit inference engine (packages/cli/AGENTS.md)

Use Bun.file(f).exists() instead of existsSync(f) for file existence checks

Files:

  • packages/cli/src/cmd/coder/workspace/index.ts
  • packages/cli/src/cmd/coder/workspace/list.ts
  • packages/cli/src/cmd/coder/workspace/update.ts
  • packages/cli/src/cmd/coder/workspace/validate-dependencies.ts
  • packages/cli/src/cmd/coder/workspace/refresh.ts
  • packages/cli/src/cmd/coder/workspace/get.ts
  • packages/cli/src/cmd/coder/workspace/common.ts
  • packages/cli/src/cmd/coder/workspace/create.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use Biome as code formatter with tabs (width 3), single quotes, semicolons, lineWidth 100, and trailingCommas es5

Files:

  • packages/cli/src/cmd/coder/workspace/index.ts
  • packages/cli/src/cmd/coder/workspace/list.ts
  • packages/cli/src/cmd/coder/workspace/update.ts
  • packages/cli/src/cmd/coder/workspace/validate-dependencies.ts
  • packages/cli/src/cmd/coder/workspace/refresh.ts
  • packages/cli/src/cmd/coder/workspace/get.ts
  • packages/core/src/services/coder/workspaces.ts
  • packages/cli/src/cmd/coder/workspace/common.ts
  • packages/cli/src/cmd/coder/workspace/create.ts
  • packages/core/src/services/coder/client.ts
  • packages/core/src/services/coder/types.ts
  • packages/core/test/coder-client.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript Strict mode with ESNext target and bundler moduleResolution
Use StructuredError from @agentuity/core for error handling

Files:

  • packages/cli/src/cmd/coder/workspace/index.ts
  • packages/cli/src/cmd/coder/workspace/list.ts
  • packages/cli/src/cmd/coder/workspace/update.ts
  • packages/cli/src/cmd/coder/workspace/validate-dependencies.ts
  • packages/cli/src/cmd/coder/workspace/refresh.ts
  • packages/cli/src/cmd/coder/workspace/get.ts
  • packages/core/src/services/coder/workspaces.ts
  • packages/cli/src/cmd/coder/workspace/common.ts
  • packages/cli/src/cmd/coder/workspace/create.ts
  • packages/core/src/services/coder/client.ts
  • packages/core/src/services/coder/types.ts
  • packages/core/test/coder-client.test.ts
**/index.ts

📄 CodeRabbit inference engine (AGENTS.md)

Use named exports from package index.ts files

Files:

  • packages/cli/src/cmd/coder/workspace/index.ts
packages/core/src/**/*.ts

📄 CodeRabbit inference engine (packages/core/AGENTS.md)

packages/core/src/**/*.ts: Build TypeScript with bun run build command
Run TypeScript type checking with bun run typecheck command
Ensure runtime compatibility with both Browser and Node/Bun environments with no runtime-specific code
Build target must be ESNext with TypeScript declaration files
Prefer interfaces for public APIs
Use generics for reusable type utilities
Ensure no side effects in all exports - all exports must be pure with no global mutations
All relative imports in TypeScript files MUST include the .ts extension
Run bun run build before publishing to compile TypeScript

Files:

  • packages/core/src/services/coder/workspaces.ts
  • packages/core/src/services/coder/client.ts
  • packages/core/src/services/coder/types.ts
**/test/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/test/**/*.{ts,tsx}: Place tests in test/ folder, never in src/ or __tests__/ directories
Import from ../src/ in test files
Use @agentuity/test-utils for mocks in tests

Files:

  • packages/core/test/coder-client.test.ts
packages/core/**/*.test.ts

📄 CodeRabbit inference engine (packages/core/AGENTS.md)

Use Bun's built-in test runner with bun test command

Files:

  • packages/core/test/coder-client.test.ts
🧠 Learnings (3)
📚 Learning: 2025-12-21T00:31:41.858Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 274
File: packages/cli/src/cmd/build/vite/server-bundler.ts:12-41
Timestamp: 2025-12-21T00:31:41.858Z
Learning: In Bun runtime, BuildMessage and ResolveMessage are global types and are not exported from the bun module. Do not import { BuildMessage } from 'bun' or similar; these types are available globally and should be used without import. This applies to all TypeScript files that target the Bun runtime within the repository.

Applied to files:

  • packages/cli/src/cmd/coder/workspace/index.ts
  • packages/cli/src/cmd/coder/workspace/list.ts
  • packages/cli/src/cmd/coder/workspace/update.ts
  • packages/cli/src/cmd/coder/workspace/validate-dependencies.ts
  • packages/cli/src/cmd/coder/workspace/refresh.ts
  • packages/cli/src/cmd/coder/workspace/get.ts
  • packages/core/src/services/coder/workspaces.ts
  • packages/cli/src/cmd/coder/workspace/common.ts
  • packages/cli/src/cmd/coder/workspace/create.ts
  • packages/core/src/services/coder/client.ts
  • packages/core/src/services/coder/types.ts
  • packages/core/test/coder-client.test.ts
📚 Learning: 2026-02-17T14:23:15.448Z
Learnt from: potofpie
Repo: agentuity/sdk PR: 974
File: packages/cli/src/cmd/git/account/list.ts:39-40
Timestamp: 2026-02-17T14:23:15.448Z
Learning: In the Agentuity CLI framework (packages/cli), when a subcommand declares requires: { auth: true }, the framework will automatically call requireAuth() before invoking the handler. Do not call requireAuth(ctx) manually inside command handlers. This applies to all TypeScript command files under packages/cli/src, including paths like packages/cli/src/cmd/git/account/list.ts.

Applied to files:

  • packages/cli/src/cmd/coder/workspace/index.ts
  • packages/cli/src/cmd/coder/workspace/list.ts
  • packages/cli/src/cmd/coder/workspace/update.ts
  • packages/cli/src/cmd/coder/workspace/validate-dependencies.ts
  • packages/cli/src/cmd/coder/workspace/refresh.ts
  • packages/cli/src/cmd/coder/workspace/get.ts
  • packages/cli/src/cmd/coder/workspace/common.ts
  • packages/cli/src/cmd/coder/workspace/create.ts
📚 Learning: 2026-02-21T02:05:57.982Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 1010
File: packages/drizzle/test/proxy.test.ts:594-603
Timestamp: 2026-02-21T02:05:57.982Z
Learning: Do not rely on StructuredError from agentuity/core in test files or simple error handling paths. In tests and straightforward error handling, use plain Error objects to represent failures, reserving StructuredError for more complex error scenarios in application logic.

Applied to files:

  • packages/core/test/coder-client.test.ts
🔇 Additional comments (3)
packages/cli/src/cmd/coder/workspace/get.ts (1)

67-67: Nice reuse of shared workspace rendering

Using printWorkspaceSummary(workspace) here keeps output consistent with other workspace commands.

packages/cli/src/cmd/coder/workspace/index.ts (1)

45-47: Subcommand registration looks good

update, refresh, and validate-dependencies are correctly wired into the workspace command tree.

packages/cli/src/cmd/coder/workspace/update.ts (1)

85-152: No changes needed. The workspace command handlers correctly use tui.fatal() for error reporting and exit, which is the established pattern across all CLI command handlers in the codebase. The StructuredError guideline applies to utility functions and internal error handling, not to command handler exit paths.

			> Likely an incorrect or invalid review comment.

Comment thread packages/cli/src/cmd/coder/workspace/common.ts Outdated
Comment thread packages/cli/src/cmd/coder/workspace/create.ts
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/cli/test/cmd/coder/workspace.test.ts (1)

16-57: Replace manual process/fetch monkeypatching with @agentuity/test-utils mocks.

This test file directly monkeypatches globalThis.fetch, process.exit, and process.stderr.write instead of using the standard mocking utilities. Use @agentuity/test-utils to align with the repository's test-mocking standard for consistency and maintainability across CLI tests.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cli/test/cmd/coder/workspace.test.ts` around lines 16 - 57, The
tests are manually monkeypatching globals (globalThis.fetch, process.exit,
process.stderr.write) via helper functions like interceptFatal; replace these
with the standard mocks from `@agentuity/test-utils`: import and use its fetch,
processExit/processStderr utilities (or the documented equivalents) instead of
globalThis.fetch and interceptFatal, update tests that call interceptFatal to
use the test-utils' mock APIs to capture stderr and exit codes, and ensure
proper setup/teardown (beforeEach/afterEach or returned restore functions) so
mocks are restored after each spec; update references to makeContext only if its
opts/json shape needs adapting to the test-utils mocks.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/cli/src/cmd/coder/workspace/common.ts`:
- Around line 34-35: Wrap the raw file read of input.setupScriptFile in a
try/catch and convert any IO error into a structured validation error: instead
of letting Bun.file(input.setupScriptFile).text() throw, call it inside try {
... } and on error throw a SetupScriptValidationError (which should extend
StructuredError from `@agentuity/core` or use the existing
SetupScriptValidationError type) with a clear message, include the original
error as the cause/detail, and ensure you import StructuredError/@agentuity/core
or the existing SetupScriptValidationError symbol; update the code path that
returns the file text (the snippet referencing input.setupScriptFile and
Bun.file(...).text()) to return the text on success and throw the structured
error on failure.

---

Nitpick comments:
In `@packages/cli/test/cmd/coder/workspace.test.ts`:
- Around line 16-57: The tests are manually monkeypatching globals
(globalThis.fetch, process.exit, process.stderr.write) via helper functions like
interceptFatal; replace these with the standard mocks from
`@agentuity/test-utils`: import and use its fetch, processExit/processStderr
utilities (or the documented equivalents) instead of globalThis.fetch and
interceptFatal, update tests that call interceptFatal to use the test-utils'
mock APIs to capture stderr and exit codes, and ensure proper setup/teardown
(beforeEach/afterEach or returned restore functions) so mocks are restored after
each spec; update references to makeContext only if its opts/json shape needs
adapting to the test-utils mocks.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2ee59006-eac8-48ed-a3c9-d42f128f5109

📥 Commits

Reviewing files that changed from the base of the PR and between 50669b8 and 4410e78.

📒 Files selected for processing (3)
  • packages/cli/src/cmd/coder/workspace/common.ts
  • packages/cli/src/cmd/coder/workspace/create.ts
  • packages/cli/test/cmd/coder/workspace.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/cli/src/cmd/coder/workspace/create.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
  • GitHub Check: Sandbox CLI Tests
  • GitHub Check: Playwright E2E Smoke Test
  • GitHub Check: Queue SDK Tests
  • GitHub Check: Template Integration Tests
  • GitHub Check: Storage CLI Tests
  • GitHub Check: Queue CLI Tests
  • GitHub Check: Framework Integration Tests (TanStack & Next.js)
  • GitHub Check: Standalone Agent Test
  • GitHub Check: Postgres SSL Integration Test
  • GitHub Check: SDK Integration Test Suite
  • GitHub Check: Package Installation & Usage Test
  • GitHub Check: Cloud Deployment Tests
  • GitHub Check: Pack & Upload
  • GitHub Check: Windows WSL CLI Smoke Test
  • GitHub Check: Build
  • GitHub Check: Agentuity Deployment
🧰 Additional context used
📓 Path-based instructions (4)
packages/cli/**/*.ts

📄 CodeRabbit inference engine (packages/cli/AGENTS.md)

Use Bun.file(f).exists() instead of existsSync(f) for file existence checks

Files:

  • packages/cli/src/cmd/coder/workspace/common.ts
  • packages/cli/test/cmd/coder/workspace.test.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use Biome as code formatter with tabs (width 3), single quotes, semicolons, lineWidth 100, and trailingCommas es5

Files:

  • packages/cli/src/cmd/coder/workspace/common.ts
  • packages/cli/test/cmd/coder/workspace.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript Strict mode with ESNext target and bundler moduleResolution
Use StructuredError from @agentuity/core for error handling

Files:

  • packages/cli/src/cmd/coder/workspace/common.ts
  • packages/cli/test/cmd/coder/workspace.test.ts
**/test/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/test/**/*.{ts,tsx}: Place tests in test/ folder, never in src/ or __tests__/ directories
Import from ../src/ in test files
Use @agentuity/test-utils for mocks in tests

Files:

  • packages/cli/test/cmd/coder/workspace.test.ts
🧠 Learnings (3)
📚 Learning: 2025-12-21T00:31:41.858Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 274
File: packages/cli/src/cmd/build/vite/server-bundler.ts:12-41
Timestamp: 2025-12-21T00:31:41.858Z
Learning: In Bun runtime, BuildMessage and ResolveMessage are global types and are not exported from the bun module. Do not import { BuildMessage } from 'bun' or similar; these types are available globally and should be used without import. This applies to all TypeScript files that target the Bun runtime within the repository.

Applied to files:

  • packages/cli/src/cmd/coder/workspace/common.ts
  • packages/cli/test/cmd/coder/workspace.test.ts
📚 Learning: 2026-02-17T14:23:15.448Z
Learnt from: potofpie
Repo: agentuity/sdk PR: 974
File: packages/cli/src/cmd/git/account/list.ts:39-40
Timestamp: 2026-02-17T14:23:15.448Z
Learning: In the Agentuity CLI framework (packages/cli), when a subcommand declares requires: { auth: true }, the framework will automatically call requireAuth() before invoking the handler. Do not call requireAuth(ctx) manually inside command handlers. This applies to all TypeScript command files under packages/cli/src, including paths like packages/cli/src/cmd/git/account/list.ts.

Applied to files:

  • packages/cli/src/cmd/coder/workspace/common.ts
📚 Learning: 2026-02-21T02:05:57.982Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 1010
File: packages/drizzle/test/proxy.test.ts:594-603
Timestamp: 2026-02-21T02:05:57.982Z
Learning: Do not rely on StructuredError from agentuity/core in test files or simple error handling paths. In tests and straightforward error handling, use plain Error objects to represent failures, reserving StructuredError for more complex error scenarios in application logic.

Applied to files:

  • packages/cli/test/cmd/coder/workspace.test.ts

Comment thread packages/cli/src/cmd/coder/workspace/common.ts Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/cli/src/cmd/coder/workspace/common.ts`:
- Around line 64-73: The fallback guidance in formatWorkspaceValidationMessage
currently omits the new --setup-script-file flag; update the
EMPTY_WORKSPACE_ERROR branch in function formatWorkspaceValidationMessage to
include --setup-script-file alongside --setup-script, i.e. change the guidance
string that currently reads "Use --repo, --dependency, --setup-script, or
--enabled-agents." to include the file-backed option so users are pointed to the
correct supported flags (reference EMPTY_WORKSPACE_ERROR and the
formatWorkspaceValidationMessage function to locate the change).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8d06d509-bb61-4da0-966c-5e52e20803cc

📥 Commits

Reviewing files that changed from the base of the PR and between 4410e78 and ce26d25.

📒 Files selected for processing (2)
  • packages/cli/src/cmd/coder/workspace/common.ts
  • packages/cli/test/cmd/coder/workspace.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
  • GitHub Check: Postgres SSL Integration Test
  • GitHub Check: Playwright E2E Smoke Test
  • GitHub Check: Template Integration Tests
  • GitHub Check: Queue CLI Tests
  • GitHub Check: Framework Integration Tests (TanStack & Next.js)
  • GitHub Check: Queue SDK Tests
  • GitHub Check: Cloud Deployment Tests
  • GitHub Check: Storage CLI Tests
  • GitHub Check: Standalone Agent Test
  • GitHub Check: Sandbox CLI Tests
  • GitHub Check: SDK Integration Test Suite
  • GitHub Check: Package Installation & Usage Test
  • GitHub Check: Pack & Upload
  • GitHub Check: Windows WSL CLI Smoke Test
  • GitHub Check: Agentuity Deployment
🧰 Additional context used
📓 Path-based instructions (4)
packages/cli/**/*.ts

📄 CodeRabbit inference engine (packages/cli/AGENTS.md)

Use Bun.file(f).exists() instead of existsSync(f) for file existence checks

Files:

  • packages/cli/src/cmd/coder/workspace/common.ts
  • packages/cli/test/cmd/coder/workspace.test.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use Biome as code formatter with tabs (width 3), single quotes, semicolons, lineWidth 100, and trailingCommas es5

Files:

  • packages/cli/src/cmd/coder/workspace/common.ts
  • packages/cli/test/cmd/coder/workspace.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript Strict mode with ESNext target and bundler moduleResolution
Use StructuredError from @agentuity/core for error handling

Files:

  • packages/cli/src/cmd/coder/workspace/common.ts
  • packages/cli/test/cmd/coder/workspace.test.ts
**/test/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/test/**/*.{ts,tsx}: Place tests in test/ folder, never in src/ or __tests__/ directories
Import from ../src/ in test files
Use @agentuity/test-utils for mocks in tests

Files:

  • packages/cli/test/cmd/coder/workspace.test.ts
🧠 Learnings (3)
📚 Learning: 2025-12-21T00:31:41.858Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 274
File: packages/cli/src/cmd/build/vite/server-bundler.ts:12-41
Timestamp: 2025-12-21T00:31:41.858Z
Learning: In Bun runtime, BuildMessage and ResolveMessage are global types and are not exported from the bun module. Do not import { BuildMessage } from 'bun' or similar; these types are available globally and should be used without import. This applies to all TypeScript files that target the Bun runtime within the repository.

Applied to files:

  • packages/cli/src/cmd/coder/workspace/common.ts
  • packages/cli/test/cmd/coder/workspace.test.ts
📚 Learning: 2026-02-17T14:23:15.448Z
Learnt from: potofpie
Repo: agentuity/sdk PR: 974
File: packages/cli/src/cmd/git/account/list.ts:39-40
Timestamp: 2026-02-17T14:23:15.448Z
Learning: In the Agentuity CLI framework (packages/cli), when a subcommand declares requires: { auth: true }, the framework will automatically call requireAuth() before invoking the handler. Do not call requireAuth(ctx) manually inside command handlers. This applies to all TypeScript command files under packages/cli/src, including paths like packages/cli/src/cmd/git/account/list.ts.

Applied to files:

  • packages/cli/src/cmd/coder/workspace/common.ts
📚 Learning: 2026-02-21T02:05:57.982Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 1010
File: packages/drizzle/test/proxy.test.ts:594-603
Timestamp: 2026-02-21T02:05:57.982Z
Learning: Do not rely on StructuredError from agentuity/core in test files or simple error handling paths. In tests and straightforward error handling, use plain Error objects to represent failures, reserving StructuredError for more complex error scenarios in application logic.

Applied to files:

  • packages/cli/test/cmd/coder/workspace.test.ts
🔇 Additional comments (5)
packages/cli/src/cmd/coder/workspace/common.ts (3)

1-58: Shared setup-script helpers look solid.

The structured error wrapper, comma-list parser, and selection detection read cleanly and line up with the new CLI flows.


75-103: Workspace summary rendering looks good.

The new summary keeps the non-JSON output compact while surfacing the key workspace fields added by this PR.


60-61: The caller properly prevents empty updates by using conditional spreads and assignments.

The body object is constructed with ...(opts?.name && { name: opts.name }) and similar patterns that only add keys for truthy values. Unset options are indeed stripped before calling hasWorkspaceUpdate. The validation is actually redundant—the Zod schema includes an identical .refine() check at the schema level that validates Object.keys(input).length > 0, so the hasWorkspaceUpdate guard and schema validation both enforce the same constraint.

packages/cli/test/cmd/coder/workspace.test.ts (2)

98-305: Create-command coverage looks aligned with the new behavior.

These cases cover the updated examples, empty-selection failure, dependency parsing, inline/file setup scripts, and the setup-script conflict path without any obvious gaps.


307-426: Update, refresh, and dependency-validation coverage looks good.

The tests exercise the new PATCH, snapshot refresh, and dependency-validation flows with the expected request and response shapes.

Comment on lines +64 to +73
export function formatWorkspaceValidationMessage(issues: Array<{ message: string }>): string {
const messages = [...new Set(issues.map((issue) => issue.message).filter(Boolean))];
if (messages.length === 0) {
return 'Invalid workspace configuration';
}
if (messages.includes(EMPTY_WORKSPACE_ERROR)) {
return `${EMPTY_WORKSPACE_ERROR}. Use --repo, --dependency, --setup-script, or --enabled-agents.`;
}
return messages.join('; ');
}
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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Keep the empty-workspace guidance in sync with the supported flags.

The fallback message still omits --setup-script-file, even though the create flow now supports file-backed setup scripts. If a file resolves to empty content, this guidance points users at an incomplete set of valid inputs.

✏️ Suggested tweak
-	return `${EMPTY_WORKSPACE_ERROR}. Use --repo, --dependency, --setup-script, or --enabled-agents.`;
+	return `${EMPTY_WORKSPACE_ERROR}. Use --repo, --dependency, --setup-script, --setup-script-file, or --enabled-agents.`;
📝 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
export function formatWorkspaceValidationMessage(issues: Array<{ message: string }>): string {
const messages = [...new Set(issues.map((issue) => issue.message).filter(Boolean))];
if (messages.length === 0) {
return 'Invalid workspace configuration';
}
if (messages.includes(EMPTY_WORKSPACE_ERROR)) {
return `${EMPTY_WORKSPACE_ERROR}. Use --repo, --dependency, --setup-script, or --enabled-agents.`;
}
return messages.join('; ');
}
export function formatWorkspaceValidationMessage(issues: Array<{ message: string }>): string {
const messages = [...new Set(issues.map((issue) => issue.message).filter(Boolean))];
if (messages.length === 0) {
return 'Invalid workspace configuration';
}
if (messages.includes(EMPTY_WORKSPACE_ERROR)) {
return `${EMPTY_WORKSPACE_ERROR}. Use --repo, --dependency, --setup-script, --setup-script-file, or --enabled-agents.`;
}
return messages.join('; ');
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cli/src/cmd/coder/workspace/common.ts` around lines 64 - 73, The
fallback guidance in formatWorkspaceValidationMessage currently omits the new
--setup-script-file flag; update the EMPTY_WORKSPACE_ERROR branch in function
formatWorkspaceValidationMessage to include --setup-script-file alongside
--setup-script, i.e. change the guidance string that currently reads "Use
--repo, --dependency, --setup-script, or --enabled-agents." to include the
file-backed option so users are pointed to the correct supported flags
(reference EMPTY_WORKSPACE_ERROR and the formatWorkspaceValidationMessage
function to locate the change).

@potofpie potofpie merged commit 12634db into main May 2, 2026
19 checks passed
@potofpie potofpie deleted the feat/coder-workspace-session-sdk branch May 2, 2026 16:49
Huijiro added a commit that referenced this pull request May 4, 2026
Five test files were testing code that no longer exists in v3:

  * test/cmd/dev/backend-proxy.test.ts \u2014 v2 dev-server / Vite proxy
    behavior. The src/cmd/build/vite/vite-asset-server-config.ts module
    they import was removed when v3 dropped the v2 build pipeline.

  * test/cmd/build/vite/public-folder.test.ts \u2014 same root cause as
    backend-proxy.test.ts.

  * test/coder-config.test.ts \u2014 imports src/coder-config.ts (removed
    in v3).

  * test/hub-url.test.ts \u2014 imports src/cmd/coder/hub-url.ts (removed
    in v3).

  * test/cmd/coder/workspace.test.ts \u2014 main PR #1432 expanded this
    file to cover refresh / update / validate-dependencies subcommands
    + setup-script / dependency options on create. None of those landed
    in v3 (the subcommand source files were intentionally removed
    during the merge because they reference @agentuity/core types that
    don't exist in v3 yet). Reverted to the pre-merge version that
    matches v3's create.ts.

After this change: 619 tests pass, 0 fail (was 617 pass, 13 fail). The
removed tests were filed by the test runner as failures every PR
build; this clears that noise so the remaining suite is meaningful.
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