Skip to content

Add global config file editor#477

Merged
shantur merged 4 commits into
devfrom
feature/config-files-settings
May 17, 2026
Merged

Add global config file editor#477
shantur merged 4 commits into
devfrom
feature/config-files-settings

Conversation

@shantur
Copy link
Copy Markdown
Collaborator

@shantur shantur commented May 17, 2026

Summary

  • Add an allowlisted server API for editing global config files, starting with OpenCode global config.
  • Add a Config Files settings section using the existing Monaco editor with save, reload, dirty-state handling, and responsive layout.
  • Improve compact settings navigation with a full-width section selector, settings icon, and close action in the compact toolbar.

Validation

  • npm run typecheck in packages/server
  • npm run typecheck in packages/ui
  • npm run build in packages/ui

Notes

  • Existing Vite warnings about virtua JSX import source and large chunks remain unrelated.

shantur added 2 commits May 17, 2026 19:00
Add an allowlisted server API for editing known global config files so settings can read and create the OpenCode global config without exposing arbitrary filesystem writes.

Expose a Config Files settings section that reuses the Monaco file editor, supports save/reload with dirty-state confirmation, and keeps the selected file path visible inside the selector for compact layouts.

Validate the implementation with server and UI typechecks plus a UI production build; existing Vite warnings remain unrelated.
Replace the narrow tab strip at compact widths with a full-width section selector so small screens keep navigation, context, and close controls in one toolbar.

The compact toolbar hides the duplicated settings title/header, shows the settings icon, keeps the close action visible, and increases selector/dropdown text size for touch layouts.

Validated with the UI typecheck and production build before committing.
@shantur
Copy link
Copy Markdown
Collaborator Author

shantur commented May 17, 2026

@CodeNomadBot

I want you to perform the gatekeeper checks for latest PR state

check for regressions
check for better possible implementations
Be the PR gatekeeper
Be ruthless about code quality

@codenomadbot
Copy link
Copy Markdown
Contributor

codenomadbot Bot commented May 17, 2026

Request understood: strict gatekeeper review of the latest PR state for regressions, implementation quality, and merge readiness. Assumption: this is review-only; I did not modify files.

Gatekeeper verdict: changes requested.

Findings:

  1. Blocking: saving can mark unsaved edits as saved if the user keeps editing while the save request is in flight.

packages/ui/src/components/settings/config-files-settings-section.tsx:94-103

handleSave sends content() to the server, then after await calls setOriginalContent(content()). Because the Monaco editor remains editable during the request, any edits made after the request starts but before it resolves become the new originalContent, even though those bytes were never written to disk. The UI will show a clean state while the file on disk is stale. Capture the payload before the request and only clear dirty state for that exact payload, or disable editing/navigation during save.

  1. Blocking: users can lose unsaved config edits by leaving the Config Files section or closing settings.

packages/ui/src/components/settings/config-files-settings-section.tsx:52-60
packages/ui/src/components/settings-screen.tsx:90
packages/ui/src/components/settings-screen.tsx:162
packages/ui/src/components/settings-screen.tsx:184

The discard confirmation is only used for file selection changes and reload. The settings section selector, sidebar nav buttons, and close buttons bypass it, so switching to another settings section or closing the dialog discards the in-memory Monaco edits without warning. That contradicts the PR’s dirty-state handling goal and is a high-risk regression for a config editor.

  1. Quality gap: the new filesystem write API has no server-side tests.

packages/server/src/server/routes/config-files.ts:51-90

This route creates directories and writes an allowlisted global config file. There should be focused coverage for the allowlist/404 behavior, missing-file read behavior, directory creation on write, and write error handling. This is a sensitive endpoint that edits files outside the workspace, so relying only on UI/manual validation is not enough.

Validation attempted:

  • npm run typecheck in packages/server: failed before PR-specific checking because this checkout is missing Node type definitions (Cannot find type definition file for 'node').
  • npm run typecheck in packages/ui: failed before PR-specific checking with missing dependency/type declarations such as solid-js, @opencode-ai/sdk, Tauri packages, and Node test types.

Additional note:

  • The added non-English locale keys for settings.configFiles.* appear to be English fallback text in every locale. That may be acceptable as an incremental i18n placeholder, but it is worth cleaning up before release if this UI is user-facing in those locales.

--
Yours,
CodeNomadBot

Prevent save completion from clearing edits made while a request is in flight by only marking the saved payload clean when the editor still matches it.

Add a reusable settings dirty guard so section navigation and dialog close paths confirm before discarding unsaved config edits.

Make the config-file route injectable and add focused tests for allowlisted listing, missing-file reads, directory creation on write, unknown ids, and write failures.

Validated with the focused config route test, server typecheck, UI typecheck, and UI production build.
@shantur
Copy link
Copy Markdown
Collaborator Author

shantur commented May 17, 2026

@CodeNomadBot

Check again

@github-actions
Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/25998702397

Artifacts expire in 7 days.
Artifacts:

  • pr-477-27ecdda5b52921027af0a1aa1700e1c95768a7e0-tauri-linux
  • pr-477-27ecdda5b52921027af0a1aa1700e1c95768a7e0-tauri-windows
  • pr-477-27ecdda5b52921027af0a1aa1700e1c95768a7e0-electron-macos
  • pr-477-27ecdda5b52921027af0a1aa1700e1c95768a7e0-tauri-macos-arm64
  • pr-477-27ecdda5b52921027af0a1aa1700e1c95768a7e0-electron-windows
  • pr-477-27ecdda5b52921027af0a1aa1700e1c95768a7e0-electron-linux

@codenomadbot
Copy link
Copy Markdown
Contributor

codenomadbot Bot commented May 17, 2026

Request understood: re-check the latest PR state after the new push, with the same strict gatekeeper lens. Assumption: review-only; I did not modify files.

Gatekeeper verdict: no code-level blockers found in the latest diff.

What changed since the prior review:

  • The save race is addressed in packages/ui/src/components/settings/config-files-settings-section.tsx:95-106 by capturing payload = content() before the async write and only clearing dirty state if the editor content still matches that payload.
  • The section-switch/close data-loss path is addressed through packages/ui/src/stores/settings-dirty-guard.ts plus guarded calls in packages/ui/src/components/settings-screen.tsx:75-83, settings-screen.tsx:102, settings-screen.tsx:174, and settings-screen.tsx:196.
  • Server-side route coverage was added in packages/server/src/server/routes/config-files.test.ts for descriptor listing, missing-file reads, directory creation on write, unknown IDs, and write failures.

Residual risks / follow-ups:

  • I still could not complete local validation in this checkout because dependencies/types are missing. npm run typecheck in packages/server fails on missing Node type definitions, npm run typecheck in packages/ui fails on missing Solid/SDK/Tauri/etc. declarations, and npm run build in packages/ui fails because vite is not installed. These look environment/dependency-related, not necessarily PR-introduced, but they mean I cannot independently certify the declared validation here.
  • The new config-files.test.ts is valuable, but I do not see an npm test script in packages/server/package.json or the root package.json that would run it. If CI does not invoke node --test/tsx --test separately, this coverage may not actually execute.
  • There is an existing naming inconsistency worth verifying before release: this PR edits ~/.config/opencode/opencode.json, while existing UI copy references provider config in opencode.jsonc. If OpenCode expects .jsonc for the global config in current supported versions, this editor would target the wrong file. I did not find enough in-repo evidence to call this a blocker, but it is the one semantic detail I would double-check.

No new regressions found in the updated dirty-state implementation during static review.

--
Yours,
CodeNomadBot

Add the OpenCode JSONC global config file to the allowlist and use the USERPROFILE .config path convention for Windows display and writes.

Give the Config Files Monaco editor a compact gutter that sizes line-number space from the current line count while keeping the right-drawer editor unchanged.

Validated with config-file route tests plus server and UI typechecks.
@shantur
Copy link
Copy Markdown
Collaborator Author

shantur commented May 17, 2026

@CodeNomadBot

Check again now

@github-actions
Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/25999086643

Artifacts expire in 7 days.
Artifacts:

  • pr-477-1a288c4c0caaa600a9f680f25493014acb5778e2-tauri-windows
  • pr-477-1a288c4c0caaa600a9f680f25493014acb5778e2-electron-macos
  • pr-477-1a288c4c0caaa600a9f680f25493014acb5778e2-tauri-macos-arm64
  • pr-477-1a288c4c0caaa600a9f680f25493014acb5778e2-electron-windows
  • pr-477-1a288c4c0caaa600a9f680f25493014acb5778e2-electron-linux

@codenomadbot
Copy link
Copy Markdown
Contributor

codenomadbot Bot commented May 17, 2026

Request understood: re-check the latest PR state after the newest push, with the same strict gatekeeper lens. Assumption: review-only; I did not modify files.

Gatekeeper verdict: no code-level blockers found in the latest diff.

What changed since the previous re-check:

  • The config target concern is addressed by exposing both ~/.config/opencode/opencode.json and ~/.config/opencode/opencode.jsonc in packages/server/src/server/routes/config-files.ts:20-56.
  • The server route tests were updated to cover both descriptors in packages/server/src/server/routes/config-files.test.ts:20-48.
  • The Monaco editor now supports compact gutter sizing through compactGutter in packages/ui/src/components/file-viewer/monaco-file-viewer.tsx:13 and monaco-file-viewer.tsx:45-49, with the config editor opting in at packages/ui/src/components/settings/config-files-settings-section.tsx:213-220.

Prior findings status:

  • Save race: still fixed. handleSave captures the payload before awaiting and only clears dirty state if the current content still matches the saved payload.
  • Section/close data loss: still fixed. Settings navigation and close continue to route through confirmSettingsDiscard().
  • Config route tests: present and expanded for JSON + JSONC descriptors.
  • opencode.json vs opencode.jsonc: resolved by listing both files.

Validation attempted again:

  • npm run typecheck in packages/server: still fails before PR-specific checking because this checkout is missing Node type definitions (Cannot find type definition file for 'node').
  • npm run typecheck in packages/ui: still fails before PR-specific checking because this checkout is missing dependency/type declarations such as solid-js, @opencode-ai/sdk, Tauri packages, and Node test types.
  • npm run build in packages/ui: still fails before PR-specific checking because vite is not installed in this checkout.

Residual non-blocking risk:

  • I still do not see an npm test script in packages/server/package.json or root package.json that obviously runs packages/server/src/server/routes/config-files.test.ts. If CI invokes Node tests separately, fine; otherwise this new coverage may not execute automatically.

No new regressions found in the latest static review.

--
Yours,
CodeNomadBot

@shantur shantur merged commit ee069bf into dev May 17, 2026
11 checks passed
@shantur shantur deleted the feature/config-files-settings branch May 17, 2026 18:44
@github-actions
Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/25999445077

Artifacts expire in 7 days.
Artifacts:

  • pr-477-3509ccadd97c018068912452b0d2075b91894934-tauri-linux
  • pr-477-3509ccadd97c018068912452b0d2075b91894934-tauri-macos
  • pr-477-3509ccadd97c018068912452b0d2075b91894934-tauri-windows
  • pr-477-3509ccadd97c018068912452b0d2075b91894934-electron-macos
  • pr-477-3509ccadd97c018068912452b0d2075b91894934-tauri-macos-arm64
  • pr-477-3509ccadd97c018068912452b0d2075b91894934-electron-windows
  • pr-477-3509ccadd97c018068912452b0d2075b91894934-electron-linux

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