Skip to content

feat: add config import/export with preview and merge modes - #427

Merged
sirmalloc merged 13 commits into
sirmalloc:mainfrom
harishkarthiktk:feat/import-export-config
Jul 25, 2026
Merged

sirmalloc merged 13 commits into
sirmalloc:mainfrom
harishkarthiktk:feat/import-export-config

Conversation

@harishkarthiktk

Copy link
Copy Markdown
Contributor

Adds configuration import/export functionality with three new dialog components for exporting to JSON, importing from JSON with validation, and previewing changes before applying. Supports both replace and merge import modes with excluded key filtering.

@harishkarthiktk

Copy link
Copy Markdown
Contributor Author

I use claude code cli on multiple machines and do make changes regularly to the status line based on what I am working on. It would be nice to export/import configurations.

  • would be nice to also have a sample space/folder of configurations that people use in general

@harishkarthiktk
harishkarthiktk force-pushed the feat/import-export-config branch from fa16c52 to 8114033 Compare June 17, 2026 06:56
@qazi0

qazi0 commented Jul 25, 2026

Copy link
Copy Markdown

manually copied my configs, can we merge this @sirmalloc ?

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.
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.
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.
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.
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.
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.
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.
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.
@sirmalloc
sirmalloc merged commit ff0b16f into sirmalloc:main Jul 25, 2026
3 checks passed
@sirmalloc

Copy link
Copy Markdown
Owner

@harishkarthiktk @qazi0 I had to make a good bit of changes to this PR to accommodate several edge cases but I have it merged and just released it in v2.2.27. Thanks for the contribution.

@qazi0

qazi0 commented Jul 25, 2026

Copy link
Copy Markdown

@harishkarthiktk @qazi0 I had to make a good bit of changes to this PR to accommodate several edge cases but I have it merged and just released it in v2.2.27. Thanks for the contribution.

Thank you!

tahodev pushed a commit to tahodev/ccstatusline that referenced this pull request Oct 20, 2026
…c#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>
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.

3 participants