diff --git a/CLAUDE.md b/CLAUDE.md index 352b6ac..73137cd 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -19,6 +19,21 @@ Working rules for this repo: ## Project notes +- **Single-select capabilities (2026-08-12, PR 2 of the streamline epic)** — + overlapping tools are radio choices, not stacking toggles. Pure + `kExclusiveGroups` (`{'hex-flavor': [verdant, hexcrawl]}`) + + `normalizeExclusive` + `kExclusiveSystemIds` in `campaign_surfaces.dart`; + the wizard + `_EditSystemsDialog` render group members as ChoiceChips + (keys unchanged, `hexflavor-none`/`edit-hexflavor-none` for None) and + normalization runs on wizard create + edit-dialog save ONLY (gates stay + tolerant of legacy both-on sets). `SessionMeta.partyTool` + ('emulator'|'behavior'|'sidekick', JSON omitted at default; + `enabledPartyTool`, `setPartyTool`, `partyToolProvider`) picks the ONE + party surface `PartyToolsPane` renders (SegmentedButton retired; the + wizard's `party-tool-` row + the edit dialog's `edit-party-tool-` + row switch it). The Dungeon pane shows one generator at a time + (`_hexcrawlDungeonControls` hidden while classic-dungeon is on). See + `docs/superpowers/specs/2026-08-12-streamline-library-exclusive-capabilities-design.md`. - **QoL sweep (2026-07-12, PRs #287–#299)** — thirteen player-experience features, each with a spec in `docs/superpowers/specs/2026-07-12-*`: mobile chrome density + HUD light-chip de-noising (`kCompactWidth` 600, diff --git a/docs/superpowers/plans/2026-08-12-exclusive-capabilities.md b/docs/superpowers/plans/2026-08-12-exclusive-capabilities.md new file mode 100644 index 0000000..1bf7f01 --- /dev/null +++ b/docs/superpowers/plans/2026-08-12-exclusive-capabilities.md @@ -0,0 +1,570 @@ +# Single-Select Capabilities (PR 2 of streamline epic) Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Where multiple enabled tools do the same job, the player picks ONE: verdant-vs-hexcrawl becomes an exclusive pair, the party subtab shows one chosen paradigm, and the dungeon pane never stacks two generators. + +**Architecture:** Pure `kExclusiveGroups` + `normalizeExclusive` over the existing `Set systems` (no model migration); one new per-campaign field `SessionMeta.partyTool`; radio ChoiceChips in the wizard + edit-systems dialog; two one-line UI gates in map_screen. + +**Tech Stack:** Flutter + flutter_riverpod (existing rails only). Package name is `loreseer` (imports `package:loreseer/...`). + +**Spec:** `docs/superpowers/specs/2026-08-12-streamline-library-exclusive-capabilities-design.md` (Part 2) + +## Global Constraints + +- Gates stay tolerant: a legacy campaign with BOTH verdant + hexcrawl enabled keeps working; normalization happens only when the edit-systems dialog saves (keep the FIRST group member by group order, drop the rest) and on wizard create (defensive). +- `SessionMeta.partyTool` values: `'emulator' | 'behavior' | 'sidekick'`; default `'emulator'`; JSON key `partyTool`, omitted at default (null); tolerant parse. +- Persisted state of unchosen party panes is untouched — switching back restores it. +- Existing test keys `cat-verdant`, `cat-hexcrawl`, `edit-sys-verdant`, `edit-sys-hexcrawl` stay on the new ChoiceChips (semantics change checkbox→radio; keys don't). +- Format only files you edit (`dart format `), never repo-wide. +- Widget tests must NOT pump HomeShell/JournalScreen without the repo's asset-provider overrides (rootBundle hang); pump dialogs/panes directly and override `emulatorDataProvider`-style asset providers with fixtures where a pane loads assets (copy the setup of that pane's existing test file). + +--- + +### Task 1: Engine + model (exclusive groups, partyTool field/setter/provider) + +**Files:** +- Modify: `lib/engine/campaign_surfaces.dart` (append at end) +- Modify: `lib/engine/models/session.dart` (`SessionMeta` ~lines 292–362) +- Modify: `lib/state/providers.dart` (`SessionsNotifier` after `setDndEdition` ~line 2785; provider next to `dndEditionProvider` ~line 3188) +- Test: `test/exclusive_groups_test.dart`, `test/party_tool_test.dart` + +**Interfaces:** +- Consumes: `SessionMeta`/`SessionsState` (session.dart), `sessionsProvider`, `_save` (SessionsNotifier private persist — same as `setDndEdition`). +- Produces (used by Tasks 2–4): + - `const Map> kExclusiveGroups` = `{'hex-flavor': ['verdant', 'hexcrawl']}` + - `Set normalizeExclusive(Set systems)` + - `Set kExclusiveSystemIds` (flattened members, for the dialogs to exclude from checkbox/filter loops) + - `SessionMeta.partyTool` (`String?` field; `enabledPartyTool` getter → `partyTool ?? 'emulator'`) + - `SessionsNotifier.setPartyTool(String id, String tool)` + - `final partyToolProvider = Provider(...)` (active campaign's, default `'emulator'`) + +- [ ] **Step 1: Write the failing tests** + +```dart +// test/exclusive_groups_test.dart +import 'package:flutter_test/flutter_test.dart'; +import 'package:loreseer/engine/campaign_surfaces.dart'; + +void main() { + test('normalizeExclusive keeps the first member by group order', () { + expect(normalizeExclusive({'juice', 'verdant', 'hexcrawl'}), + {'juice', 'verdant'}); + expect(normalizeExclusive({'hexcrawl'}), {'hexcrawl'}); + expect(normalizeExclusive({'juice', 'party'}), {'juice', 'party'}); + expect(normalizeExclusive(const {}), isEmpty); + }); + + test('kExclusiveSystemIds flattens group members', () { + expect(kExclusiveSystemIds, containsAll(['verdant', 'hexcrawl'])); + }); +} +``` + +```dart +// test/party_tool_test.dart +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:loreseer/engine/models.dart'; +import 'package:loreseer/state/providers.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + test('partyTool round-trips through JSON, omitted at default', () { + const m = SessionMeta(id: 's1', name: 'A'); + expect(m.toJson().containsKey('partyTool'), isFalse); + expect(m.enabledPartyTool, 'emulator'); + final m2 = SessionMeta.fromJson( + {'id': 's1', 'name': 'A', 'partyTool': 'sidekick'}); + expect(m2.enabledPartyTool, 'sidekick'); + expect(m2.toJson()['partyTool'], 'sidekick'); + }); + + test('setPartyTool persists and partyToolProvider reflects it', () async { + SharedPreferences.setMockInitialValues({}); + final container = ProviderContainer(); + addTearDown(container.dispose); + final sessions = await container.read(sessionsProvider.future); + expect(container.read(partyToolProvider), 'emulator'); + await container + .read(sessionsProvider.notifier) + .setPartyTool(sessions.active, 'behavior'); + expect(container.read(partyToolProvider), 'behavior'); + }); +} +``` + +- [ ] **Step 2: Run to verify they fail** + +Run: `flutter test test/exclusive_groups_test.dart test/party_tool_test.dart` +Expected: FAIL — symbols undefined. + +- [ ] **Step 3: Implement** + +Append to `lib/engine/campaign_surfaces.dart`: + +```dart +/// Capability groups where enabling more than one member stacks overlapping +/// UI for the same job. The dialogs render each group as a radio row, and +/// [normalizeExclusive] resolves a both-on legacy set by keeping the FIRST +/// member listed here. Gates elsewhere stay tolerant of both-on sets. +const Map> kExclusiveGroups = { + 'hex-flavor': ['verdant', 'hexcrawl'], +}; + +/// Every system id that belongs to some exclusive group — the dialogs skip +/// these in their plain checkbox/filter loops. +final Set kExclusiveSystemIds = + kExclusiveGroups.values.expand((m) => m).toSet(); + +/// Keeps at most one member per exclusive group (the first listed), leaving +/// everything else untouched. +Set normalizeExclusive(Set systems) { + final out = {...systems}; + for (final members in kExclusiveGroups.values) { + final present = members.where(out.contains).toList(); + for (final id in present.skip(1)) { + out.remove(id); + } + // Order comes from the group list, not the set: keep the first-listed. + if (present.length > 1) { + out.removeAll(present); + out.add(present.first); + } + } + return out; +} +``` + +(Note the two loops above are redundant as written — implement it as ONE pass: compute `present`; if `present.length > 1`, `out.removeAll(present)` then `out.add(present.first)`. The test pins the behavior.) + +`lib/engine/models/session.dart` — `SessionMeta` gains a field mirroring `dndEdition` exactly: constructor param `this.partyTool`, `final String? partyTool;` with doc `/// Which party-tools paradigm the Track subtab shows ('emulator' | 'behavior' | 'sidekick'); null → emulator.`, getter `String get enabledPartyTool => partyTool ?? 'emulator';`, `toJson`: `if (partyTool != null) 'partyTool': partyTool,`, `copyWith` param + pass-through, `fromJson`: `partyTool: j['partyTool'] as String?,`. + +`lib/state/providers.dart` — after `setDndEdition` (~line 2785): + +```dart + /// Set which party-tools paradigm session [id] shows + /// ('emulator' | 'behavior' | 'sidekick'). + Future setPartyTool(String id, String tool) async { + final s = state.valueOrNull; + if (s == null) return; + final updated = [ + for (final m in s.sessions) + if (m.id == id) m.copyWith(partyTool: tool) else m, + ]; + await _save(SessionsState(active: s.active, sessions: updated)); + } +``` + +Next to `dndEditionProvider` (~line 3188): + +```dart +/// Active campaign's party-tools paradigm; default 'emulator'. +final partyToolProvider = Provider((ref) => + ref.watch(sessionsProvider).valueOrNull?.activeMeta.enabledPartyTool ?? + 'emulator'); +``` + +- [ ] **Step 4: Run to verify they pass** + +Run: `flutter test test/exclusive_groups_test.dart test/party_tool_test.dart` +Expected: PASS. + +- [ ] **Step 5: Commit** + +```bash +git add lib/engine/campaign_surfaces.dart lib/engine/models/session.dart lib/state/providers.dart test/exclusive_groups_test.dart test/party_tool_test.dart +git commit -m "feat(systems): exclusive capability groups + per-campaign partyTool" +``` + +--- + +### Task 2: Wizard — exclusive radio row + party-tool row + +**Files:** +- Modify: `lib/shared/home_shell.dart` (`NewCampaignResult` typedef ~line 1241; `_NewCampaignDialogState` ~1265–1341; `_buildStep1` addon loop ~1520–1552; `_createSession` ~302) and `lib/features/launcher_screen.dart` (`_new`, the second `NewCampaignDialog` call site ~line 96 — it consumes the same result record; wire `setPartyTool` the same way) +- Test: `test/campaign_wizard_exclusive_test.dart` + +**Interfaces:** +- Consumes: `kExclusiveGroups` / `kExclusiveSystemIds` / `normalizeExclusive` (Task 1), `SessionsNotifier.setPartyTool` (Task 1), existing wizard state (`_addons`, `_systems`, `_submit`). +- Produces: `NewCampaignResult` gains `String partyTool`; keys `hexflavor-none`, `party-tool-emulator|behavior|sidekick` (wizard); `cat-verdant`/`cat-hexcrawl` become ChoiceChips (same keys). + +- [ ] **Step 1: Write the failing test** + +Model the pump on the existing wizard test (find it: `grep -rln "wizard-next\|ruleset-none" test/ | head`, copy its scaffolding — it pumps `NewCampaignDialog` directly and walks steps). Then add: + +```dart +// test/campaign_wizard_exclusive_test.dart — scenarios: +// 1. Step 1 shows a 'Hexcrawl flavor' ChoiceChip row: hexflavor-none selected +// by default; cat-verdant + cat-hexcrawl present as radio chips. +// 2. Tap cat-verdant then cat-hexcrawl → resulting created systems contain +// 'hexcrawl' and NOT 'verdant' (radio, not additive). Assert via the +// popped NewCampaignResult (pump the dialog with a Navigator and capture +// the result like the existing wizard test does). +// 3. With the 'party' addon on (default), a 'Party tool' ChoiceChip row shows +// party-tool-emulator selected; tapping party-tool-sidekick makes the +// popped result carry partyTool == 'sidekick'. Turning the party addon OFF +// hides the row and the result carries partyTool == 'emulator'. +``` + +Write real tests for all three. + +- [ ] **Step 2: Run to verify they fail** + +Run: `flutter test test/campaign_wizard_exclusive_test.dart` +Expected: FAIL. + +- [ ] **Step 3: Implement** + +(a) `_NewCampaignDialogState`: add `String _partyTool = 'emulator';`. In `_buildStep1`'s per-category chip Wrap (~line 1539), skip exclusive members in the FilterChip loop: + +```dart + for (final id in addonIds.where((i) => + kSystemCategory[i] == cat && !kExclusiveSystemIds.contains(i))) +``` + +Directly after that Wrap, still inside the `for (final cat ...)` block, render each group whose members live in this category (today: hex-flavor under exploration): + +```dart + if (cat == SystemCategory.exploration) ...[ + const SizedBox(height: 6), + const Text('Hexcrawl flavor (pick one)', + style: TextStyle(fontWeight: FontWeight.w500, fontSize: 13)), + const SizedBox(height: 4), + Wrap(spacing: 6, runSpacing: 6, children: [ + ChoiceChip( + key: const Key('hexflavor-none'), + label: const Text('None'), + selected: !kExclusiveGroups['hex-flavor']! + .any(_addons.contains), + onSelected: (_) => setState(() => + _addons.removeAll(kExclusiveGroups['hex-flavor']!)), + ), + for (final id in kExclusiveGroups['hex-flavor']!) + ChoiceChip( + key: Key('cat-$id'), + label: Text(kSystemShortName[id] ?? id), + selected: _addons.contains(id), + onSelected: (_) => setState(() { + _addons.removeAll(kExclusiveGroups['hex-flavor']!); + _addons.add(id); + }), + ), + ]), + ], + if (cat == SystemCategory.tools && _addons.contains('party')) ...[ + const SizedBox(height: 6), + const Text('Party tool (pick one)', + style: TextStyle(fontWeight: FontWeight.w500, fontSize: 13)), + const SizedBox(height: 4), + Wrap(spacing: 6, runSpacing: 6, children: [ + for (final t in const [ + ('emulator', 'Emulator'), + ('behavior', 'Behavior'), + ('sidekick', 'Sidekick'), + ]) + ChoiceChip( + key: Key('party-tool-${t.$1}'), + label: Text(t.$2), + selected: _partyTool == t.$1, + onSelected: (_) => setState(() => _partyTool = t.$1), + ), + ]), + ], +``` + +(b) `NewCampaignResult` gains `String partyTool`; `_submit` wraps systems defensively and carries the tool: + +```dart + Navigator.of(context).pop(( + name: _nameCtrl.text, + systems: normalizeExclusive(systemsForSubmit), + ... + partyTool: _partyTool, + )); +``` + +(c) Both create call sites (`home_shell._createSession` after `setDefaultOracle`, `launcher_screen._new` same spot) add: + +```dart + if (result.partyTool != 'emulator') { + final active = ref.read(sessionsProvider).valueOrNull?.active; + if (active != null) { + await ref + .read(sessionsProvider.notifier) + .setPartyTool(active, result.partyTool); + } + } +``` + +Add `import` for `campaign_surfaces.dart` where missing. + +- [ ] **Step 4: Run tests** + +Run: `flutter test test/campaign_wizard_exclusive_test.dart $(grep -rln "wizard-next" test/ | tr '\n' ' ')` +Expected: PASS (new + existing wizard tests). + +- [ ] **Step 5: Format + commit** + +```bash +dart format lib/shared/home_shell.dart lib/features/launcher_screen.dart +git add -A lib test/campaign_wizard_exclusive_test.dart +git commit -m "feat(wizard): hexcrawl-flavor radio + party-tool choice" +``` + +--- + +### Task 3: Edit-systems dialog — radio row, normalization on save, party-tool switcher + +**Files:** +- Modify: `lib/shared/home_shell.dart` (`_EditSystemsDialog` ~1855–1930; caller `_editSystems` ~326–334) +- Test: `test/edit_systems_exclusive_test.dart` + +**Interfaces:** +- Consumes: Task 1 symbols; `SessionsNotifier.editSystems` + `setPartyTool`. +- Produces: `_EditSystemsDialog` returns `({Set systems, String partyTool})`; takes `initial` + `initialPartyTool`. Keys: `edit-sys-verdant`/`edit-sys-hexcrawl` (now ChoiceChips), `edit-hexflavor-none`, `edit-party-tool-`. + +- [ ] **Step 1: Write the failing test** + +Model on the existing edit-systems test (find: `grep -rln "edit-sys-" test/ | head`). Scenarios (write real tests): + +```dart +// 1. Dialog seeded with {'juice','verdant','hexcrawl'} (legacy both-on): +// saving without touching anything returns systems containing 'verdant' +// but NOT 'hexcrawl' (normalizeExclusive keeps first by group order). +// 2. Tapping edit-sys-hexcrawl then Save → 'hexcrawl' in, 'verdant' out. +// Tapping edit-hexflavor-none then Save → neither. +// 3. Seeded with party enabled + initialPartyTool 'emulator': an +// edit-party-tool-behavior chip exists; tapping it and saving returns +// partyTool == 'behavior'. Without 'party' in the picked set, the row is +// hidden and partyTool returns unchanged. +``` + +- [ ] **Step 2: Run to verify it fails** + +Run: `flutter test test/edit_systems_exclusive_test.dart` +Expected: FAIL. + +- [ ] **Step 3: Implement** + +`_EditSystemsDialog`: add `final String initialPartyTool;` (constructor `this.initialPartyTool = 'emulator'`). State: `late String _partyTool = widget.initialPartyTool;`. In the category loop, exclude exclusive members from the checkbox rows: + +```dart + for (final id in kSystemCategory.entries + .where((e) => + e.value == cat && !kExclusiveSystemIds.contains(e.key)) + .map((e) => e.key)) + _row(id, kSystemShortName[id] ?? id), +``` + +After the exploration category's rows, add the radio row (same chip pattern as the wizard, keys `edit-sys-` + `edit-hexflavor-none`, mutating `_picked`). After the tools category's rows, when `_picked.contains('party')`, add the party-tool row (keys `edit-party-tool-`, mutating `_partyTool`). + +Save action pops the record with normalization: + +```dart + FilledButton( + onPressed: () => Navigator.of(context) + .pop((systems: normalizeExclusive(_picked), partyTool: _partyTool)), + child: const Text('Save'), + ), +``` + +Caller `_editSystems`: + +```dart + final picked = await showDialog<({Set systems, String partyTool})>( + context: dialogContext, + builder: (context) => _EditSystemsDialog( + initial: meta.enabledSystems, + initialPartyTool: meta.enabledPartyTool), + ); + if (picked == null) return; + await ref + .read(sessionsProvider.notifier) + .editSystems(meta.id, picked.systems); + if (picked.partyTool != meta.enabledPartyTool) { + await ref + .read(sessionsProvider.notifier) + .setPartyTool(meta.id, picked.partyTool); + } +``` + +- [ ] **Step 4: Run tests** + +Run: `flutter test test/edit_systems_exclusive_test.dart $(grep -rln "edit-sys-" test/ | tr '\n' ' ')` +Expected: PASS. + +- [ ] **Step 5: Format + commit** + +```bash +dart format lib/shared/home_shell.dart +git add lib/shared/home_shell.dart test/edit_systems_exclusive_test.dart +git commit -m "feat(systems): edit dialog radio groups + normalization + party-tool switcher" +``` + +--- + +### Task 4: Party pane renders only the chosen paradigm + +**Files:** +- Modify: `lib/features/party_tools_pane.dart` (whole file — it is 60 lines) +- Test: `test/party_tools_pane_test.dart` (new or extend existing — check `grep -rln "party-tools-switch" test/`) + +**Interfaces:** +- Consumes: `partyToolProvider` (Task 1). +- Produces: `PartyToolsPane` (ConsumerWidget) rendering exactly one of `PartyEmulatorScreen` / `BehaviorTablesScreen` / `SidekickScreen`; the `party-tools-switch` SegmentedButton and `initial` param are REMOVED (check its call site: `grep -rn "PartyToolsPane(" lib/` — update any `initial:` usage; the subtab host likely constructs it bare). + +- [ ] **Step 1: Write the failing test** + +Override whatever asset providers the three screens load (copy the setup from the existing party/emulator test file — find via `grep -rln "PartyEmulator\|emulatorData" test/ | head`; repo rule: never let a widget test hit rootBundle). Scenarios: + +```dart +// 1. partyTool 'emulator' (default, empty prefs) → PartyEmulatorScreen +// present; BehaviorTablesScreen + SidekickScreen absent; +// party-tools-switch key absent. +// 2. prefs seeded with sessions registry carrying partyTool 'sidekick' +// (or override partyToolProvider directly with Provider((_) => 'sidekick')) +// → only SidekickScreen present. +``` + +- [ ] **Step 2: Run to verify it fails** + +Run: `flutter test test/party_tools_pane_test.dart` +Expected: FAIL (switch still present / wrong child). + +- [ ] **Step 3: Implement** + +```dart +// lib/features/party_tools_pane.dart +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +import '../state/providers.dart'; +import 'behavior_tables_screen.dart'; +import 'party_emulator_screen.dart'; +import 'sidekick_screen.dart'; + +/// The Track party subtab shows ONE party-tools paradigm — Emulator, +/// Behavior, or Sidekick — chosen per campaign (SessionMeta.partyTool, set +/// in the creation wizard or Campaigns → Edit systems). The old in-pane +/// SegmentedButton stacked all three behind a switch; the paradigms answer +/// the same question, so the choice is campaign config, not pane state. +/// Unchosen paradigms keep their persisted state for a later switch back. +class PartyToolsPane extends ConsumerWidget { + const PartyToolsPane({super.key}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + return switch (ref.watch(partyToolProvider)) { + 'behavior' => const BehaviorTablesScreen(), + 'sidekick' => const SidekickScreen(), + _ => const PartyEmulatorScreen(), + }; + } +} +``` + +Fix any call site passing `initial:` (grep first; adjust or drop the arg). + +- [ ] **Step 4: Run tests** + +Run: `flutter test test/party_tools_pane_test.dart $(grep -rln "party-tools\|PartyToolsPane" test/ | tr '\n' ' ')` +Expected: PASS. + +- [ ] **Step 5: Format + commit** + +```bash +dart format lib/features/party_tools_pane.dart +git add -A lib/features test/party_tools_pane_test.dart +git commit -m "feat(party): subtab renders the one chosen party tool" +``` + +--- + +### Task 5: Dungeon pane — one generator at a time + +**Files:** +- Modify: `lib/features/map_screen.dart` (line ~593: `if (_hexcrawlOn()) _hexcrawlDungeonControls(context)` in the Dungeon pane's `_tools`) +- Test: extend the existing dungeon-pane widget test (find: `grep -rln "classic-enter\|hexcrawl-new-room" test/ | head`) + +**Interfaces:** +- Consumes: existing private `_hexcrawlOn()` / `_classicOn()` in the same State. +- Produces: no new symbols — a gate change only. + +- [ ] **Step 1: Write the failing test** + +In the existing dungeon-pane test file (reuse its pump + provider-override scaffolding; remember tests must tap `map-tools-toggle` before reaching folded tools): + +```dart +// classic-dungeon AND hexcrawl both enabled → after opening map-tools-toggle, +// hexcrawl-new-room and hexcrawl-generate-dungeon are ABSENT (classic owns +// dungeon generation); with hexcrawl on and classic OFF, both remain present. +``` + +- [ ] **Step 2: Run to verify it fails** + +Run: `flutter test ` +Expected: new case FAILS (controls currently render under classic). + +- [ ] **Step 3: Implement** + +```dart + // One dungeon generator at a time: when the classic (Roll 4 Ruin) + // crawler owns this pane, the hexcrawl toolkit's room/dungeon + // generation folds away instead of stacking a second generator. + if (_hexcrawlOn() && !_classicOn()) _hexcrawlDungeonControls(context), +``` + +- [ ] **Step 4: Run tests** + +Run: `flutter test ` +Expected: PASS (new + existing cases). + +- [ ] **Step 5: Format + commit** + +```bash +dart format lib/features/map_screen.dart +git add lib/features/map_screen.dart test/ +git commit -m "fix(map): classic dungeon hides hexcrawl generation controls" +``` + +--- + +### Task 6: Full verify + docs + +**Files:** +- Modify: `CLAUDE.md` (one bullet under Project notes) + +- [ ] **Step 1: Analyze + full suite** + +Run: `flutter analyze && flutter test` +Expected: clean + green. Attribute any failure ONLY from the final "Failing tests:" block (never `+P -F:` lines); treat failures as this branch's until proven otherwise. + +- [ ] **Step 2: CLAUDE.md note** + +```markdown +- **Single-select capabilities (2026-08-12, PR 2 of the streamline epic)** — + overlapping tools are radio choices, not stacking toggles. Pure + `kExclusiveGroups` (`{'hex-flavor': [verdant, hexcrawl]}`) + + `normalizeExclusive` + `kExclusiveSystemIds` in `campaign_surfaces.dart`; + the wizard + `_EditSystemsDialog` render group members as ChoiceChips + (keys unchanged, `hexflavor-none`/`edit-hexflavor-none` for None) and + normalization runs on wizard create + edit-dialog save ONLY (gates stay + tolerant of legacy both-on sets). `SessionMeta.partyTool` + ('emulator'|'behavior'|'sidekick', JSON omitted at default; + `enabledPartyTool`, `setPartyTool`, `partyToolProvider`) picks the ONE + party surface `PartyToolsPane` renders (SegmentedButton retired; the + wizard's `party-tool-` row + the edit dialog's `edit-party-tool-` + row switch it). The Dungeon pane shows one generator at a time + (`_hexcrawlDungeonControls` hidden while classic-dungeon is on). See + `docs/superpowers/specs/2026-08-12-streamline-library-exclusive-capabilities-design.md`. +``` + +- [ ] **Step 3: Commit** + +```bash +git add CLAUDE.md +git commit -m "docs: single-select capabilities project note" +``` diff --git a/lib/engine/campaign_surfaces.dart b/lib/engine/campaign_surfaces.dart index 3bc9b28..c68d811 100644 --- a/lib/engine/campaign_surfaces.dart +++ b/lib/engine/campaign_surfaces.dart @@ -84,3 +84,30 @@ List surfacesFor(Set systems) { ]), ]; } + +/// Capability groups where enabling more than one member stacks overlapping +/// UI for the same job. The dialogs render each group as a radio row, and +/// [normalizeExclusive] resolves a both-on legacy set by keeping the FIRST +/// member listed here. Gates elsewhere stay tolerant of both-on sets. +const Map> kExclusiveGroups = { + 'hex-flavor': ['verdant', 'hexcrawl'], +}; + +/// Every system id that belongs to some exclusive group — the dialogs skip +/// these in their plain checkbox/filter loops. +final Set kExclusiveSystemIds = + kExclusiveGroups.values.expand((m) => m).toSet(); + +/// Keeps at most one member per exclusive group (the first listed), leaving +/// everything else untouched. +Set normalizeExclusive(Set systems) { + final out = {...systems}; + for (final members in kExclusiveGroups.values) { + final present = members.where(out.contains).toList(); + if (present.length > 1) { + out.removeAll(present); + out.add(present.first); + } + } + return out; +} diff --git a/lib/engine/models/session.dart b/lib/engine/models/session.dart index 9646a0a..24687d2 100644 --- a/lib/engine/models/session.dart +++ b/lib/engine/models/session.dart @@ -297,7 +297,8 @@ class SessionMeta { this.identityColor, this.identityIcon, this.genre, - this.dndEdition}); + this.dndEdition, + this.partyTool}); final String id; final String name; @@ -319,9 +320,16 @@ class SessionMeta { /// ('5.2'). Filters edition-tagged content so one edition shows at a time. final String? dndEdition; + /// Which party-tools paradigm the Track subtab shows ('emulator' | 'behavior' | + /// 'sidekick'); null → emulator. + final String? partyTool; + /// Resolved set: the declared systems, or every system when unset. Set get enabledSystems => systems?.toSet() ?? kAllSystems; + /// Resolved party tool; null → 'emulator'. + String get enabledPartyTool => partyTool ?? 'emulator'; + Map toJson() => { 'id': id, 'name': name, @@ -330,6 +338,7 @@ class SessionMeta { if (identityIcon != null) 'identityIcon': identityIcon, if (genre != null) 'genre': genre, if (dndEdition != null) 'dndEdition': dndEdition, + if (partyTool != null) 'partyTool': partyTool, }; // id is immutable — not overridable via copyWith. @@ -340,6 +349,7 @@ class SessionMeta { String? identityIcon, String? genre, String? dndEdition, + String? partyTool, }) => SessionMeta( id: id, @@ -349,6 +359,7 @@ class SessionMeta { identityIcon: identityIcon ?? this.identityIcon, genre: genre ?? this.genre, dndEdition: dndEdition ?? this.dndEdition, + partyTool: partyTool ?? this.partyTool, ); factory SessionMeta.fromJson(Map j) => SessionMeta( @@ -359,6 +370,7 @@ class SessionMeta { identityIcon: j['identityIcon'] as String?, genre: j['genre'] as String?, dndEdition: j['dndEdition'] as String?, + partyTool: j['partyTool'] as String?, ); } diff --git a/lib/features/launcher_screen.dart b/lib/features/launcher_screen.dart index 8563836..e534f3e 100644 --- a/lib/features/launcher_screen.dart +++ b/lib/features/launcher_screen.dart @@ -101,6 +101,14 @@ class LauncherScreen extends ConsumerWidget { await ref .read(settingsProvider.notifier) .setDefaultOracle(result.defaultOracle); + if (result.partyTool != 'emulator') { + final active = ref.read(sessionsProvider).valueOrNull?.active; + if (active != null) { + await ref + .read(sessionsProvider.notifier) + .setPartyTool(active, result.partyTool); + } + } // First real campaign replaces the untouched first-run placeholder. if (wasPristine) { await ref.read(sessionsProvider.notifier).remove('default'); diff --git a/lib/features/map_screen.dart b/lib/features/map_screen.dart index 3aa438d..927d389 100644 --- a/lib/features/map_screen.dart +++ b/lib/features/map_screen.dart @@ -590,7 +590,10 @@ class DungeonMapPaneState extends ConsumerState { .goTo(Destination.map, subtab: 'world'); }, ), - if (_hexcrawlOn()) _hexcrawlDungeonControls(context), + // One dungeon generator at a time: when the classic (Roll 4 Ruin) + // crawler owns this pane, the hexcrawl toolkit's room/dungeon + // generation folds away instead of stacking a second generator. + if (_hexcrawlOn() && !_classicOn()) _hexcrawlDungeonControls(context), IconButton( key: const Key('dungeon-journal'), icon: const Icon(Icons.bookmark_add_outlined), diff --git a/lib/features/party_tools_pane.dart b/lib/features/party_tools_pane.dart index 6852666..a6ad517 100644 --- a/lib/features/party_tools_pane.dart +++ b/lib/features/party_tools_pane.dart @@ -1,56 +1,26 @@ import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import '../state/providers.dart'; import 'behavior_tables_screen.dart'; import 'party_emulator_screen.dart'; import 'sidekick_screen.dart'; -/// One Track subtab hosting the three party-tools surfaces — Emulator, -/// Behavior, and Sidekick — behind a segmented switch (was three separate -/// same-weight subtabs). An [IndexedStack] keeps all three mounted so each -/// keeps its state across switches (and dodges the TabBarView loose-constraints -/// gotcha in the tool host). -class PartyToolsPane extends StatefulWidget { - const PartyToolsPane({super.key, this.initial = 0}); - - /// Which inner surface to show first (0 Emulator, 1 Behavior, 2 Sidekick). - final int initial; - - @override - State createState() => _PartyToolsPaneState(); -} - -class _PartyToolsPaneState extends State { - late int _tab = widget.initial.clamp(0, 2); +/// The Track party subtab shows ONE party-tools paradigm — Emulator, +/// Behavior, or Sidekick — chosen per campaign (SessionMeta.partyTool, set +/// in the creation wizard or Campaigns → Edit systems). The old in-pane +/// SegmentedButton stacked all three behind a switch; the paradigms answer +/// the same question, so the choice is campaign config, not pane state. +/// Unchosen paradigms keep their persisted state for a later switch back. +class PartyToolsPane extends ConsumerWidget { + const PartyToolsPane({super.key}); @override - Widget build(BuildContext context) { - return Column( - children: [ - Padding( - padding: const EdgeInsets.fromLTRB(12, 8, 12, 0), - child: SegmentedButton( - key: const Key('party-tools-switch'), - segments: const [ - ButtonSegment(value: 0, label: Text('Emulator')), - ButtonSegment(value: 1, label: Text('Behavior')), - ButtonSegment(value: 2, label: Text('Sidekick')), - ], - selected: {_tab}, - showSelectedIcon: false, - onSelectionChanged: (s) => setState(() => _tab = s.first), - ), - ), - Expanded( - child: IndexedStack( - index: _tab, - children: const [ - PartyEmulatorScreen(), - BehaviorTablesScreen(), - SidekickScreen(), - ], - ), - ), - ], - ); + Widget build(BuildContext context, WidgetRef ref) { + return switch (ref.watch(partyToolProvider)) { + 'behavior' => const BehaviorTablesScreen(), + 'sidekick' => const SidekickScreen(), + _ => const PartyEmulatorScreen(), + }; } } diff --git a/lib/features/tracking_tab.dart b/lib/features/tracking_tab.dart index 352c839..de23e73 100644 --- a/lib/features/tracking_tab.dart +++ b/lib/features/tracking_tab.dart @@ -39,8 +39,10 @@ class TrackingTab extends ConsumerWidget { const SubtabDef('encounter', 'Encounter'), if (rumors) const SubtabDef('rumors', 'Rumors'), const SubtabDef('tracks', 'Tracks'), - // Emulator + Behavior + Sidekick consolidated into one Party subtab - // (internal switch); legacy routes resolve via the aliases. + // One party paradigm renders per SessionMeta.partyTool (Emulator / + // Behavior / Sidekick are mutually exclusive, not stacked). The + // aliases only keep legacy routes ('emulator'/'sidekick'/'behavior') + // resolving to this subtab. if (partyTools) const SubtabDef('party', 'Party', aliases: ['emulator', 'sidekick', 'behavior']), diff --git a/lib/shared/home_shell.dart b/lib/shared/home_shell.dart index 69c83b4..0858f3e 100644 --- a/lib/shared/home_shell.dart +++ b/lib/shared/home_shell.dart @@ -7,6 +7,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:http/http.dart' as http; +import '../engine/campaign_surfaces.dart'; import '../engine/constructed_oracle.dart'; import '../engine/custom_table.dart'; import '../engine/funnel.dart'; @@ -313,6 +314,14 @@ class _HomeShellState extends ConsumerState { await ref .read(settingsProvider.notifier) .setDefaultOracle(result.defaultOracle); + if (result.partyTool != 'emulator') { + final active = ref.read(sessionsProvider).valueOrNull?.active; + if (active != null) { + await ref + .read(sessionsProvider.notifier) + .setPartyTool(active, result.partyTool); + } + } ref.read(shellRouteProvider.notifier).land(); if (result.start == 'funnel') { await ref.read(charactersProvider.notifier).addFunnel(result.seedSystem); @@ -325,12 +334,21 @@ class _HomeShellState extends ConsumerState { Future _editSystems( BuildContext dialogContext, SessionMeta meta) async { - final picked = await showDialog>( + final picked = await showDialog<({Set systems, String partyTool})>( context: dialogContext, - builder: (context) => _EditSystemsDialog(initial: meta.enabledSystems), + builder: (context) => _EditSystemsDialog( + initial: meta.enabledSystems, + initialPartyTool: meta.enabledPartyTool), ); if (picked == null) return; - await ref.read(sessionsProvider.notifier).editSystems(meta.id, picked); + await ref + .read(sessionsProvider.notifier) + .editSystems(meta.id, picked.systems); + if (picked.partyTool != meta.enabledPartyTool) { + await ref + .read(sessionsProvider.notifier) + .setPartyTool(meta.id, picked.partyTool); + } } Future _exportCampaign(BuildContext dialogContext) async { @@ -1247,6 +1265,7 @@ typedef NewCampaignResult = ({ String seedSystem, LoopKit? kit, String defaultOracle, + String partyTool, }); class NewCampaignDialog extends StatefulWidget { @@ -1280,6 +1299,10 @@ class _NewCampaignDialogState extends State { String _start = 'roster'; // 'roster' | 'funnel' | 'kit' LoopKit? _selectedKit; + // Party-tool paradigm ('emulator' | 'behavior' | 'sidekick'), only shown + // (and only meaningful) while the 'party' addon is on. + String _partyTool = 'emulator'; + @override void dispose() { _nameCtrl.dispose(); @@ -1330,13 +1353,14 @@ class _NewCampaignDialogState extends State { }; Navigator.of(context).pop(( name: _nameCtrl.text, - systems: systemsForSubmit, + systems: normalizeExclusive(systemsForSubmit), genre: _genreCtrl.text.trim(), tone: _toneCtrl.text.trim(), start: _start, seedSystem: _seedSystem, kit: _start == 'kit' ? _selectedKit : null, defaultOracle: _oracle, + partyTool: _partyTool, )); } @@ -1536,7 +1560,8 @@ class _NewCampaignDialogState extends State { ], const SizedBox(height: 4), Wrap(spacing: 6, runSpacing: 6, children: [ - for (final id in addonIds.where((i) => kSystemCategory[i] == cat)) + for (final id in addonIds.where((i) => + kSystemCategory[i] == cat && !kExclusiveSystemIds.contains(i))) FilterChip( key: Key('cat-$id'), label: Text(kSystemShortName[id] ?? id), @@ -1550,6 +1575,51 @@ class _NewCampaignDialogState extends State { }), ), ]), + if (cat == SystemCategory.exploration) ...[ + const SizedBox(height: 6), + const Text('Hexcrawl flavor (pick one)', + style: TextStyle(fontWeight: FontWeight.w500, fontSize: 13)), + const SizedBox(height: 4), + Wrap(spacing: 6, runSpacing: 6, children: [ + ChoiceChip( + key: const Key('hexflavor-none'), + label: const Text('None'), + selected: + !kExclusiveGroups['hex-flavor']!.any(_addons.contains), + onSelected: (_) => setState( + () => _addons.removeAll(kExclusiveGroups['hex-flavor']!)), + ), + for (final id in kExclusiveGroups['hex-flavor']!) + ChoiceChip( + key: Key('cat-$id'), + label: Text(kSystemShortName[id] ?? id), + selected: _addons.contains(id), + onSelected: (_) => setState(() { + _addons.removeAll(kExclusiveGroups['hex-flavor']!); + _addons.add(id); + }), + ), + ]), + ], + if (cat == SystemCategory.tools && _addons.contains('party')) ...[ + const SizedBox(height: 6), + const Text('Party tool (pick one)', + style: TextStyle(fontWeight: FontWeight.w500, fontSize: 13)), + const SizedBox(height: 4), + Wrap(spacing: 6, runSpacing: 6, children: [ + for (final t in const [ + ('emulator', 'Emulator'), + ('behavior', 'Behavior'), + ('sidekick', 'Sidekick'), + ]) + ChoiceChip( + key: Key('party-tool-${t.$1}'), + label: Text(t.$2), + selected: _partyTool == t.$1, + onSelected: (_) => setState(() => _partyTool = t.$1), + ), + ]), + ], const SizedBox(height: 10), ], const Text('Default oracle', @@ -1853,8 +1923,10 @@ class CampaignIdentityLeading extends StatelessWidget { /// Dialog to toggle the optional systems of an existing campaign. /// Returns the chosen set, or null on cancel. class _EditSystemsDialog extends StatefulWidget { - const _EditSystemsDialog({required this.initial}); + const _EditSystemsDialog( + {required this.initial, this.initialPartyTool = 'emulator'}); final Set initial; + final String initialPartyTool; @override State<_EditSystemsDialog> createState() => _EditSystemsDialogState(); @@ -1862,6 +1934,7 @@ class _EditSystemsDialog extends StatefulWidget { class _EditSystemsDialogState extends State<_EditSystemsDialog> { late final Set _picked = {...widget.initial}; + late String _partyTool = widget.initialPartyTool; Widget _row(String id, String label) => CheckboxListTile( key: Key('edit-sys-$id'), @@ -1895,9 +1968,49 @@ class _EditSystemsDialogState extends State<_EditSystemsDialog> { ), ), for (final id in kSystemCategory.entries - .where((e) => e.value == cat) + .where((e) => + e.value == cat && !kExclusiveSystemIds.contains(e.key)) .map((e) => e.key)) _row(id, kSystemShortName[id] ?? id), + if (cat == SystemCategory.exploration) ...[ + const SizedBox(height: 4), + Wrap(spacing: 6, runSpacing: 6, children: [ + ChoiceChip( + key: const Key('edit-hexflavor-none'), + label: const Text('None'), + selected: + !kExclusiveGroups['hex-flavor']!.any(_picked.contains), + onSelected: (_) => setState(() => + _picked.removeAll(kExclusiveGroups['hex-flavor']!)), + ), + for (final id in kExclusiveGroups['hex-flavor']!) + ChoiceChip( + key: Key('edit-sys-$id'), + label: Text(kSystemShortName[id] ?? id), + selected: _picked.contains(id), + onSelected: (_) => setState(() { + _picked.removeAll(kExclusiveGroups['hex-flavor']!); + _picked.add(id); + }), + ), + ]), + ], + if (cat == SystemCategory.tools && _picked.contains('party')) ...[ + const SizedBox(height: 4), + Wrap(spacing: 6, runSpacing: 6, children: [ + for (final t in const [ + ('emulator', 'Emulator'), + ('behavior', 'Behavior'), + ('sidekick', 'Sidekick'), + ]) + ChoiceChip( + key: Key('edit-party-tool-${t.$1}'), + label: Text(t.$2), + selected: _partyTool == t.$1, + onSelected: (_) => setState(() => _partyTool = t.$1), + ), + ]), + ], ], ], ), @@ -1908,7 +2021,8 @@ class _EditSystemsDialogState extends State<_EditSystemsDialog> { child: const Text('Cancel'), ), FilledButton( - onPressed: () => Navigator.of(context).pop(_picked), + onPressed: () => Navigator.of(context).pop( + (systems: normalizeExclusive(_picked), partyTool: _partyTool)), child: const Text('Save'), ), ], diff --git a/lib/state/providers.dart b/lib/state/providers.dart index 7491b73..3d1ae6b 100644 --- a/lib/state/providers.dart +++ b/lib/state/providers.dart @@ -2741,6 +2741,7 @@ class SessionsNotifier extends AsyncNotifier { identityIcon: src.identityIcon, genre: src.genre, dndEdition: src.dndEdition, + partyTool: src.partyTool, ); final prefs = await ref.read(prefsProvider.future); final settings = prefs.getString('loreseer.settings.v1.$sourceId'); @@ -2784,6 +2785,18 @@ class SessionsNotifier extends AsyncNotifier { await _save(SessionsState(active: s.active, sessions: updated)); } + /// Set which party-tools paradigm session [id] shows + /// ('emulator' | 'behavior' | 'sidekick'). + Future setPartyTool(String id, String tool) async { + final s = state.valueOrNull; + if (s == null) return; + final updated = [ + for (final m in s.sessions) + if (m.id == id) m.copyWith(partyTool: tool) else m, + ]; + await _save(SessionsState(active: s.active, sessions: updated)); + } + Future remove(String id) async { final s = state.valueOrNull; if (s == null || s.sessions.length <= 1) return; // keep at least one @@ -3188,6 +3201,11 @@ final systemSpellsProvider = final dndEditionProvider = Provider((ref) => ref.watch(sessionsProvider).valueOrNull?.activeMeta.dndEdition ?? '5.2'); +/// Active campaign's party-tools paradigm; default 'emulator'. +final partyToolProvider = Provider((ref) => + ref.watch(sessionsProvider).valueOrNull?.activeMeta.enabledPartyTool ?? + 'emulator'); + /// All monsters across enabled systems: bundled creature files + Ironsworn /// npc_collections (adapted) + the user bestiary. De-duped by id. Edition-tagged /// entries (D&D 5.1/5.2) are filtered to the active campaign edition. diff --git a/test/campaign_duplicate_test.dart b/test/campaign_duplicate_test.dart index 0057abd..8715753 100644 --- a/test/campaign_duplicate_test.dart +++ b/test/campaign_duplicate_test.dart @@ -10,7 +10,8 @@ void main() { SharedPreferences.setMockInitialValues({ 'loreseer.sessions.v1': '{"active":"src","sessions":[{"id":"src",' '"name":"Ironlands","systems":["ironsworn","juice"],' - '"genre":"grim fantasy","dndEdition":"5.1"}]}', + '"genre":"grim fantasy","dndEdition":"5.1",' + '"partyTool":"sidekick"}]}', 'loreseer.settings.v1.src': '{"genre":"grim fantasy","tone":"bleak","defaultOracle":"mythic"}', 'loreseer.journal.v2.src': '[{"id":"e1","timestamp":' @@ -32,6 +33,7 @@ void main() { expect(dup.systems, ['ironsworn', 'juice']); expect(dup.genre, 'grim fantasy'); expect(dup.dndEdition, '5.1'); + expect(dup.partyTool, 'sidekick'); final prefs = await SharedPreferences.getInstance(); // Settings blob copied… diff --git a/test/campaign_wizard_exclusive_test.dart b/test/campaign_wizard_exclusive_test.dart new file mode 100644 index 0000000..1d2733a --- /dev/null +++ b/test/campaign_wizard_exclusive_test.dart @@ -0,0 +1,116 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:loreseer/shared/home_shell.dart'; + +// Local mirror of NewCampaignResult so this test file can read fields off the +// popped record without importing the private wizard internals. Must match +// the shape home_shell.dart's NewCampaignDialog actually pops. +typedef _Result = ({ + String name, + Set systems, + String genre, + String tone, + String start, + String seedSystem, + dynamic kit, + String defaultOracle, + String partyTool, +}); + +Future<_Result?> _openAndCapture( + WidgetTester tester, Future Function(WidgetTester) drive) async { + _Result? result; + await tester.pumpWidget(MaterialApp( + home: Scaffold(body: Builder(builder: (context) { + return ElevatedButton( + onPressed: () async { + result = await showDialog<_Result>( + context: context, + builder: (_) => const NewCampaignDialog(), + ); + }, + child: const Text('open'), + ); + })), + )); + await tester.tap(find.text('open')); + await tester.pumpAndSettle(); + await tester.enterText( + find.byKey(const Key('new-campaign-name')), 'Test Campaign'); + await tester.pump(); + await tester.tap(find.byKey(const Key('wizard-next'))); // step 0 -> 1 + await tester.pumpAndSettle(); + await drive(tester); + return result; +} + +Future _toStep2AndCreate(WidgetTester tester) async { + await tester.tap(find.byKey(const Key('wizard-next'))); // step 1 -> 2 + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('wizard-create'))); + await tester.pumpAndSettle(); +} + +void main() { + testWidgets( + 'step 1 shows a Hexcrawl flavor row: none selected by default, ' + 'cat-verdant + cat-hexcrawl present as radio chips', (tester) async { + await _openAndCapture(tester, (tester) async { + expect(find.byKey(const Key('hexflavor-none')), findsOneWidget); + expect(find.byKey(const Key('cat-verdant')), findsOneWidget); + expect(find.byKey(const Key('cat-hexcrawl')), findsOneWidget); + final noneChip = + tester.widget(find.byKey(const Key('hexflavor-none'))); + expect(noneChip.selected, isTrue); + }); + }); + + testWidgets( + 'tapping cat-verdant then cat-hexcrawl is a radio: only hexcrawl ' + 'survives in the created systems', (tester) async { + final result = await _openAndCapture(tester, (tester) async { + await tester.ensureVisible(find.byKey(const Key('cat-verdant'))); + await tester.tap(find.byKey(const Key('cat-verdant'))); + await tester.pumpAndSettle(); + await tester.ensureVisible(find.byKey(const Key('cat-hexcrawl'))); + await tester.tap(find.byKey(const Key('cat-hexcrawl'))); + await tester.pumpAndSettle(); + await _toStep2AndCreate(tester); + }); + + expect(result!.systems, contains('hexcrawl')); + expect(result.systems, isNot(contains('verdant'))); + }); + + testWidgets( + 'party addon on: party-tool row shows emulator selected by default; ' + 'tapping sidekick carries through to the result', (tester) async { + final result = await _openAndCapture(tester, (tester) async { + expect(find.byKey(const Key('party-tool-emulator')), findsOneWidget); + final emulatorChip = tester + .widget(find.byKey(const Key('party-tool-emulator'))); + expect(emulatorChip.selected, isTrue); + + await tester.ensureVisible(find.byKey(const Key('party-tool-sidekick'))); + await tester.tap(find.byKey(const Key('party-tool-sidekick'))); + await tester.pumpAndSettle(); + await _toStep2AndCreate(tester); + }); + + expect(result!.partyTool, 'sidekick'); + }); + + testWidgets( + 'turning the party addon off hides the party-tool row and the result ' + 'still carries the default partyTool', (tester) async { + final result = await _openAndCapture(tester, (tester) async { + await tester.ensureVisible(find.byKey(const Key('cat-party'))); + await tester.tap(find.byKey(const Key('cat-party'))); // party off + await tester.pumpAndSettle(); + expect(find.byKey(const Key('party-tool-emulator')), findsNothing); + await _toStep2AndCreate(tester); + }); + + expect(result!.partyTool, 'emulator'); + }); +} diff --git a/test/dungeon/classic_pane_widget_test.dart b/test/dungeon/classic_pane_widget_test.dart index 79a58bf..312ab3f 100644 --- a/test/dungeon/classic_pane_widget_test.dart +++ b/test/dungeon/classic_pane_widget_test.dart @@ -7,6 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:loreseer/engine/dungeon/faction.dart'; import 'package:loreseer/engine/dungeon/footprint.dart'; import 'package:loreseer/engine/dungeon/tables.dart'; +import 'package:loreseer/engine/hexcrawl_data.dart'; import 'package:loreseer/engine/models.dart'; import 'package:loreseer/engine/oracle.dart'; import 'package:loreseer/engine/oracle_data.dart'; @@ -22,9 +23,12 @@ void main() { final dungeonTables = DungeonTables.fromJson( jsonDecode(File('assets/dungeon_data.json').readAsStringSync()) as Map); + final hexcrawlData = HexcrawlData( + jsonDecode(File('assets/hexcrawl_data.json').readAsStringSync()) + as Map); Future pump(WidgetTester tester, - {bool classic = true}) async { + {bool classic = true, bool hexcrawl = false}) async { SharedPreferences.setMockInitialValues({ 'loreseer.sessions.v1': jsonEncode({ 'active': 'default', @@ -32,7 +36,11 @@ void main() { { 'id': 'default', 'name': 'C1', - if (classic) 'systems': ['juice', 'classic-dungeon'], + 'systems': [ + 'juice', + if (classic) 'classic-dungeon', + if (hexcrawl) 'hexcrawl', + ], } ], }), @@ -40,6 +48,7 @@ void main() { await tester.pumpWidget(ProviderScope( overrides: [ dungeonDataProvider.overrideWith((ref) async => dungeonTables), + hexcrawlDataProvider.overrideWith((ref) async => hexcrawlData), ], child: MaterialApp( home: Scaffold(body: DungeonMapPane(oracle: Oracle(data)))))); @@ -177,4 +186,26 @@ void main() { expect(reg.factions, isEmpty); expect(container.read(mapProvider).requireValue.rooms, isEmpty); }); + + testWidgets( + 'classic dungeon owns generation: hexcrawl room/dungeon controls ' + 'fold away when both systems are enabled', (tester) async { + await pump(tester, classic: true, hexcrawl: true); + await tester.tap(find.byKey(const Key('map-tools-toggle'))); + await tester.pumpAndSettle(); + expect(find.byKey(const Key('hexcrawl-new-room')), findsNothing); + expect(find.byKey(const Key('hexcrawl-generate-dungeon')), findsNothing); + // Classic still owns dungeon generation. + expect(find.byKey(const Key('classic-enter')), findsOneWidget); + }); + + testWidgets( + 'hexcrawl-only (classic off): hexcrawl room/dungeon controls remain', + (tester) async { + await pump(tester, classic: false, hexcrawl: true); + await tester.tap(find.byKey(const Key('map-tools-toggle'))); + await tester.pumpAndSettle(); + expect(find.byKey(const Key('hexcrawl-new-room')), findsOneWidget); + expect(find.byKey(const Key('hexcrawl-generate-dungeon')), findsOneWidget); + }); } diff --git a/test/edit_systems_exclusive_test.dart b/test/edit_systems_exclusive_test.dart new file mode 100644 index 0000000..b30df7a --- /dev/null +++ b/test/edit_systems_exclusive_test.dart @@ -0,0 +1,231 @@ +import 'dart:convert'; +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:loreseer/engine/emulator_data.dart'; +import 'package:loreseer/engine/hexcrawl_data.dart'; +import 'package:loreseer/engine/oracle.dart'; +import 'package:loreseer/engine/oracle_data.dart'; +import 'package:loreseer/engine/verdant_data.dart'; +import 'package:loreseer/shared/home_shell.dart'; +import 'package:loreseer/state/providers.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +Oracle _oracle() => Oracle(OracleData( + jsonDecode(File('assets/oracle_data.json').readAsStringSync()) + as Map)); +final _verdant = VerdantData( + jsonDecode(File('assets/verdant_data.json').readAsStringSync()) + as Map); +final _emu = EmulatorData( + jsonDecode(File('assets/emulator_data.json').readAsStringSync()) + as Map); +final _hex = HexcrawlData( + jsonDecode(File('assets/hexcrawl_data.json').readAsStringSync()) + as Map); + +final _overrides = [ + verdantDataProvider.overrideWith((ref) async => _verdant), + emulatorDataProvider.overrideWith((ref) async => _emu), + hexcrawlDataProvider.overrideWith((ref) async => _hex), +]; + +// Opens the Campaigns dialog and taps the (single, default-session) "Edit +// systems" tooltip icon, landing on the private _EditSystemsDialog. +Future _openEditSystems(WidgetTester t) async { + await t.tap(find.byTooltip('Campaigns')); + await t.pumpAndSettle(); + await t.tap(find.byTooltip('Edit systems')); + await t.pumpAndSettle(); +} + +void main() { + setUp(() => SharedPreferences.setMockInitialValues({})); + + testWidgets( + 'legacy both-on seed (verdant + hexcrawl): saving untouched keeps ' + 'verdant, drops hexcrawl (normalizeExclusive keeps first by group ' + 'order)', (t) async { + SharedPreferences.setMockInitialValues({ + 'loreseer.sessions.v1': jsonEncode({ + 'active': 'default', + 'sessions': [ + { + 'id': 'default', + 'name': 'Camp', + 'systems': ['juice', 'verdant', 'hexcrawl'], + } + ], + }), + }); + await t.pumpWidget(ProviderScope( + overrides: _overrides, + child: MaterialApp(home: HomeShell(oracle: _oracle())), + )); + await t.pumpAndSettle(); + await _openEditSystems(t); + + await t.tap(find.text('Save')); + await t.pumpAndSettle(); + + final container = + ProviderScope.containerOf(t.element(find.byType(HomeShell))); + final systems = + container.read(sessionsProvider).valueOrNull!.activeMeta.enabledSystems; + expect(systems, contains('verdant')); + expect(systems, isNot(contains('hexcrawl'))); + }); + + testWidgets('tapping edit-sys-hexcrawl then Save swaps in hexcrawl', + (t) async { + SharedPreferences.setMockInitialValues({ + 'loreseer.sessions.v1': jsonEncode({ + 'active': 'default', + 'sessions': [ + { + 'id': 'default', + 'name': 'Camp', + 'systems': ['juice', 'verdant'], + } + ], + }), + }); + await t.pumpWidget(ProviderScope( + overrides: _overrides, + child: MaterialApp(home: HomeShell(oracle: _oracle())), + )); + await t.pumpAndSettle(); + + final container = + ProviderScope.containerOf(t.element(find.byType(HomeShell))); + + await _openEditSystems(t); + await t.ensureVisible(find.byKey(const Key('edit-sys-hexcrawl'))); + await t.tap(find.byKey(const Key('edit-sys-hexcrawl'))); + await t.pumpAndSettle(); + await t.tap(find.text('Save')); + await t.pumpAndSettle(); + + final systems = + container.read(sessionsProvider).valueOrNull!.activeMeta.enabledSystems; + expect(systems, contains('hexcrawl')); + expect(systems, isNot(contains('verdant'))); + }); + + testWidgets('tapping edit-hexflavor-none then Save clears both flavors', + (t) async { + SharedPreferences.setMockInitialValues({ + 'loreseer.sessions.v1': jsonEncode({ + 'active': 'default', + 'sessions': [ + { + 'id': 'default', + 'name': 'Camp', + 'systems': ['juice', 'hexcrawl'], + } + ], + }), + }); + await t.pumpWidget(ProviderScope( + overrides: _overrides, + child: MaterialApp(home: HomeShell(oracle: _oracle())), + )); + await t.pumpAndSettle(); + + final container = + ProviderScope.containerOf(t.element(find.byType(HomeShell))); + + await _openEditSystems(t); + await t.ensureVisible(find.byKey(const Key('edit-hexflavor-none'))); + await t.tap(find.byKey(const Key('edit-hexflavor-none'))); + await t.pumpAndSettle(); + await t.tap(find.text('Save')); + await t.pumpAndSettle(); + + final systems = + container.read(sessionsProvider).valueOrNull!.activeMeta.enabledSystems; + expect(systems, isNot(contains('hexcrawl'))); + expect(systems, isNot(contains('verdant'))); + }); + + testWidgets( + 'party enabled + initialPartyTool emulator: an edit-party-tool-behavior ' + 'chip exists; tapping it and saving returns partyTool==behavior', + (t) async { + SharedPreferences.setMockInitialValues({ + 'loreseer.sessions.v1': jsonEncode({ + 'active': 'default', + 'sessions': [ + { + 'id': 'default', + 'name': 'Camp', + 'systems': ['juice', 'party'], + } + ], + }), + }); + await t.pumpWidget(ProviderScope( + overrides: _overrides, + child: MaterialApp(home: HomeShell(oracle: _oracle())), + )); + await t.pumpAndSettle(); + await _openEditSystems(t); + + expect(find.byKey(const Key('edit-party-tool-behavior')), findsOneWidget); + await t.ensureVisible(find.byKey(const Key('edit-party-tool-behavior'))); + await t.tap(find.byKey(const Key('edit-party-tool-behavior'))); + await t.pumpAndSettle(); + await t.tap(find.text('Save')); + await t.pumpAndSettle(); + + final container = + ProviderScope.containerOf(t.element(find.byType(HomeShell))); + expect( + container + .read(sessionsProvider) + .valueOrNull! + .activeMeta + .enabledPartyTool, + 'behavior'); + }); + + testWidgets( + 'without party in the picked set, the party-tool row is hidden and ' + 'partyTool is unchanged on save', (t) async { + SharedPreferences.setMockInitialValues({ + 'loreseer.sessions.v1': jsonEncode({ + 'active': 'default', + 'sessions': [ + { + 'id': 'default', + 'name': 'Camp', + 'systems': ['juice'], + 'partyTool': 'behavior', + } + ], + }), + }); + await t.pumpWidget(ProviderScope( + overrides: _overrides, + child: MaterialApp(home: HomeShell(oracle: _oracle())), + )); + await t.pumpAndSettle(); + await _openEditSystems(t); + + expect(find.byKey(const Key('edit-party-tool-behavior')), findsNothing); + await t.tap(find.text('Save')); + await t.pumpAndSettle(); + + final container = + ProviderScope.containerOf(t.element(find.byType(HomeShell))); + expect( + container + .read(sessionsProvider) + .valueOrNull! + .activeMeta + .enabledPartyTool, + 'behavior'); + }); +} diff --git a/test/exclusive_groups_test.dart b/test/exclusive_groups_test.dart new file mode 100644 index 0000000..faf5686 --- /dev/null +++ b/test/exclusive_groups_test.dart @@ -0,0 +1,120 @@ +import 'dart:convert'; +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:loreseer/engine/campaign_surfaces.dart'; +import 'package:loreseer/engine/emulator_data.dart'; +import 'package:loreseer/engine/hexcrawl_data.dart'; +import 'package:loreseer/engine/oracle.dart'; +import 'package:loreseer/engine/oracle_data.dart'; +import 'package:loreseer/engine/verdant_data.dart'; +import 'package:loreseer/shared/home_shell.dart'; +import 'package:loreseer/state/providers.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +Oracle _oracle() => Oracle(OracleData( + jsonDecode(File('assets/oracle_data.json').readAsStringSync()) + as Map)); +final _verdant = VerdantData( + jsonDecode(File('assets/verdant_data.json').readAsStringSync()) + as Map); +final _emu = EmulatorData( + jsonDecode(File('assets/emulator_data.json').readAsStringSync()) + as Map); +final _hex = HexcrawlData( + jsonDecode(File('assets/hexcrawl_data.json').readAsStringSync()) + as Map); + +final _overrides = [ + verdantDataProvider.overrideWith((ref) async => _verdant), + emulatorDataProvider.overrideWith((ref) async => _emu), + hexcrawlDataProvider.overrideWith((ref) async => _hex), +]; + +void main() { + test('normalizeExclusive keeps the first member by group order', () { + expect(normalizeExclusive({'juice', 'verdant', 'hexcrawl'}), + {'juice', 'verdant'}); + expect(normalizeExclusive({'hexcrawl'}), {'hexcrawl'}); + expect(normalizeExclusive({'juice', 'party'}), {'juice', 'party'}); + expect(normalizeExclusive(const {}), isEmpty); + }); + + test('kExclusiveSystemIds flattens group members', () { + expect(kExclusiveSystemIds, containsAll(['verdant', 'hexcrawl'])); + }); + + // Guard test: both the creation wizard and the edit-systems dialog exclude + // EVERY id in kExclusiveSystemIds from their generic chip loops and + // instead render them via a hand-written radio row hardcoded to + // kExclusiveGroups['hex-flavor']. That wiring works today because + // 'hex-flavor' is the only exclusive group, but nothing enforces it — a + // second exclusive group added to kExclusiveGroups without a matching + // radio row in both dialogs would have its members silently unreachable + // (skipped by the generic loop AND never rendered by the hardcoded row). + // These two tests pin today's set of exclusive ids to a rendered chip in + // both dialogs, so extending kExclusiveGroups without wiring the new + // group's UI fails loudly here instead of shipping a dead system id. + testWidgets( + 'wizard step 1 renders a cat- chip for every kExclusiveSystemIds', + (tester) async { + await tester.pumpWidget(MaterialApp( + home: Scaffold(body: Builder(builder: (context) { + return ElevatedButton( + onPressed: () => showDialog( + context: context, builder: (_) => const NewCampaignDialog()), + child: const Text('open'), + ); + })), + )); + await tester.tap(find.text('open')); + await tester.pumpAndSettle(); + await tester.enterText( + find.byKey(const Key('new-campaign-name')), 'Test Campaign'); + await tester.pump(); + await tester.tap(find.byKey(const Key('wizard-next'))); // step 0 -> 1 + await tester.pumpAndSettle(); + + for (final id in kExclusiveSystemIds) { + await tester.ensureVisible(find.byKey(Key('cat-$id'))); + expect(find.byKey(Key('cat-$id')), findsOneWidget, + reason: '$id belongs to kExclusiveSystemIds but the wizard never ' + 'renders a cat-$id chip for it'); + } + }); + + testWidgets( + 'edit-systems dialog renders an edit-sys- chip for every ' + 'kExclusiveSystemIds', (t) async { + SharedPreferences.setMockInitialValues({ + 'loreseer.sessions.v1': jsonEncode({ + 'active': 'default', + 'sessions': [ + { + 'id': 'default', + 'name': 'Camp', + 'systems': ['juice'] + } + ], + }), + }); + await t.pumpWidget(ProviderScope( + overrides: _overrides, + child: MaterialApp(home: HomeShell(oracle: _oracle())), + )); + await t.pumpAndSettle(); + await t.tap(find.byTooltip('Campaigns')); + await t.pumpAndSettle(); + await t.tap(find.byTooltip('Edit systems')); + await t.pumpAndSettle(); + + for (final id in kExclusiveSystemIds) { + await t.ensureVisible(find.byKey(Key('edit-sys-$id'))); + expect(find.byKey(Key('edit-sys-$id')), findsOneWidget, + reason: '$id belongs to kExclusiveSystemIds but the edit-systems ' + 'dialog never renders an edit-sys-$id chip for it'); + } + }); +} diff --git a/test/lonelog_campaign_ui_test.dart b/test/lonelog_campaign_ui_test.dart index f178125..8d4c818 100644 --- a/test/lonelog_campaign_ui_test.dart +++ b/test/lonelog_campaign_ui_test.dart @@ -131,6 +131,8 @@ void main() { final hex = find.byKey(const Key('cat-hexcrawl')); expect(hex, findsOneWidget); - expect(t.widget(hex).selected, isFalse); + // 'hexcrawl' is an exclusive hex-flavor group member; it now renders as a + // ChoiceChip (radio) rather than an additive FilterChip. + expect(t.widget(hex).selected, isFalse); }); } diff --git a/test/new_campaign_dialog_test.dart b/test/new_campaign_dialog_test.dart index 80f061a..d222e99 100644 --- a/test/new_campaign_dialog_test.dart +++ b/test/new_campaign_dialog_test.dart @@ -12,6 +12,7 @@ typedef NewCampaignResult = ({ String seedSystem, LoopKit? kit, String defaultOracle, + String partyTool, }); // Helper: open the dialog and return a reference to the future result. diff --git a/test/party_tool_test.dart b/test/party_tool_test.dart new file mode 100644 index 0000000..c030fd8 --- /dev/null +++ b/test/party_tool_test.dart @@ -0,0 +1,31 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:loreseer/engine/models.dart'; +import 'package:loreseer/state/providers.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + test('partyTool round-trips through JSON, omitted at default', () { + const m = SessionMeta(id: 's1', name: 'A'); + expect(m.toJson().containsKey('partyTool'), isFalse); + expect(m.enabledPartyTool, 'emulator'); + final m2 = SessionMeta.fromJson( + {'id': 's1', 'name': 'A', 'partyTool': 'sidekick'}); + expect(m2.enabledPartyTool, 'sidekick'); + expect(m2.toJson()['partyTool'], 'sidekick'); + }); + + test('setPartyTool persists and partyToolProvider reflects it', () async { + SharedPreferences.setMockInitialValues({}); + final container = ProviderContainer(); + addTearDown(container.dispose); + final sessions = await container.read(sessionsProvider.future); + expect(container.read(partyToolProvider), 'emulator'); + await container + .read(sessionsProvider.notifier) + .setPartyTool(sessions.active, 'behavior'); + expect(container.read(partyToolProvider), 'behavior'); + }); +} diff --git a/test/party_tools_pane_test.dart b/test/party_tools_pane_test.dart new file mode 100644 index 0000000..7cabfd5 --- /dev/null +++ b/test/party_tools_pane_test.dart @@ -0,0 +1,77 @@ +import 'dart:convert'; +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:loreseer/engine/emulator_data.dart'; +import 'package:loreseer/features/behavior_tables_screen.dart'; +import 'package:loreseer/features/party_emulator_screen.dart'; +import 'package:loreseer/features/party_tools_pane.dart'; +import 'package:loreseer/features/sidekick_screen.dart'; +import 'package:loreseer/shared/theme.dart'; +import 'package:loreseer/state/interpreter.dart'; +import 'package:loreseer/state/providers.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +import 'fake_interpreter.dart'; + +final _emulatorData = EmulatorData( + jsonDecode(File('assets/emulator_data.json').readAsStringSync()) + as Map); +final _emulatorOverride = + emulatorDataProvider.overrideWith((ref) async => _emulatorData); + +Override _fakeInterpreterOverride() => + interpreterServiceProvider.overrideWithValue(FakeInterpreterService( + initial: const InterpreterStatus(InterpreterPhase.ready))); + +void main() { + setUp(() => SharedPreferences.setMockInitialValues({})); + + testWidgets('default (no partyTool set) renders the Emulator paradigm only', + (tester) async { + SharedPreferences.setMockInitialValues({ + 'loreseer.sessions.v1': + '{"active":"default","sessions":[{"id":"default","name":"C1"}]}', + }); + final c = ProviderContainer( + overrides: [_emulatorOverride, _fakeInterpreterOverride()]); + addTearDown(c.dispose); + await c.read(sessionsProvider.future); + await tester.pumpWidget(UncontrolledProviderScope( + container: c, + child: MaterialApp( + theme: AppTheme.light(), + home: const Scaffold(body: PartyToolsPane())), + )); + await tester.pumpAndSettle(); + + expect(find.byType(PartyEmulatorScreen), findsOneWidget); + expect(find.byType(BehaviorTablesScreen), findsNothing); + expect(find.byType(SidekickScreen), findsNothing); + expect(find.byKey(const Key('party-tools-switch')), findsNothing); + }); + + testWidgets('partyTool "sidekick" renders only the Sidekick paradigm', + (tester) async { + final c = ProviderContainer(overrides: [ + _emulatorOverride, + _fakeInterpreterOverride(), + partyToolProvider.overrideWithValue('sidekick'), + ]); + addTearDown(c.dispose); + await tester.pumpWidget(UncontrolledProviderScope( + container: c, + child: MaterialApp( + theme: AppTheme.light(), + home: const Scaffold(body: PartyToolsPane())), + )); + await tester.pumpAndSettle(); + + expect(find.byType(SidekickScreen), findsOneWidget); + expect(find.byType(PartyEmulatorScreen), findsNothing); + expect(find.byType(BehaviorTablesScreen), findsNothing); + expect(find.byKey(const Key('party-tools-switch')), findsNothing); + }); +} diff --git a/test/tracking_tab_test.dart b/test/tracking_tab_test.dart index af0c202..65b9c21 100644 --- a/test/tracking_tab_test.dart +++ b/test/tracking_tab_test.dart @@ -7,9 +7,12 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:loreseer/engine/emulator_data.dart'; import 'package:loreseer/features/tracking_tab.dart'; import 'package:loreseer/shared/theme.dart'; +import 'package:loreseer/state/interpreter.dart'; import 'package:loreseer/state/providers.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'fake_interpreter.dart'; + final _emulatorData = EmulatorData( jsonDecode(File('assets/emulator_data.json').readAsStringSync()) as Map); @@ -70,7 +73,7 @@ void main() { expect(find.widgetWithText(Tab, 'Party'), findsOneWidget); }); - testWidgets('Party subtab hosts Emulator/Behavior/Sidekick behind a switch', + testWidgets('Party subtab hosts the campaign\'s chosen party tool', (tester) async { tester.view.physicalSize = const Size(1400, 1600); tester.view.devicePixelRatio = 1.0; @@ -79,9 +82,13 @@ void main() { SharedPreferences.setMockInitialValues({ 'loreseer.sessions.v1': '{"active":"default","sessions":[{"id":"default","name":"C1",' - '"systems":["party"]}]}', + '"systems":["party"],"partyTool":"sidekick"}]}', }); - final c = ProviderContainer(overrides: [_emulatorOverride]); + final c = ProviderContainer(overrides: [ + _emulatorOverride, + interpreterServiceProvider.overrideWithValue(FakeInterpreterService( + initial: const InterpreterStatus(InterpreterPhase.ready))), + ]); addTearDown(c.dispose); await c.read(sessionsProvider.future); await tester.pumpWidget(UncontrolledProviderScope( @@ -93,13 +100,9 @@ void main() { // Open the one Party subtab. await tester.tap(find.widgetWithText(Tab, 'Party')); await tester.pumpAndSettle(); - // The internal switch + all three surfaces are reachable. - expect(find.byKey(const Key('party-tools-switch')), findsOneWidget); - // Emulator is the default surface. - expect(find.byKey(const Key('pe-pet-actions')), findsOneWidget); - // Switch to Sidekick. - await tester.tap(find.text('Sidekick')); - await tester.pumpAndSettle(); + // No switch anymore — the campaign's chosen paradigm (sidekick) renders + // directly; the emulator surface is absent. + expect(find.byKey(const Key('party-tools-switch')), findsNothing); expect(find.byKey(const Key('pe-pet-actions')), findsNothing); });