Skip to content

feat: chart subcommands, remove global FlagState, and drop --scale from root#129

Merged
fahimfaisaal merged 3 commits into
mainfrom
feat/chart-subcommands
Jun 16, 2026
Merged

feat: chart subcommands, remove global FlagState, and drop --scale from root#129
fahimfaisaal merged 3 commits into
mainfrom
feat/chart-subcommands

Conversation

@fahimfaisaal

@fahimfaisaal fahimfaisaal commented Jun 16, 2026

Copy link
Copy Markdown
Member

Summary

  • Replaces the mutable global shared.FlagState with typed per-command option structs (CommonOptions, LinearOptions, ChartOptions) passed explicitly through the pipeline
  • Introduces vizb bar|line|pie|heatmap|radar subcommands, each self-registering via init() into a CLI registry — users can now target a single chart type directly without --charts
  • Removes the global --scale flag from the root command; scale is now per-chart only (-S on bar/line, or --chart bar:scale=log for overrides) since pie/heatmap/radar don't support it
  • Parsers refactored to accept an explicit parser.Config instead of reading from global state

Add independent chart subcommands (bar, line, pie, heatmap, radar) that
each expose only the flags valid for that chart. bar/line carry --scale
and --rotate; pie/heatmap/radar omit them by struct composition, so the
restriction is enforced at compile time rather than via a runtime
exclusion map.

Architecture (Approach C):
- Delete the global shared.FlagState. Parsers become pure functions of
  (input, parser.Config): ParseFunc gains a parser.Config arg and
  GroupAxes/GroupBenchmarkName/ShouldIncludeBenchmark take config.
- New cmd/cli package: a self-registration registry, composable option
  groups (CommonOptions -> LinearOptions -> ChartOptions), and one shared
  RunLinear pipeline. Output/progress helpers move here too.
- Chart subcommands live in cmd/charts/<type> and self-register via
  init(), mirroring how pkg/parser parsers register; root blank-imports
  them. A future non-linear chart type plugs in the same way.
- Root keeps multi-chart --charts and the --chart per-chart override
  (no breaking change). ui and merge are de-globalized to local options.

Tests: refactor-touched test files converted to testify/suite; SetupTest
builds parser.Config / resets state, removing the previous order
fragility. Docs add a consolidated chart-subcommands page.
@fahimfaisaal fahimfaisaal changed the title feat(cmd): per-chart subcommands, remove global FlagState, and drop --scale from root feat: chart subcommands, remove global FlagState, and drop --scale from root Jun 16, 2026
@fahimfaisaal
fahimfaisaal merged commit ccdac51 into main Jun 16, 2026
1 check passed
@fahimfaisaal
fahimfaisaal deleted the feat/chart-subcommands branch June 16, 2026 13:53
fahimfaisaal added a commit that referenced this pull request Jun 16, 2026
Resolves structural divergence introduced by PR #129 (squashed into ccdac51 on main). The 3f60897 sync commit pre-merged only the --scale flag removal, CommonOptions field reorder, and 3D bevel/line cosmetic tweaks. The deeper refactors from #129 (LinearDefaults, ChartSelection, ParseChartSpecs, DatasetSettings{Charts,Axes,ChartSettings,Sort,Scale,ShowLabels}) are superseded by settings-architecture's per-chart Config registry (config/charts/{bar,line,pie,heatmap,radar}/Materialise).

All 20 unmerged files resolved in favour of the new architecture per design spec docs/superpowers/specs/2026-06-16-settings-architecture-design.md:

  cmd/charts/{bar,heatmap,line,pie,radar}/{name,_test}.go  (10 files)
  cmd/cli/{options_test,pipeline,pipeline_test}.go         (3 files)
  cmd/{root,root_test,ui,ui_test}.go                       (4 files)
  pkg/template/vizb-ui.gen.go                              (1 file)
  shared/{chart_spec,chart_spec_test}.go                   (2 files)

Audit: test counts match 1:1 across branches; the two architectures are mutually exclusive at the type/function signature level, so no test cases from main port over. go build ./... and go test -count=1 ./... pass.
fahimfaisaal added a commit that referenced this pull request Jun 17, 2026
…stry panel (#130)

- **Wire format**: `Dataset.Settings` is now `[]config_charts.ChartConfig` (typed per-chart: bar/line/pie/heatmap/radar). v0.12.0 files are auto-migrated in-memory on read via `shared.MigrateDataset`. See CHANGELOG 0.13.0.
- **Per-chart config registry** (`config/charts/`): `ChartConfig` interface + `Register`/`New`/`Decode`/`Registered`/`Factory`. Each chart subdir (`bar`, `line`, …) self-registers via `init()`. `Materialise(flags, *Config)` is the typed build entry point.
- **CLI refactor**: replaces `shared.FlagState` with `cli.CommonOptions` → `LinearOptions` → per-chart options; `vizb bar|line|pie|heatmap|radar` subcommands self-register via `init()`. The per-chart subcommand `Run` calls `Materialise` and passes the typed `*Config` to a new `cli.RunSingleChart(cmd, args, common, configs)`. `assembleDataset` / `applySelections` now set `dataSet.Settings = configs` directly. Re-introduces the `cli.ValidateScale` call that the previous per-chart-subcommand refactor had dropped.
- **UI panel**: schema-less `SettingsPanel` walks a `fieldRegistry` (`appliesTo: ChartType[]` + `appliesOn: Dimension[]` per field) and renders the registered control for each known key. Adding a field is one registry entry + one Vue file; new chart types ride along automatically. `autoRotate` declares `appliesOn: ['3D']` and is hidden for 2D data.
- **Chart-type picker** auto-switches from a tabs row to an icon+name combobox when the active dataset exposes more than 3 chart types (constant `CHART_PICKER_TAB_THRESHOLD = 3`).
- **Bug fixes**: `setScale`/`setAutoRotate` no longer silently no-op on freshly migrated configs (the `'X' in cfg` guard was removed); `useDataPoint` keeps settings reactive by only `markRaw`-ing the rows (the data field), not the whole DataSet; the swap handler now calls `useDataPoint.setArrangement` + group/color reset (matching the old `AxisSwapper` behavior).
- **Sample data**: `ui/src/data/sample.json` migrated to the new `ChartConfig[]` shape; all 6 datasets preserved, including the Worker Pool Benchmarks "no charts" entry.
- **Dead code removed**: `AxisSwapper.vue`, `ChartSettings.vue`, `AutoRotateToggle.vue`, `ScaleSelector.vue`, `shared/chart_config.go`, `cmd/flag_validation_rules.go`, `LinearDefaults`/`applyDefaults`/`selectionSettings`/`ChartSelection`/`SelectionsFromCharts`, the `axisKeyConcat` helper, and the v0.12.0 `DatasetSettings`/`ChartSettings`/`Defaults` structs.
- **Sync with main (#129)**: removes `--scale` from root and syncs the 3D bar/line bevel/width values that were squashed into #129.
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.

2 participants