Skip to content

feat: add raw openclaw config editor#828

Merged
evanjacobson merged 3 commits into
mainfrom
feat/config-editor
Mar 12, 2026
Merged

feat: add raw openclaw config editor#828
evanjacobson merged 3 commits into
mainfrom
feat/config-editor

Conversation

@tspader
Copy link
Copy Markdown
Contributor

@tspader tspader commented Mar 5, 2026

Summary

We need a way to let users get their machines out of bad states. Since we don't provide full remote access, this PR adds a widget to fetch the openclaw.json from the live machine, let the user patch it arbitrarily, and send the updated config back to the machine. OpenClaw hot reloads configs.

Details:

  • Added new controller routes, /_kilo/config/replace and /_kilo/config/read
  • Tried to separate "your instance needs to be updated to pull in the new routes" from "failed to reach instance" in the status codes
    • 401 => unauthorized
    • 404 => your instance doesn't have the route yet
    • 409 => anything else (not provisioned, unreachable)
  • Lazy load @monaco-editor/react for a reasonable inline JSON editor with highlighting + validation
  • Don't do any validation beyond "is this valid JSON"; trying to keep track of OpenClaw's config through some Zod schema that we maintain is a fool's errand
    • Similarly, the config payload is an opaque blob in the Zod schema
  • Added Edit Config to the danger zone since it is dangerous

Verification

I loaded this up in my dev environment and made sure that:

  • You can't send a malformed config
  • You CAN send a well-formed config
  • Any changed keys persist across restarts
  • Refetching the config to hand-edit again always loads the freshest config

Visual Changes

Before After
image image

And the editor proper:
image

Comment thread kiloclaw/controller/src/routes/config.test.ts Outdated
Comment thread kiloclaw/controller/src/routes/config.ts
Comment thread src/routers/kiloclaw-router.ts Outdated
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented Mar 5, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (25 files)
  • kiloclaw/DEVELOPMENT_LOCAL.md
  • kiloclaw/controller/bun.lock
  • kiloclaw/controller/package.json
  • kiloclaw/controller/src/atomic-write.test.ts
  • kiloclaw/controller/src/atomic-write.ts
  • kiloclaw/controller/src/config-writer.test.ts
  • kiloclaw/controller/src/config-writer.ts
  • kiloclaw/controller/src/proxy.test.ts
  • kiloclaw/controller/src/proxy.ts
  • kiloclaw/controller/src/routes/config.test.ts
  • kiloclaw/controller/src/routes/config.ts
  • kiloclaw/scripts/push-dev.sh
  • kiloclaw/src/durable-objects/gateway-controller-types.ts
  • kiloclaw/src/durable-objects/kiloclaw-instance/gateway.ts
  • kiloclaw/src/durable-objects/kiloclaw-instance/index.ts
  • kiloclaw/src/routes/platform.ts
  • src/app/(app)/claw/components/OpenclawConfigEditor.tsx
  • src/app/(app)/claw/components/SettingsTab.tsx
  • src/hooks/useKiloClaw.ts
  • src/lib/kiloclaw/config-redaction.test.ts
  • src/lib/kiloclaw/config-redaction.ts
  • src/lib/kiloclaw/kiloclaw-internal-client.ts
  • src/lib/kiloclaw/types.ts
  • src/lib/trpc/init.ts
  • src/routers/kiloclaw-router.ts

Reviewed by gpt-5.4-20260305 · 1,311,271 tokens

Comment thread kiloclaw/controller/src/routes/config.ts
Comment thread kiloclaw/controller/src/routes/config.ts
@tspader tspader force-pushed the feat/config-editor branch from c656b99 to 9fc642b Compare March 6, 2026 20:35
Comment thread kiloclaw/controller/src/routes/config.ts
Comment thread src/app/(app)/claw/components/OpenclawConfigEditor.tsx
Comment thread src/app/(app)/claw/components/SettingsTab.tsx
Comment thread kiloclaw/controller/src/routes/config.ts Outdated
Comment thread src/hooks/useKiloClaw.ts Outdated
Comment thread src/app/(app)/claw/components/OpenclawConfigEditor.tsx Outdated
Comment thread kiloclaw/controller/src/routes/config.ts
Comment thread src/app/(app)/claw/components/SettingsTab.tsx
Comment thread src/app/(app)/claw/components/OpenclawConfigEditor.tsx
Comment thread kiloclaw/controller/src/routes/config.test.ts
Comment thread src/routers/kiloclaw-router.ts Outdated
Comment thread kiloclaw/src/durable-objects/kiloclaw-instance.ts Outdated
Comment thread kiloclaw/src/routes/platform.ts Outdated
Comment thread kiloclaw/controller/src/config-writer.test.ts Outdated
Copy link
Copy Markdown
Contributor

@St0rmz1 St0rmz1 left a comment

Choose a reason for hiding this comment

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

Good work overall — atomic writes, etag concurrency, backup before replace, solid test coverage. Leaving inline comments on a few things worth addressing or documenting.

Comment thread kiloclaw/controller/src/routes/config.ts
Comment thread kiloclaw/src/durable-objects/kiloclaw-instance.ts Outdated
Comment thread kiloclaw/controller/src/config-writer.test.ts
Comment thread src/app/(app)/claw/components/SettingsTab.tsx
Comment thread kiloclaw/src/routes/platform.ts
Comment thread src/app/(app)/claw/components/OpenclawConfigEditor.tsx
Comment thread src/routers/kiloclaw-router.ts Outdated
Comment thread kiloclaw/controller/src/routes/config.test.ts Outdated
@evanjacobson evanjacobson self-assigned this Mar 10, 2026
Comment thread src/app/(app)/claw/components/OpenclawConfigEditor.tsx
Comment thread src/lib/kiloclaw/config-redaction.ts
Comment thread kiloclaw/src/durable-objects/kiloclaw-instance.ts Outdated
Comment thread src/lib/kiloclaw/config-redaction.ts Outdated
Comment thread src/routers/kiloclaw-router.ts
Comment thread cloudflare-code-review-infra/src/code-review-orchestrator.ts
Comment thread cloudflare-gastown/container/src/control-server.ts
@evanjacobson evanjacobson marked this pull request as draft March 11, 2026 20:31
- Add OpenclawConfigEditor component with Monaco editor
- Add config read/replace endpoints on gateway controller
- Add pattern-based secret redaction for provider apiKey fields
- Add etag support for config replace to prevent stomping
- Add atomic file writes for config changes
- Add config change detection banner
- Add comprehensive tests for config redaction and controller routes

Co-Authored-By: Thomas Spader <tspader@users.noreply.github.com>
@evanjacobson evanjacobson marked this pull request as ready for review March 11, 2026 23:50
@evanjacobson evanjacobson enabled auto-merge March 11, 2026 23:51
Comment thread src/lib/kiloclaw/config-redaction.ts Outdated
Comment thread src/routers/kiloclaw-router.ts
… codes

Remove index-based array walking in walkAndRestore() which silently
swapped secrets between entries when users reordered arrays. Placeholders
in array entries are now stripped instead of restored.

Wire up UpstreamApiError so the tRPC error formatter surfaces
upstreamCode to clients. The config editor now checks for
config_etag_conflict specifically, so non-etag 409s (e.g. "Instance not
provisioned") show the actual error instead of a misleading reload prompt.
@evanjacobson evanjacobson disabled auto-merge March 12, 2026 01:05
@evanjacobson evanjacobson enabled auto-merge March 12, 2026 01:06
Comment thread src/lib/kiloclaw/config-redaction.ts
'Gateway controller ', // already sanitized at DO level
'Config was modified ', // etag mismatch on config replace
'Invalid secret patch: ', // catalog validation (allFieldsRequired, etc.)
'Config was modified ', // etag mismatch on config replace
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.

Duplicate entry for ' 'Config was modified ' ?

Copy link
Copy Markdown
Contributor

@St0rmz1 St0rmz1 left a comment

Choose a reason for hiding this comment

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

nit (non-blocking): sanitizeOpenclawConfigError forwards code to the client on all three paths, including the generic fallback where the message is intentionally redacted. Today the codes are all safe constants (config_read_failed, config_etag_conflict, etc.), so this is fine in practice. But as a future hardening consideration, Path 3 could restrict code passthrough to the OPENCLAW_CONFIG_ERROR_CODES allow list, same as it does for messages, so a future controller change can't accidentally leak internal details via the code field:

// Current
return { message: `${operation} failed`, status, ...(code ? { code } : {}) };

// Hardened
return { message: `${operation} failed`, status, ...(code && OPENCLAW_CONFIG_ERROR_CODES.has(code) ? { code } : {}) };

Not blocking since the tRPC layer in kiloclaw-router.ts provides a second defense via UNSAFE_ERROR_CODES.

# Conflicts:
#	src/app/(app)/claw/components/SettingsTab.tsx
#	src/hooks/useKiloClaw.ts
#	src/lib/kiloclaw/kiloclaw-internal-client.ts
#	src/lib/kiloclaw/types.ts
@evanjacobson evanjacobson merged commit 5d9f36e into main Mar 12, 2026
18 checks passed
@evanjacobson evanjacobson deleted the feat/config-editor branch March 12, 2026 16:46
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.

4 participants