Skip to content

Decouple domain and storage code from TUI presentation - #35

Merged
polymorcodeus merged 1 commit into
mainfrom
api-decoupling
Sep 23, 2026
Merged

polymorcodeus merged 1 commit into
mainfrom
api-decoupling

Conversation

@polymorcodeus

Copy link
Copy Markdown
Owner

Summary

Adds a storage/UI config split and relocates all presentation concerns (spinners, styled errors, CLI renderers) out of internal/book, internal/catalog, and internal/web into cmd/book and internal/theme. Completes Phase 0 of the pkg/book extraction; CLI behavior is unchanged.

What's new

  • theme.UIConfig - embeds *book.Config and carries runtime presentation state (Theme, Templates) plus LoadTheme, LoadTemplates, and StyledError; book.Config is now storage-only and internal/book imports stdlib + toml only.
  • Spinner wrappers in cmd/book/spinner.go - loadCatalog and loadWebsite replace catalog.LoadCatalog and web.LoadWebsite; internal/catalog and internal/web no longer import huh or the spinner.
  • CLI renderers in cmd/book/catalog.go - dumpDefaults and printConfigSources move out of internal/catalog as the book catalog theme|template|config implementations, ending the storage layer's theme dependency.
  • book.MarshalCatalog - replaces PrintCatalog with a pure ([]byte, error) marshaler; cmd call sites print via the printCatalog helper.

Behavior changes / guardrails

  • No user-facing changes: catalog config output and catalog theme/template dumps verified byte-identical against the previous binary.
  • catalog.ResolveWritePath is newly exported so the relocated dumpDefaults keeps symlink-aware writes; CreateTOML shares the same resolution path.
  • Storage-only functions (gc, doctor, migrate, indexCache) keep *book.Config signatures; cmd actions and TUI constructors take *theme.UIConfig and hand the embedded config to storage calls.

Testing

  • New TestMarshalCatalog table test covers json, toml, and empty formats; TestUIConfigStyledError covers interactive and plain rendering.
  • Smoke-tested shelf/collection/mark add, list, search, get, remove, restore, plus index rebuild, index sync, doctor, and gc against the previous binary.
  • make check runs fmt, vet, lint, and tests; all green.

@polymorcodeus polymorcodeus self-assigned this Sep 22, 2026
@polymorcodeus
polymorcodeus merged commit 82d9669 into main Sep 23, 2026
4 checks passed
@polymorcodeus
polymorcodeus deleted the api-decoupling branch September 23, 2026 00:20
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