feat: consolidate config to TOML + add web edit UI - #50
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
~/.arc/config.toml(auto-migrates legacycli-config.jsonwith.bakbackup + one-line stderr notice).arc configto manage every key via dotted paths (cli.server,server.port,share.author, etc.); addsunsetandeditsubcommands; legacy keys (server_url,share_author, …) emit precise "did you mean" hints.GET/PUT /api/v1/configendpoints with field-level validation errors ({"errors": {"<dotted-key>": "<msg>"}})./settingspage in the web UI: dirty-tracked form, per-field inline errors, "↻ requires restart" badge forserver.port/server.db_path, sidebar entry rendered conditionally so arc-paste deployments degrade gracefully.*atomic.Pointer[Config](Store) for future hot-reload — structural readiness only; SIGHUP/fsnotify deferred to follow-up arc-0d80.073ri6.Implementation notes
api.Config→api.ServerOptionsto resolve a name collision with the OpenAPI-generatedConfigschema. The new name is also more idiomatic.share.serverdefaults to the public arc-paste URL;resolveShareServernow treats config-tier values equal to that default as "not set" soARC_SHARE_SERVERenv var precedence remains usable.Test plan
make testpasses (Go: all 21 packages green)bun --cwd web run checkpasses (0 errors, 0 warnings)bun --cwd web run buildpassesarc config list,arc config get cli.server,arc config set share.author "..."round-trip via TOMLarc config get server_urlreturns "did you mean cli.server?"GET /api/v1/configreturns nested config + meta;PUTvalidates and persists/settingspage loads, edits round-trip, validation errors render inline, sidebar entry visible~/.arc/cli-config.jsonworks as expected