Skip to content

fix: apply editor settings to automations#642

Merged
ColeMurray merged 1 commit into
mainfrom
fix/automation-editor-settings
May 17, 2026
Merged

fix: apply editor settings to automations#642
ColeMurray merged 1 commit into
mainfrom
fix/automation-editor-settings

Conversation

@ColeMurray
Copy link
Copy Markdown
Owner

@ColeMurray ColeMurray commented May 14, 2026

Summary

  • Move code-server and sandbox integration resolution into a shared session helper.
  • Route automation-created sessions through initializeSession so they preserve D1-before-DO init ordering, automation lineage, and resolved editor/sandbox settings.
  • Add TDD coverage for automation lineage and resolved code-server/sandbox settings.

Verification

  • npm test -w @open-inspect/control-plane -- src/session/initialize.test.ts src/scheduler/durable-object.test.ts
  • npm run typecheck -w @open-inspect/control-plane
  • npm run lint -w @open-inspect/control-plane

Created with Open-Inspect

Summary by CodeRabbit

  • New Features

    • Sessions now track automation identifiers for improved run traceability.
  • Bug Fixes

    • Enhanced integration settings resolution with improved error handling and default fallback logic for code-server and sandbox configurations.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

📝 Walkthrough

Walkthrough

Session initialization is refactored to be configurable with per-repository integration settings. A new shared resolver module extracts code-server and sandbox setting lookups from the router. Session initialization now tracks automation lineage via new automationId and automationRunId fields. The scheduler's session creation function is refactored to use the new resolvers and initialization pattern, and the router is updated to use the shared resolvers.

Changes

Session Initialization and Integration Settings

Layer / File(s) Summary
Integration Settings Resolution Foundations
packages/control-plane/src/session/integration-settings-resolution.ts
New module exports resolveCodeServerEnabled and resolveSandboxSettings that query IntegrationSettingsStore for repository-level integration configuration, enforce allowlist semantics, and default gracefully when the database is missing or resolution fails.
Session Initialization Contract and Automation Lineage
packages/control-plane/src/session/initialize.ts, packages/control-plane/src/session/initialize.test.ts
SessionInitInput is extended with optional automationId and automationRunId fields persisted to the D1 session index. Tests validate both user-spawned (null) and automation-spawned (populated) scenarios.
Scheduler Session Creation Refactoring
packages/control-plane/src/scheduler/durable-object.ts, packages/control-plane/src/scheduler/durable-object.test.ts
createSessionForAutomation resolves integration settings concurrently and calls the shared initializeSession with consolidated parameters including automation lineage. Tests are extended with D1 mock factories and request body parsing to validate integration settings in the session init payload.
Router Integration Settings Migration
packages/control-plane/src/router.ts
Router imports resolveCodeServerEnabled and resolveSandboxSettings from the new shared module instead of defining them locally, removing the duplicated integration settings logic.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • ColeMurray/background-agents#553: Modifies the same createSessionForAutomation flow in scheduler to wire automation.user_id into session indexing, overlapping with this PR's refactoring of the same code path.
  • ColeMurray/background-agents#587: Refactors session initialization wiring to use shared initializeSession/SessionInitInput flow across router and session initialization, with this PR layering in integration-settings resolution for the init payload.

Suggested reviewers

  • open-inspect

Poem

🐰 Sessions now know their creators dear,
With automation lineage tracked and clear,
Settings resolved where they belong,
Shared across the codebase, strong!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'fix: apply editor settings to automations' directly describes the main change: extending editor/sandbox settings resolution to automation-created sessions.
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.

✨ 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/automation-editor-settings

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.

@github-actions
Copy link
Copy Markdown

Terraform Validation Results

Step Status
Format
Init
Validate

Note: Terraform plan was skipped because secrets are not configured. This is expected for external contributors. See docs/GETTING_STARTED.md for setup instructions.

Pushed by: @ColeMurray, Action: pull_request

Copy link
Copy Markdown
Contributor

@open-inspect open-inspect Bot left a comment

Choose a reason for hiding this comment

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

Summary

PR #642 fix: apply editor settings to automations by @ColeMurray updates automation-created sessions to use the shared initializeSession path and extracts editor/sandbox setting resolution into a reusable helper. Reviewed 6 changed files (+207/-109); the change looks correct and keeps the intended D1-before-DO initialization ordering.

Critical Issues

None found.

Suggestions

None blocking. Verification note: I attempted to run npm test -w @open-inspect/control-plane -- src/session/initialize.test.ts src/scheduler/durable-object.test.ts and npm run typecheck -w @open-inspect/control-plane, but this checkout does not have Node dev dependencies installed, so vitest and tsc were unavailable.

Nitpicks

None.

Positive Feedback

  • Good reuse of initializeSession, which removes a duplicated session creation path and preserves the D1-before-DO invariant for automations.
  • Automation lineage is now threaded into the shared D1 session index path and covered by focused tests.
  • The new scheduler test covers resolved code-server and sandbox settings, including repo override merging.

Questions

None.

Verdict

Approve.

Copy link
Copy Markdown

@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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/control-plane/src/session/integration-settings-resolution.ts`:
- Around line 17-24: Normalize the repo slug to a consistent case before any
store lookups and comparisons: compute a single normalized repo identifier
(e.g., use `${repoOwner}/${repoName}` and call .toLowerCase()) and pass that
normalized value into IntegrationSettingsStore.getResolvedConfig("code-server",
...) and into any allowlist checks (instead of the original mixed-case repo).
Apply the same change in the other similar block (the code around the second
getResolvedConfig usage referenced in the comment) so both the lookup and the
enabledRepos.includes check use the same normalized repo slug.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: dda19adb-23f8-47a6-a072-c0b6a20faf13

📥 Commits

Reviewing files that changed from the base of the PR and between 24ae9bf and b4a0955.

📒 Files selected for processing (6)
  • packages/control-plane/src/router.ts
  • packages/control-plane/src/scheduler/durable-object.test.ts
  • packages/control-plane/src/scheduler/durable-object.ts
  • packages/control-plane/src/session/initialize.test.ts
  • packages/control-plane/src/session/initialize.ts
  • packages/control-plane/src/session/integration-settings-resolution.ts

Comment on lines +17 to +24
const repo = `${repoOwner}/${repoName}`;
try {
const store = new IntegrationSettingsStore(db);
const { enabledRepos, settings } = await store.getResolvedConfig("code-server", repo);
const codeServerSettings = settings as CodeServerSettings;
if (codeServerSettings.enabled !== true) return false;
// enabledRepos: null -> all repos, [] -> none, [...] -> allowlist
if (enabledRepos !== null && !enabledRepos.includes(repo.toLowerCase())) return false;
Copy link
Copy Markdown

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

Normalize repo slug before store lookups to avoid case-sensitive misses.

The allowlist logic uses lowercase comparison, but getResolvedConfig(...) currently receives potentially mixed-case repo. If callers pass non-lowercase values, repo overrides can be skipped while allowlist checks still run against lowercase, producing inconsistent resolution.

Suggested fix
-  const repo = `${repoOwner}/${repoName}`;
+  const repo = `${repoOwner}/${repoName}`.toLowerCase();
   try {
     const store = new IntegrationSettingsStore(db);
     const { enabledRepos, settings } = await store.getResolvedConfig("code-server", repo);
@@
-    if (enabledRepos !== null && !enabledRepos.includes(repo.toLowerCase())) return false;
+    if (enabledRepos !== null && !enabledRepos.includes(repo)) return false;
@@
-  const repo = `${repoOwner}/${repoName}`;
+  const repo = `${repoOwner}/${repoName}`.toLowerCase();
   try {
     const store = new IntegrationSettingsStore(db);
     const { enabledRepos, settings } = await store.getResolvedConfig("sandbox", repo);
@@
-    if (enabledRepos !== null && !enabledRepos.includes(repo.toLowerCase())) return {};
+    if (enabledRepos !== null && !enabledRepos.includes(repo)) return {};

Also applies to: 43-49

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/control-plane/src/session/integration-settings-resolution.ts` around
lines 17 - 24, Normalize the repo slug to a consistent case before any store
lookups and comparisons: compute a single normalized repo identifier (e.g., use
`${repoOwner}/${repoName}` and call .toLowerCase()) and pass that normalized
value into IntegrationSettingsStore.getResolvedConfig("code-server", ...) and
into any allowlist checks (instead of the original mixed-case repo). Apply the
same change in the other similar block (the code around the second
getResolvedConfig usage referenced in the comment) so both the lookup and the
enabledRepos.includes check use the same normalized repo slug.

@ColeMurray ColeMurray merged commit 3ce0a62 into main May 17, 2026
18 checks passed
@ColeMurray ColeMurray deleted the fix/automation-editor-settings branch May 17, 2026 06:19
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