Skip to content

chore: audit cleanup leftovers — generate-views/node->hiccup splits + tests#14

Merged
avanelsas merged 3 commits intomainfrom
chore/audit-cleanup-leftovers
Apr 30, 2026
Merged

chore: audit cleanup leftovers — generate-views/node->hiccup splits + tests#14
avanelsas merged 3 commits intomainfrom
chore/audit-cleanup-leftovers

Conversation

@avanelsas
Copy link
Copy Markdown
Owner

Summary

Three commits picking up the open items from the 2026-04-23 audit
that weren't closed by the time of the v0.1.0 cleanup arc, plus
unit coverage for the v0.2.0 modules that landed without test
files. No behaviour change, no document-model change, no plugin
contract change.

Commits

  • Tests for cheat-sheet/group-rows + command-palette pure
    helpers
    — promotes group-rows / curated-commands /
    wrap-commands / ->item from defn- to defn so unit tests can
    pin the shape (label / group / run! present, no duplicate
    labels, ->item synthetic id format) without going through the
    modal lifecycle. 13 new tests, 40 new assertions; test count
    571 → 584.

  • Decompose generate-views: extract view-context data bundle
    — generate-views was 161 lines mixing data derivation (sub-
    groups, read fields, payload fields, four kinds of aliases,
    fn signature, ns-clause requires) with output formatting.
    view-context (private, ~140 lines) does the assembly and
    returns a known-shape map; generate-views shrinks to ~45 lines
    reading as a sequence of formatting steps. Same recipe as the
    already-landed generate-core split.

  • Decompose node->hiccup-with-events into walk + emit
    helpers
    — node->hiccup-with-events was 123 lines doing four
    jobs at once. emit-sub-group-child (~40 lines) renders one
    sub-group child; walk-slotted-children (~29 lines) is the
    reduce-over-slots loop; node->hiccup-with-events shrinks to
    ~77 lines and reads as props → text → children → output
    assembly.

Test plan

  • cljfmt check — clean
  • npx shadow-cljs compile test — 584 tests, 0 failures
  • npx shadow-cljs release app — 0 warnings under Closure Advanced
  • clj-kondo — 0 errors, 0 warnings

The cljs-project parity tests in test/bareforge/export/cljs_project_test.cljs
are the safety net for both refactors. Any behavioural drift in
the emitted CLJS project would have failed one of those.

🤖 Generated with Claude Code

avanelsas and others added 3 commits April 30, 2026 11:10
Adds unit coverage for the v0.2.0 modules that landed without
test files. Pure helpers only — modal mounting, focus management,
and the x-command-palette wiring stay browser-only and out of
unit scope.

cheat-sheet:
- group-rows promoted from defn- to defn so tests can pin its
  output without going through the modal lifecycle.
- 5 tests cover empty info, single category, declared-order
  preservation, dropped-empty-category, and a smoke test against
  the live shortcut-info / category-labels data.

command-palette:
- curated-commands, wrap-commands, ->item promoted to defn.
- ->item: 3 tests cover field projection, synthetic id format,
  keywords-default-to-empty-string.
- curated-commands: 3 tests cover shape, label uniqueness,
  group whitelist.
- wrap-commands: 2 tests cover shape and label-references-tag.

Test count moves 571 → 584 (13 new tests, 40 new assertions).
Gates green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
generate-views was 161 lines mixing data derivation (sub-groups,
read fields, payload fields, four kinds of aliases, function
signature, ns-clause requires) with output formatting (the file
string). The audit's recipe — the same one already applied to
generate-core — was to split data assembly from orchestration.

view-context (private, ~140 lines) does the assembly and returns
a known-shape map: :fn-name :ns-path :fn-sig :require-entries
:hiccup-ctx :node :root-slot :let-fields :field->owner :has-let?

generate-views shrinks to ~45 lines: destructures the bundle,
builds the ns-clause string, threads has-let?/let-fields/
hiccup-ctx into the body string, returns the file content.

The data assembly is still big — every derived datum is needed
exactly once and they cross-reference enough that further
splitting would multiply argument lists. The split's value is
that the orchestrator is now a readable sequence of steps
without 25 derived locals in scope.

cljs_project_test.cljs's parity tests are the safety net; all
584 tests still pass (0 failures), 0 release-build warnings,
0 lint warnings.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
node->hiccup-with-events was 123 lines doing four jobs at once:
build the props map, resolve text from text-field or :text, walk
the children across slots with sub-group / template dispatch, and
assemble the final hiccup string. The children walk was the
gnarliest part — 50 lines of nested cond + let inside a reduce.

emit-sub-group-child (~40 lines) renders one sub-group child:
either a singleton view call or a template iteration. Returns
[rendered-or-nil rendered-tpls'] so the caller can dedupe
templates within a parent slot — the first encounter renders,
later ones return nil so a parent with N seed-backed clones
still emits one iteration.

walk-slotted-children (~29 lines) is the reduce-over-slots loop;
sub-group children dispatch through emit-sub-group-child,
non-group children recurse via node->hiccup-with-events.

node->hiccup-with-events shrinks to ~77 lines and reads as
props → text → children → output assembly, four single-purpose
steps. The recursive cycle (node->hiccup-with-events ↔
walk-slotted-children) is bridged by a forward `declare`.

cljs_project parity tests are the safety net; 584 tests still
pass, 0 release-build warnings, 0 lint warnings, formatting
clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@avanelsas avanelsas merged commit 354248f into main Apr 30, 2026
1 check passed
@avanelsas avanelsas deleted the chore/audit-cleanup-leftovers branch April 30, 2026 09:32
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