Skip to content

feat: consolidate config to TOML + add web edit UI - #50

Merged
bfirestone merged 14 commits into
mainfrom
feat/config-expand-and-ui
May 1, 2026
Merged

feat: consolidate config to TOML + add web edit UI#50
bfirestone merged 14 commits into
mainfrom
feat/config-expand-and-ui

Conversation

@bfirestone

Copy link
Copy Markdown
Contributor

Summary

  • Consolidate CLI + server settings into a single ~/.arc/config.toml (auto-migrates legacy cli-config.json with .bak backup + one-line stderr notice).
  • Expand arc config to manage every key via dotted paths (cli.server, server.port, share.author, etc.); adds unset and edit subcommands; legacy keys (server_url, share_author, …) emit precise "did you mean" hints.
  • Add GET/PUT /api/v1/config endpoints with field-level validation errors ({"errors": {"<dotted-key>": "<msg>"}}).
  • Add /settings page in the web UI: dirty-tracked form, per-field inline errors, "↻ requires restart" badge for server.port / server.db_path, sidebar entry rendered conditionally so arc-paste deployments degrade gracefully.
  • Server holds config in *atomic.Pointer[Config] (Store) for future hot-reload — structural readiness only; SIGHUP/fsnotify deferred to follow-up arc-0d80.073ri6.

Implementation notes

  • Renames pre-existing api.Configapi.ServerOptions to resolve a name collision with the OpenAPI-generated Config schema. The new name is also more idiomatic.
  • share.server defaults to the public arc-paste URL; resolveShareServer now treats config-tier values equal to that default as "not set" so ARC_SHARE_SERVER env var precedence remains usable.
  • Closes epic arc-0d80.06ieh3 (T0–T4).

Test plan

  • make test passes (Go: all 21 packages green)
  • bun --cwd web run check passes (0 errors, 0 warnings)
  • bun --cwd web run build passes
  • Manual: arc config list, arc config get cli.server, arc config set share.author "..." round-trip via TOML
  • Manual: arc config get server_url returns "did you mean cli.server?"
  • Manual: GET /api/v1/config returns nested config + meta; PUT validates and persists
  • Manual: /settings page loads, edits round-trip, validation errors render inline, sidebar entry visible
  • Reviewer: confirm migration on a real ~/.arc/cli-config.json works as expected

bfirestone added 14 commits May 1, 2026 15:09
Replace stale JSON config fixture in TestShareCreatePrintsPreviewURLForLocal
with a valid TOML write so cfgpkg.Load() actually uses the configured test
server URL instead of silently falling back to localhost defaults. Also add an
explicit legacyAliases map in normalizeKey so well-known pre-TOML keys
(server_url, share_author, share_server, channel) produce the correct
"did you mean <new-key>?" hint instead of a Levenshtein false-positive.
Eliminate the post-Save Load in putConfig so a transient disk-read
failure cannot mask a successful write. Also tighten test assertions:
all five top-level response keys, cli.server default value,
non-empty requires_restart, response share.author after PUT, and
explicit json.Marshal error handling.
- Add /config GET and PUT paths to OpenAPI spec with config tag
- Add Config, CLIConfig, ServerConfig, ShareConfig, UpdatesConfig, ConfigResponse, ConfigValidationError schemas
- Regenerate internal/api/openapi.gen.go with config operation handlers
- Regenerate web/src/lib/api/types.ts with Config types for T4 Settings page
- Rename api.Config -> api.NewServerConfig to resolve naming collision with generated Config schema type
- Update all server initialization call sites to use NewServerConfig
… site

Rename api.NewServerConfig to api.ServerOptions everywhere for more idiomatic
naming (echo, http, and other Go libs use Options for bootstrap structs).
Also fixes the missed call site in internal/client/client_test.go:27 that was
still referencing the old api.Config name introduced by the OpenAPI codegen
collision.
- errname: rename ValidationErrors → ValidationError (singular)
- goconst: extract dbPathKey, testAuthor, tildeDBPath constants in tests
- gofmt/gofumpt: reformat main.go and save.go
- gosec G702: nolint exec.Command in runConfigEdit ($EDITOR user-controlled)
- mnd: extract setArgsCount, dottedKeyParts consts; add DefaultServerPort
- perfsprint: errors.New in setKey; string concat in Validate
- revive comments-density: add doc comments to config.go, save.go, validate.go
- testpackage: move config/load/migrate/save/validate _test.go to config_test package; nolint api config_test
- unused: delete defaultDirPerm, defaultFilePerm, defaultConfigPath from main.go
- unhandled-error: discard fmt.Fprintf return in load.go migration notice
- line-length-limit: break long tomlBody literal in share_test.go
The auto-migration stderr notice from internal/config.Load() polluted output
in tests that asserted "no output" or parsed JSON, causing 7 failures. Switch
the setupHome fixture to write config.toml directly, matching how
cmd/arc/share_test.go and cmd/arc/self_test.go were updated in T1.
@bfirestone
bfirestone merged commit 957fb1c into main May 1, 2026
3 checks passed
@bfirestone
bfirestone deleted the feat/config-expand-and-ui branch May 1, 2026 23:57
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