Files
OneHTW ff0b16f1bb feat: add config import/export with preview and merge modes (#427)
* feat: add config import/export with preview and merge modes

* feat: add config import/export with preview and merge modes

* Temp personal configurations addeed.

* fix(config): export live TUI settings

Pass the current in-memory Settings object into exportConfig instead of reloading settings.json from disk. This ensures unsaved TUI edits are included in exported files and keeps the export callback synchronized with current React state.

Add a regression test with intentionally stale on-disk data to verify the provided configuration is exported, along with the exporter version metadata.

* fix(config): preserve omitted settings during merge import

Record the keys that were actually present in the validated import payload before schema defaults obscure their absence. Pass that key set through the TUI import flow and restrict merge mode to explicitly supplied settings.

Replace mode continues to receive a fully validated settings object, while merge mode no longer resets lines, width behavior, thresholds, or other customizations omitted from a partial import. Add a regression test covering a partial current-version payload.

* fix(config): retain installation metadata on replace import

Restore the current installation metadata after filtering machine-local fields from imported configuration. Replace All can now replace user-facing settings without erasing pinned or self-managed install classification used by update and version-mismatch safeguards.

Add regression coverage showing that imported installation metadata is ignored and the active local pinned metadata survives while ordinary imported settings are still applied.

* fix(tui): preview settings added by imports

Build import-preview keys from the union of current and validated imported settings rather than only the current configuration. Optional values such as separators, padding, and color overrides are now displayed when an import introduces them.

Extract the key selection into a focused helper and add regression coverage for multiple imported-only optional settings while continuing to filter machine-local metadata.

* fix(tui): keep import preview in dynamic output

Render diff rows inside a normal column Box instead of Ink Static. Canceling, applying, or reopening an import now allows Ink to erase and replace the preview rather than permanently committing stale rows above the active interface.

Add a structural regression test asserting that the preview row region uses the dynamic Box component.

* fix(tui): synchronize Chalk after config import

Apply imported settings in the user-event handler, update the module-wide Chalk level from the resulting configuration, and then publish the same settings object to React state. Imported color capability changes now affect previews and color UI immediately, including No Color mode.

Keep the side effect outside the React state updater and add regression coverage that verifies both the imported setting and Chalk global state change together.

* fix(tui): preview effective merge settings

Build the import preview from applyImport using the currently highlighted action. Merge previews now preserve values omitted from partial payloads instead of presenting schema defaults as changes, while Replace All continues to show the fully validated replacement result.

Track Replace All and Merge selection changes in the dialog so the displayed diff always matches the action Enter will apply. Add focused coverage for omitted merge fields and an Ink interaction regression test that verifies the preview updates when Merge is highlighted.

* fix(config): reject imports from newer schemas

Check an imported config's declared version before migration or current-schema parsing. Files produced by a newer ccstatusline release now return an explicit validation error instead of having unknown settings stripped and missing values replaced with this release's defaults.

Add regression coverage with a future-version payload containing an unsupported field, asserting that validation fails with both the imported and supported schema versions in the diagnostic.

---------

Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
2026-07-25 18:45:34 -04:00
..