Skip to content

feat: inject workspace config into daemon sessions#86

Merged
arek-e merged 1 commit intomainfrom
feat/workspace-session-injection
Apr 4, 2026
Merged

feat: inject workspace config into daemon sessions#86
arek-e merged 1 commit intomainfrom
feat/workspace-session-injection

Conversation

@arek-e
Copy link
Copy Markdown
Owner

@arek-e arek-e commented Apr 4, 2026

Summary

When a daemon is linked to a workspace, session env vars are now injected:

PAWS_WORKSPACE_NAME=paws
PAWS_WORKSPACE_TYPE=monorepo
PAWS_WORKSPACE_REPO=arek-e/paws
PAWS_WORKSPACE_ROOT_DIR=/
PAWS_WORKSPACE_BRANCH=main
PAWS_CLONE_URL=https://github.com/arek-e/paws.git
PAWS_WORKSPACE_LANGUAGE=typescript
PAWS_WORKSPACE_PACKAGE_MANAGER=bun

For multi-repo workspaces, also injects PAWS_WORKSPACE_REPOS (comma-separated).

Works at both dispatch sites: webhook/schedule triggers and GitHub PR triggers.

Test plan

  • 0 lint errors, 42/42 typecheck, 31/31 tests
  • CI green

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Sessions now automatically inject workspace-specific environment variables, including repository details, clone URLs, and settings-derived configuration (language, package manager, test/build commands).
    • GitHub app webhook-triggered sessions now include enriched workspace context for improved session initialization.
    • Multi-repository workspace support with aggregated repository information injected into session environments.

When a daemon is linked to a workspace, inject PAWS_WORKSPACE_* env vars
into the session workload: name, type, repo, branch, root dir, clone URL,
language, package manager, test/build commands. Works for both webhook
triggers and GitHub PR triggers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 4, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fe63bfc0-c11f-42f5-8035-5598b08c2cc4

📥 Commits

Reviewing files that changed from the base of the PR and between 4b19098 and 4d194fc.

📒 Files selected for processing (3)
  • apps/control-plane/src/app.ts
  • apps/control-plane/src/store/daemons.ts
  • packages/integrations/src/types.ts

📝 Walkthrough

Walkthrough

This pull request adds workspace-aware environment injection into session and workload dispatch. A new helper function computes workspace-derived environment variables (including repository details and build/test commands) and injects them into workload environments during session creation for both daemon-triggered and GitHub webhook-triggered sessions. Type definitions are updated to include an optional workspace field on daemon interfaces.

Changes

Cohort / File(s) Summary
Workspace Environment Injection
apps/control-plane/src/app.ts
Added injectWorkspaceEnv() helper to compute and merge PAWS_WORKSPACE_* environment variables from workspace store. Updated daemon-triggered and GitHub webhook session creation to inject workspace env into workload.env; gracefully falls back to original env if workspace is missing or lookup fails.
Type Definitions
apps/control-plane/src/store/daemons.ts, packages/integrations/src/types.ts
Added optional workspace?: string field to StoredDaemon and GitHubDaemon interfaces. No changes to persistence or mapping logic.

Sequence Diagram

sequenceDiagram
    actor Webhook as GitHub Webhook
    participant ControlPlane as Control Plane
    participant WorkspaceStore as Workspace Store
    participant SessionMgr as Session Manager
    
    Webhook->>ControlPlane: POST /v1/webhooks/github
    ControlPlane->>WorkspaceStore: Lookup workspace (daemon.workspace)
    alt Workspace Found
        WorkspaceStore-->>ControlPlane: Workspace config + repos
        ControlPlane->>ControlPlane: injectWorkspaceEnv()<br/>(compute PAWS_WORKSPACE_*)
        ControlPlane->>ControlPlane: Merge into workload.env
    else Workspace Not Found
        WorkspaceStore-->>ControlPlane: null/undefined
        ControlPlane->>ControlPlane: Return original env unchanged
    end
    ControlPlane->>SessionMgr: Create sessionRequest<br/>with enriched workload.env
    SessionMgr-->>ControlPlane: Session created
    ControlPlane-->>Webhook: Success response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 A workspace bloom unfolds today,
Where env vars dance and play,
From daemon's nest to session's keep,
Workspace secrets flow so deep!

✨ 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 feat/workspace-session-injection

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

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying getpaws with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4d194fc
Status: ✅  Deploy successful!
Preview URL: https://0006e4cd.getpaws-6m4.pages.dev
Branch Preview URL: https://feat-workspace-session-injec.getpaws-6m4.pages.dev

View logs

@arek-e arek-e merged commit 2ce6e4a into main Apr 4, 2026
2 of 3 checks passed
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