@schandlergarcia/sf-web-components 1.9.87 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/.a4drules/features/command-center-dashboard-rule.md +1 -1
  2. package/.a4drules/skills/command-center-builder/SKILL.md +33 -36
  3. package/.a4drules/skills/command-center-builder/getting-started.md +64 -104
  4. package/.a4drules/skills/command-center-builder/improved-build-process.md +28 -34
  5. package/.a4drules/skills/command-center-guide/SKILL.md +9 -9
  6. package/.a4drules/skills/command-center-project/SKILL.md +4 -5
  7. package/.a4drules/skills/component-library/SKILL.md +8 -10
  8. package/.a4drules/skills/component-library/card-components.md +3 -3
  9. package/.a4drules/skills/component-library/chat-data.md +4 -6
  10. package/.a4drules/troubleshooting/codegen-overwrites-types.md +21 -162
  11. package/.a4drules/troubleshooting/graphql-introspection-failure.md +13 -264
  12. package/.a4drules/validation-requirements.md +3 -5
  13. package/.a4drules/webapp-data.md +1 -1
  14. package/CHANGELOG.md +30 -0
  15. package/CLAUDE.md +19 -39
  16. package/dist/components/library/cards/ActivityCard.js +9 -9
  17. package/dist/components/library/cards/ActivityCard.js.map +1 -1
  18. package/dist/styles/base.css +112 -27
  19. package/dist/styles/global.css +15 -30
  20. package/package.json +2 -3
  21. package/scripts/postinstall.mjs +39 -178
  22. package/scripts/reset-command-center.sh +67 -406
  23. package/scripts/validate-dashboard.sh +4 -4
  24. package/src/components/library/cards/ActivityCard.jsx +2 -2
  25. package/src/styles/base.css +223 -0
  26. package/src/styles/global.css +223 -0
  27. package/src/templates/config/vite.config.ts.template +0 -18
  28. package/.a4drules/features/engine-dashboard-rule.md +0 -63
  29. package/.a4drules/features/phase2-data-pattern.md +0 -15
  30. package/assets/images/engine_logo.png +0 -0
  31. package/data/README.md +0 -202
  32. package/data/USAGE.md +0 -81
  33. package/data/agentApiConfig.ts +0 -36
  34. package/data/copy-to-webapp.sh +0 -61
  35. package/data/engine-command-center-prd.md +0 -575
  36. package/data/engine-live-data.js +0 -135
  37. package/data/engine-sample-data.js +0 -378
  38. package/data/schema.graphql +0 -292
  39. package/data/useEngineLiveData.ts +0 -49
  40. package/data/useEvaAgent.ts +0 -288
  41. package/scripts/generate-schema-from-sample.mjs +0 -370
@@ -6,7 +6,7 @@ paths:
6
6
 
7
7
  # Command Center Dashboard Rules
8
8
 
9
- These rules apply to all dashboard files. For Engine-specific rules, see `engine-dashboard-rule.md`.
9
+ These rules apply to all dashboard files.
10
10
 
11
11
  **Read `.a4drules/skills/command-center-builder/SKILL.md` before building any dashboard.** It has the full conventions, component rules, and wiring steps.
12
12
 
@@ -1,12 +1,11 @@
1
1
  ---
2
2
  name: command-center-builder
3
3
  description: >-
4
- Conventions and patterns for building the Engine Travel Command Center
5
- dashboard and other command center pages. Covers layout patterns
6
- (visualization-hero, grid), component selection (MetricCard, ChartCard,
7
- GeoMap, ListCard, ActivityCard), dark mode, brand colors, styling, and
8
- wiring dashboards into the app. Use when scaffolding, building, or editing
9
- any dashboard page in this project.
4
+ Conventions and patterns for building Command Center dashboards.
5
+ Covers layout patterns (visualization-hero, grid), component selection
6
+ (MetricCard, ChartCard, GeoMap, ListCard, ActivityCard), dark mode,
7
+ brand colors, styling, and wiring dashboards into the app. Use when
8
+ scaffolding, building, or editing any dashboard page in this project.
10
9
  ---
11
10
 
12
11
  # Command Center Builder Rules
@@ -115,19 +114,17 @@ import {
115
114
  MapPinIcon, GlobeAltIcon, UserIcon,
116
115
  } from "@heroicons/react/24/outline";
117
116
 
118
- // Sample data
119
- import {
120
- MAP_MARKERS, MAP_ARCS, MAP_OVERLAYS, FLIGHT_STATUS_LIST,
121
- TRAVELER_CARDS, DISRUPTION_CARDS, ESCALATION_CARDS,
122
- MONTHLY_SPEND, METRICS,
123
- } from "@/data/engine-sample-data.js";
117
+ // Sample data (import from your project's sample data file)
118
+ // import { ... } from "@/data/sample-data.js";
124
119
 
125
- // Logo
126
- import engineLogo from "@/assets/images/engine_logo.png";
120
+ // Logo (import from your project's assets)
121
+ // import logo from "@/assets/images/logo.png";
127
122
  ```
128
123
 
129
124
  **Common mistakes:** `PlaneIcon` doesn't exist (use `PaperAirplaneIcon`), `HotelIcon` doesn't exist (use `BuildingOfficeIcon`), `import { useDataSource }` fails (it's a default export — no braces).
130
125
 
126
+ > **Sample data:** Import sample data from your project's data file. The exact exports depend on your domain. Use `useDataSource({ sample: SAMPLE_DATA, live: liveData })` for all data.
127
+
131
128
  ---
132
129
 
133
130
  ## Core Conventions
@@ -165,7 +162,7 @@ The component library (`@/components/library`) provides pre-built, themed, dark-
165
162
  | KPI / stat | `MetricCard` | `<div className="bg-white border ..."><h3>Total Spend</h3><span>$4,903</span></div>` |
166
163
  | List of items | `ListCard` | `<div className="bg-white ..."><div className="space-y-3">` with custom item rows |
167
164
  | Activity feed (display only) | `ActivityCard` or `FeedPanel` | `<div>` with hand-rolled interaction rows |
168
- | **Activity feed (with per-item actions like "Assign to Agent")** | **Custom markup inside `BaseCard`** | **`ActivityCard` (doesn't support per-item buttons — see Engine PRD Section 8a)** |
165
+ | **Activity feed (with per-item actions like "Assign to Agent")** | **Custom markup inside `BaseCard`** | **`ActivityCard` (doesn't support per-item buttons)** |
169
166
  | Data table | `TableCard` | `<table>` or custom grid of rows |
170
167
  | Stats panel | `WidgetCard` or `SectionCard` | `<div className="bg-white ... p-6">` with label/value pairs |
171
168
  | Custom interactive content (expand/collapse, inline details) | `WidgetCard` (sections accept arbitrary JSX) or `ListCard` (with `onItemClick` + `itemActions`) | Hand-rolled `<div>` card with custom expand/collapse logic |
@@ -190,7 +187,7 @@ import { MetricCard, ListCard, ActivityCard, WidgetCard } from "@/components/lib
190
187
  }))} />
191
188
 
192
189
  // Activity feed — use ActivityCard
193
- <ActivityCard title="Eva — Recent Interactions" items={interactions.map(i => ({
190
+ <ActivityCard title="Recent Activity" items={interactions.map(i => ({
194
191
  id: i.id, title: i.traveler, description: i.query,
195
192
  status: i.status, timestamp: i.time
196
193
  }))} />
@@ -203,19 +200,19 @@ import { MetricCard, ListCard, ActivityCard, WidgetCard } from "@/components/lib
203
200
 
204
201
  ## Images
205
202
 
206
- The company logo is at `src/assets/images/engine_logo.png`. Import it as a module and use it where a logo is needed (nav header, branding, etc.).
203
+ Import your company logo as a module and use it where a logo is needed (nav header, branding, etc.).
207
204
 
208
205
  ```jsx
209
- import engineLogo from "@/assets/images/engine_logo.png";
206
+ import logo from "@/assets/images/logo.png";
210
207
 
211
208
  // On light backgrounds:
212
- <img src={engineLogo} alt="Engine" className="h-5 w-auto" />
209
+ <img src={logo} alt="Company" className="h-5 w-auto" />
213
210
 
214
211
  // On dark backgrounds (slate-900 header, dark mode):
215
- <img src={engineLogo} alt="Engine" className="h-5 w-auto brightness-0 invert" />
212
+ <img src={logo} alt="Company" className="h-5 w-auto brightness-0 invert" />
216
213
  ```
217
214
 
218
- The logo is black use `brightness-0 invert` to make it white when placed on dark surfaces.
215
+ If the logo is dark-colored, use `brightness-0 invert` to make it white when placed on dark surfaces.
219
216
 
220
217
  - **Do not use external image URLs** (Unsplash, placeholder services, etc.) unless the user explicitly requests images.
221
218
  - **Do not use other asset images** (codey-*.png, etc.) unless the user asks for them.
@@ -227,7 +224,7 @@ No `<nav>`, header bar, tab bar, or content-swapping via `useState("activeTab")`
227
224
 
228
225
  ## Where Dashboards Live
229
226
 
230
- - Dashboard page files: `src/pages/` (e.g. `EngineDashboard.tsx`, `FleetDashboard.tsx`) — **NOT** `src/components/pages/`
227
+ - Dashboard page files: `src/pages/` (e.g. `MyDashboard.tsx`, `FleetDashboard.tsx`) — **NOT** `src/components/pages/`
231
228
  - File format: `.tsx` (MUST be TypeScript) — this is a TypeScript project, all React components use `.tsx`, NEVER `.jsx`.
232
229
  - `CommandCenter.tsx` wraps with `heroui-scope` div + `AppThemeProvider` + `DataModeProvider` + `Toast.Provider` from `@heroui/react`. **Never recreate these providers in dashboard pages.** When wiring a new dashboard, only change the import — preserve the `heroui-scope` wrapper and `Toast.Provider` exactly as-is. For toasts inside dashboards, import `toast` from `@heroui/react` (or `@/components/library`) — NOT from `sonner`.
233
230
  - **Wiring is covered at the top of this file** — see "WIRING — DO THIS FIRST".
@@ -309,10 +306,10 @@ function fmtK(n) {
309
306
 
310
307
  ## Brand & Accent Colors
311
308
 
312
- Defined in `global.css` (`--color-brand-*` and `--color-engine-*`), available as Tailwind classes.
309
+ Defined in `global.css` (`--color-brand-*`), available as Tailwind classes.
313
310
 
314
- - `engine-*` for the Engine brand: `engine-teal`, `engine-coral`, `engine-orange`, `engine-savings`, `engine-text`, `engine-muted`, `engine-label`, `engine-border`, `engine-bg`
315
- - `brand-*` for the legacy command center palette (indigo-based)
311
+ - `brand-*` for the command center palette (indigo-based)
312
+ - Custom brand tokens can be defined in `global.css` (e.g. `--color-brand-teal`, etc.)
316
313
  - Tailwind built-in colors for status (green/amber/red). Never use brand for status.
317
314
 
318
315
  ## Semantic Colors
@@ -373,7 +370,7 @@ Three layers: `filterUtils.js` (pure) → `usePageFilters` hook (state) → `Fil
373
370
  - Same layout for both modes — only data changes.
374
371
  - Sample data: 10–50 items, realistic, deterministic (no `Math.random()`).
375
372
  - Define sample data as constants outside the component body.
376
- - **Live data simulation:** When GraphQL is unavailable, use a separate live data file (`engine-live-data.js`) with a visibly different dataset. Create a hook that simulates async loading via `setTimeout`, then calls `setMode("live")` to flip all `useDataSource` calls at once. This makes the data transition visible — components refresh with new values after a loading period.
373
+ - **Live data simulation:** When GraphQL is unavailable, use a separate live data file with a visibly different dataset. Create a hook that simulates async loading via `setTimeout`, then calls `setMode("live")` to flip all `useDataSource` calls at once. This makes the data transition visible — components refresh with new values after a loading period.
377
374
 
378
375
  ```jsx
379
376
  // ✅ Correct: data defined outside, selected by mode
@@ -398,19 +395,19 @@ Define schemas outside component body. Always `required: true` on mandatory fiel
398
395
 
399
396
  ## AI Chat & Agent
400
397
 
401
- Two pieces for agent integration — a **ChatBar** component and the **`useEvaAgent` hook** (Agent REST API):
398
+ Two pieces for agent integration — a **ChatBar** component and an **agent hook** (Agent REST API):
402
399
 
403
- - **`ChatBar`** — command-palette strip for suggested prompts. Place between the hero map and data panels (full-width, `px-4 pt-4`), NOT in the header. Always provide 3–5 `suggestions`.
404
- - **`useEvaAgent`**pre-installed hook at `src/hooks/useEvaAgent.ts`. Handles OAuth → session → messages → cleanup via the Agentforce Agent REST API. Config is in `src/config/agentApi.ts`. Vite proxy rules in `vite.config.ts` forward requests.
400
+ - **`ChatBar`** — command-palette strip for suggested prompts. Place between the hero/visualization area and data panels (full-width, `px-4 pt-4`), NOT in the header. Always provide 3–5 `suggestions`.
401
+ - **Agent hook** a hook that handles OAuth → session → messages → cleanup via the Agentforce Agent REST API. Config lives in `src/config/agentApi.ts`. Vite proxy rules in `vite.config.ts` forward requests.
405
402
 
406
- > **Do NOT use `AgentforceConversationClient`** (the iframe widget). We use the Agent REST API via `useEvaAgent`.
407
- > **Do NOT create wrapper hooks** (useEvaChatAdapter, useDisruptionAlerts, etc.). Use `useEvaAgent` directly.
403
+ > **Do NOT use `AgentforceConversationClient`** (the iframe widget). Use the Agent REST API via a dedicated hook.
404
+ > **Do NOT create wrapper hooks** around the agent hook. Use it directly.
408
405
  > **Do NOT create `.env` or `.env.local` files** — config is hardcoded in `src/config/agentApi.ts`.
409
406
 
410
407
  ```tsx
411
- import useEvaAgent from "@/hooks/useEvaAgent";
408
+ import useAgentChat from "@/hooks/useAgentChat";
412
409
 
413
- const { messages, isReady, isSending, connect, sendMessage } = useEvaAgent();
410
+ const { messages, isReady, isSending, connect, sendMessage } = useAgentChat();
414
411
  useEffect(() => { connect(); }, [connect]);
415
412
 
416
413
  const handleChat = (text: string) => {
@@ -462,7 +459,7 @@ const spendData = [
462
459
  ];
463
460
  <ChartCard
464
461
  title="30-Day Spend"
465
- subtitle="Engine savings"
462
+ subtitle="Last 30 days"
466
463
  chart={
467
464
  <D3Chart
468
465
  data={spendData}
@@ -551,7 +548,7 @@ Before finishing a dashboard page, verify ALL of these:
551
548
  - [ ] **No inline `<svg>`** — use Heroicons from `@heroicons/react`
552
549
  - [ ] **`position: fixed` uses `createPortal`** — FABs, modals, toasts
553
550
  - [ ] **Data uses `useDataSource`** — sample data defined outside the component
554
- - [ ] **Only uses company logo** (`@/assets/images/engine_logo.png`) — no external URLs, no placeholder boxes
551
+ - [ ] **Only uses company logo** (from `@/assets/images/`) — no external URLs, no placeholder boxes
555
552
  - [ ] **Images preserve aspect ratio** — one dimension auto, never both fixed
556
553
  - [ ] **Imports only from `@/components/library`** — no shadcn, no Lucide, no `cn()`
557
554
  - [ ] **Grid patterns match the approved list** — no custom grid layouts
@@ -616,7 +613,7 @@ sf project deploy start --source-dir force-app/main/default/classes/TravelDisrup
616
613
 
617
614
  ### When to create metadata
618
615
 
619
- During the build, proactively create the Salesforce metadata needed for the features you're building. If the dashboard needs field access, create a permission set. If a new field would improve the data model, create it. If automation would enhance a workflow, create a flow. Tell the user what you're creating and ask before doing it. The PRD's build prompts (section 13) include specific instructions for these interactions, with XML templates in section 14.
616
+ During the build, proactively create the Salesforce metadata needed for the features you're building. If the dashboard needs field access, create a permission set. If a new field would improve the data model, create it. If automation would enhance a workflow, create a flow. Tell the user what you're creating and ask before doing it.
620
617
 
621
618
  ### Key rules
622
619
 
@@ -1,4 +1,4 @@
1
- # Engine Travel Command Center — Build Guide
1
+ # Command Center Dashboard — Build Guide
2
2
 
3
3
  The dashboard is built in **3 phases**, one per user prompt. Each phase adds a layer. Do NOT build ahead — only build what the current phase asks for.
4
4
 
@@ -6,17 +6,17 @@ The dashboard is built in **3 phases**, one per user prompt. Each phase adds a l
6
6
 
7
7
  ## RULES THAT APPLY TO EVERY PHASE
8
8
 
9
- > **Read these first. Violations of these rules are the #1 cause of failed demos.**
9
+ > **Read these first. Violations of these rules are the #1 cause of failed builds.**
10
10
 
11
- 1. **Phase 1 writes new files. Phases 2 and 3 make surgical edits.** Never rewrite `EngineDashboard.tsx` from scratch in Phase 2 or 3. Rewriting a 400+ line file takes 60s, risks losing prior work, and introduces regressions. Surgical edits take seconds.
11
+ 1. **Phase 1 writes new files. Phases 2 and 3 make surgical edits.** Never rewrite the dashboard file from scratch in Phase 2 or 3. Rewriting a 400+ line file takes 60s, risks losing prior work, and introduces regressions. Surgical edits take seconds.
12
12
 
13
- 2. **Do NOT read library component source files.** This means: do NOT read `GeoMap.jsx`, `BaseCard.jsx`, `Avatar.jsx`, `ChatBar.jsx`, `ChartCard.jsx`, `D3Chart.jsx`, `useDataSource.jsx`, `DataModeProvider.jsx`, `DataModeToggle.jsx`, or any file inside `src/components/library/`. All props and patterns are documented in this build guide and the PRD. Reading source files wastes time and produces no new information.
13
+ 2. **Do NOT read library component source files.** Do NOT read `GeoMap.jsx`, `BaseCard.jsx`, `Avatar.jsx`, `ChatBar.jsx`, `ChartCard.jsx`, `D3Chart.jsx`, `useDataSource.jsx`, `DataModeProvider.jsx`, `DataModeToggle.jsx`, or any file inside `src/components/library/`. All props and patterns are documented in this build guide and the SKILL.md. Reading source files wastes time and produces no new information.
14
14
 
15
15
  3. **Do NOT load unnecessary skills.** Phase 1 needs only `command-center-builder`. Do NOT load `outer-app`, `component-library`, `command-center-project`, `agentforce-test`, or `agentforce-observability` — they add latency and aren't needed.
16
16
 
17
17
  4. **Do NOT run `npm run build` or `npm run dev` during the build.** Vite handles JSX/TSX regardless of TypeScript errors. Pre-existing TS7016 errors (from untyped .jsx library files) are normal and expected.
18
18
 
19
- 5. **STOP and ASK before creating Salesforce metadata.** Custom fields, platform events, and Apex classes are scripted demo moments. Suggest them, wait for "yes," then create. Never create them proactively.
19
+ 5. **STOP and ASK before creating Salesforce metadata.** Custom fields, platform events, and Apex classes should be suggested to the user first. Never create them proactively.
20
20
 
21
21
  6. **Do NOT create extra files not listed in the build guide.** Each phase lists exactly which files to create or edit. Do NOT create wrapper hooks, adapter files, .env files, or any file not explicitly listed.
22
22
 
@@ -25,37 +25,32 @@ The dashboard is built in **3 phases**, one per user prompt. Each phase adds a l
25
25
  ## Phase 1 — Build the Dashboard (sample data only)
26
26
 
27
27
  ### FORBIDDEN in Phase 1
28
- - ❌ ChatBar, Eva, or any Agentforce integration (that's Phase 3)
29
- - ❌ `useEngineLiveData` or live data wiring (that's Phase 2)
30
- - ❌ Salesforce metadata — custom fields, platform events, Apex (that's Phases 2-3)
31
- - ❌ Reading library component source files (GeoMap.jsx, BaseCard.jsx, etc.)
28
+ - ❌ ChatBar or any Agentforce/AI integration (that's Phase 3)
29
+ - ❌ Live data hooks or live data wiring (that's Phase 2)
30
+ - ❌ Salesforce metadata — custom fields, platform events, Apex
31
+ - ❌ Reading library component source files
32
32
  - ❌ Loading skills other than `command-center-builder`
33
33
 
34
- ### Files to read (only these)
35
- 1. `engine-command-center-prd.md` — the full spec
36
- 2. `src/data/engine-sample-data.js`sample data shape
34
+ ### Files to read
35
+ 1. Your PRD or requirements document — the full spec
36
+ 2. Your sample data file to understand available data shapes
37
37
 
38
38
  ### Files to create/edit (in order)
39
39
  ```
40
- 1. WRITE src/pages/EngineDashboard.tsx ← full dashboard, one pass
41
- 2. EDIT src/components/workspace/CommandCenter.tsx ← import EngineDashboard
42
- 3. WRITE src/pages/Home.tsx ← REPLACE with CommandCenter wrapper (3 lines)
43
- 4. EDIT src/routes.tsx ← change index route label to "Dashboard"
40
+ 1. WRITE src/pages/YourDashboard.tsx ← full dashboard, one pass
41
+ 2. EDIT src/components/workspace/CommandCenter.tsx ← import YourDashboard
42
+ 3. WRITE src/pages/Home.tsx ← REPLACE with CommandCenter wrapper (3 lines)
43
+ 4. EDIT src/routes.tsx ← change index route label to "Dashboard"
44
44
  ```
45
45
 
46
- ### What to build in EngineDashboard.tsx
47
- - Sticky header (h-12, Engine logo, "Travel Command Center", "Powered by Agentforce" badge, bell icon, theme toggle)
48
- - Hero GeoMap (h-[520px]) with markers, arcs, overlays from sample data
49
- - Glass KPI overlays on the map (Active Travelers, Spend MTD, Compliance %, Eva Resolved)
50
- - Flight status strip (horizontal scroll, glass pills)
51
- - Escalations panel (BaseCard with "Assign to Agent" buttons, toast on click)
52
- - Disruptions panel (severity dots, flight info, Eva action lines)
53
- - Active Travelers panel (expandable cards with Avatar, details grid, "View in Salesforce" links)
54
- - Monthly Spend chart (ChartCard + D3Chart groupedBarChart)
55
- - All data via `useDataSource({ sample: SAMPLE_DATA, live: [] })` — leave `live:` empty
46
+ ### What to build
47
+ - Choose your layout pattern (visualization-hero with full-width map, or grid-first)
48
+ - Pick components from the library for each section (MetricCard, ChartCard, ListCard, TableCard, etc.)
49
+ - Wire all data via `useDataSource({ sample: SAMPLE_DATA, live: [] })` leave `live:` empty for now
50
+ - Add dark mode support to any custom markup
56
51
 
57
52
  ### Wiring
58
- - `CommandCenter.tsx` → import EngineDashboard instead of BlankDashboard
53
+ - `CommandCenter.tsx` → import your dashboard instead of BlankDashboard
59
54
  - `Home.tsx` → **REPLACE** the Account Search page with a 3-line wrapper that renders `<CommandCenter />`
60
55
  - `routes.tsx` → change the index route handle to `{ showInNavigation: false, showNavBar: false, label: "Dashboard" }`
61
56
 
@@ -67,112 +62,89 @@ Plan the entire file before writing. Do NOT write a partial dashboard and iterat
67
62
  ## Phase 2 — Connect to Live Data
68
63
 
69
64
  ### FORBIDDEN in Phase 2
70
- - ❌ `DataModeToggle` — do NOT add it to the UI. There is NO UI toggle. The switch is `dataStrategy.ts` on the backend.
71
- - ❌ Rewriting `EngineDashboard.tsx` from scratch make 5 targeted edits only
72
- - ❌ Reading library source files (`useDataSource.jsx`, `DataModeProvider.jsx`, `DataModeToggle.jsx`, `dataStrategy.ts`)
73
- - ❌ ChatBar, Eva, or Agentforce integration (that's Phase 3)
74
- - ❌ Platform events or Apex classes (that's Phase 3)
75
- - ❌ Renaming existing imports (don't add SAMPLE_ prefix — leave existing variable names alone, just fill in the `live:` props)
65
+ - ❌ Rewriting the dashboard file from scratch make targeted surgical edits only
66
+ - ❌ Reading library source files (`useDataSource.jsx`, `DataModeProvider.jsx`, etc.)
67
+ - ❌ ChatBar or AI/agent integration (that's Phase 3)
76
68
  - ❌ Creating extra files not listed below
77
69
  - ❌ Running `npm run build` between edits
78
70
 
79
71
  ### The point of Phase 2
80
- The dashboard switches from sample data (8 US travelers: Sarah Chen, Marcus Johnson…) to a completely different live dataset (12 global travelers: Raj Kapoor, Sofia Reyes… with a Midwest storm scenario). The user sees different names, different cities, different metrics, and different disruptions.
72
+ The dashboard switches from sample data to live data from your Salesforce org. The `useDataSource` hook handles the toggle you just need to fill in the `live:` props and flip the backend switch.
81
73
 
82
74
  ### How the switch works
83
75
  `ENABLE_SAMPLE_DATA_CACHE` in `src/lib/dataStrategy.ts` controls the mode. `CommandCenter.tsx` reads this flag and passes `initialMode` to `DataModeProvider`. When `true` (default) → sample mode. When `false` → live mode, every `useDataSource` returns its `live` prop.
84
76
 
85
- ### Files to read (only these — no others)
86
- 1. `src/pages/EngineDashboard.tsx` — the Phase 1 dashboard you're editing
87
- 2. `src/hooks/useEngineLiveData.ts` — to see the live data shape
77
+ ### Edits to make (in order)
88
78
 
89
- ### Edits to make (exactly 5, in order)
90
-
91
- **Edit 1 — Add import** at the top of EngineDashboard.tsx:
79
+ **Edit 1 Add live data import** at the top of your dashboard file:
92
80
  ```tsx
93
- import { useEngineLiveData } from "@/hooks/useEngineLiveData";
81
+ import { useLiveData } from "@/hooks/useLiveData";
94
82
  ```
95
83
 
96
84
  **Edit 2 — Add hook call** inside the component, near the top:
97
85
  ```tsx
98
- const live = useEngineLiveData();
86
+ const live = useLiveData();
99
87
  ```
100
88
 
101
89
  **Edit 3 — Update every `useDataSource` call** to pass live data:
102
90
  ```tsx
103
91
  // Before (Phase 1):
104
- const markers = useDataSource({ sample: MAP_MARKERS, live: [] });
92
+ const items = useDataSource({ sample: SAMPLE_ITEMS, live: [] });
105
93
  // After (Phase 2 — just fill in the live: prop):
106
- const markers = useDataSource({ sample: MAP_MARKERS, live: live.mapMarkers });
94
+ const items = useDataSource({ sample: SAMPLE_ITEMS, live: live.items });
107
95
  ```
108
- Do this for ALL useDataSource calls: markers, arcs, travelers, flights, escalations, disruptions, spendData.
96
+ Do this for ALL `useDataSource` calls in the dashboard.
109
97
 
110
- **Edit 4 — Update KPI derivations** to react to active data:
111
- ```tsx
112
- const activeMetrics = live.loading ? null : live.metrics;
113
- // Then use activeMetrics in KPI overlays when available, fall back to sample constants
114
- ```
98
+ **Edit 4 — Update any derived values** to react to the active data source.
115
99
 
116
100
  **Edit 5 — Flip the backend switch** — edit `src/lib/dataStrategy.ts`:
117
101
  ```tsx
118
102
  export const ENABLE_SAMPLE_DATA_CACHE = false;
119
103
  ```
120
104
 
121
- > ⚠️ **Do NOT skip Edit 5.** This is the most critical step. Without it, the data never switches and the demo fails. The dashboard will still show sample data no matter what you wired in Edits 1-4.
122
-
123
- That's 5 targeted edits, not a full rewrite.
124
-
125
- ### After wiring — STOP and suggest (do not create yet)
126
-
127
- Say: *"I notice Flight__c doesn't have a field to track weather impact on individual flights. A Weather_Impact__c picklist would help the dashboard filter storm-affected flights. Want me to create it?"*
105
+ > ⚠️ **Do NOT skip Edit 5.** This is the most critical step. Without it, the data never switches. The dashboard will still show sample data no matter what you wired in Edits 1-4.
128
106
 
129
- Only create `Flight__c.Weather_Impact__c` (PRD section 14a) AFTER the user says yes. Suggest ONLY this one field — do not suggest additional fields.
107
+ That's targeted surgical edits, not a full rewrite.
130
108
 
131
109
  ---
132
110
 
133
- ## Phase 3 — Add Agentforce
111
+ ## Phase 3 — Add AI Assistant
134
112
 
135
113
  ### FORBIDDEN in Phase 3
136
- - ❌ `AgentforceConversationClient` — do NOT use the iframe widget. We use the Agent REST API via `useEvaAgent`.
137
- - ❌ Wrapper hooks or adapter files — do NOT create `useEvaChatAdapter.ts`, `useDisruptionAlerts.ts`, or any extra hook. Use `useEvaAgent` directly.
138
- - ❌ `.env` or `.env.local` files — the config is hardcoded in `src/config/agentApi.ts` (pre-installed by the package)
139
- - ❌ Rewriting `EngineDashboard.tsx` from scratch
114
+ - ❌ `AgentforceConversationClient` — do NOT use the iframe widget. Use the Agent REST API via a dedicated hook.
115
+ - ❌ Wrapper hooks or adapter files — use the agent hook directly.
116
+ - ❌ `.env` or `.env.local` files — config is hardcoded in `src/config/agentApi.ts`
117
+ - ❌ Rewriting the dashboard file from scratch
140
118
  - ❌ Reading library component source files (including `ChatBar.jsx`)
141
- - ❌ Creating platform events or Apex classes without user confirmation
142
- - ❌ Loading `agentforce-test`, `agentforce-observability`, or `outer-app` skills
143
119
 
144
120
  ### Pre-installed files (already in the project — do NOT recreate)
145
- These files are installed by the package and restored by the reset script. They already exist:
146
- - `src/hooks/useEvaAgent.ts` — the Agent API hook (OAuth → session → messages → cleanup)
147
- - `src/config/agentApi.ts` — hardcoded credentials and endpoint config
148
- - `vite.config.ts` — already has `/sf-oauth` and `/sf-agent` proxy rules
121
+ If the agent hook and config files are already installed by the package, they already exist:
122
+ - `src/hooks/useAgentChat.ts` — the Agent API hook
123
+ - `src/config/agentApi.ts` — endpoint config
124
+ - `vite.config.ts` — already has proxy rules for agent API
149
125
 
150
126
  **Do NOT create, rewrite, or modify these files.** Just import and use them.
151
127
 
152
- ### Files to read (only these)
153
- 1. `src/pages/EngineDashboard.tsx` — the current dashboard
128
+ ### Edits to make (in order)
154
129
 
155
- ### Edits to make (exactly 4, in order)
156
-
157
- **Edit 1 — Add imports** at the top of EngineDashboard.tsx:
130
+ **Edit 1 Add imports** at the top of the dashboard file:
158
131
  ```tsx
159
132
  import { ChatBar } from "@/components/library";
160
- import useEvaAgent from "@/hooks/useEvaAgent";
133
+ import useAgentChat from "@/hooks/useAgentChat";
161
134
  ```
162
135
 
163
136
  **Edit 2 — Add chat suggestions constant** at module scope (outside the component):
164
137
  ```tsx
165
138
  const CHAT_SUGGESTIONS = [
166
- "Are any travelers affected by the Denver weather?",
167
- "What's our rebooking policy for weather delays?",
168
- "Notify all travelers on disrupted flights",
169
- "Create a support case for the SFO→JFK cancellation",
139
+ "Show me a summary of recent activity",
140
+ "What items need attention?",
141
+ "Help me understand the current status",
170
142
  ];
171
143
  ```
172
144
 
173
145
  **Edit 3 — Add agent hook + handler** inside the component:
174
146
  ```tsx
175
- const { messages: evaMessages, isReady, isSending, connect, sendMessage } = useEvaAgent();
147
+ const { messages, isReady, isSending, connect, sendMessage } = useAgentChat();
176
148
  useEffect(() => { connect(); }, [connect]);
177
149
 
178
150
  const handleChat = (text: string) => {
@@ -181,13 +153,12 @@ const handleChat = (text: string) => {
181
153
  };
182
154
  ```
183
155
 
184
- **Edit 4 — Insert ChatBar JSX** between the map section closing `</div>` and the data panels `<div>`:
156
+ **Edit 4 — Insert ChatBar JSX** between the visualization area and data panels:
185
157
  ```tsx
186
- {/* ── EVA CHATBAR ──────────────────────────────────────────────── */}
187
158
  <div className="px-4 pt-4">
188
159
  <ChatBar
189
- title="Eva"
190
- placeholder="Ask Eva anything about travelers, bookings, policy, or spend…"
160
+ title="AI Assistant"
161
+ placeholder="Ask anything about your data…"
191
162
  suggestions={CHAT_SUGGESTIONS}
192
163
  onSend={handleChat}
193
164
  />
@@ -196,17 +167,9 @@ const handleChat = (text: string) => {
196
167
 
197
168
  That's 4 targeted edits. Nothing else.
198
169
 
199
- ### After adding EvaSTOP and suggest (do not create yet)
200
-
201
- Say: *"The dashboard tracks disruptions in real time. I can create a Travel_Disruption_Alert__e platform event so disruption data can be published to the Salesforce event bus. Want me to set it up?"*
202
-
203
- Only create the platform event (PRD section 14b) AFTER the user confirms.
204
-
205
- ### After the platform event — STOP and suggest again
206
-
207
- Say: *"Now I'll write an Apex service class to publish disruption records to that event bus. Want me to create it?"*
170
+ ### After adding AI — suggest Salesforce metadata
208
171
 
209
- Only create `TravelDisruptionEventService` (PRD section 14c) AFTER the user confirms.
172
+ If your use case benefits from platform events or Apex services, suggest them to the user and wait for confirmation before creating.
210
173
 
211
174
  ---
212
175
 
@@ -216,16 +179,13 @@ Only create `TravelDisruptionEventService` (PRD section 14c) AFTER the user conf
216
179
  |---|---------|---------|---------|
217
180
  | Dashboard layout & panels | Write new file | — | — |
218
181
  | Sample data | Wire (`live: []`) | — | — |
219
- | Live data wiring | Skip | 5 surgical edits | — |
220
- | Flip `dataStrategy.ts` to `false` | Skip | **Edit 5 — don't skip** | — |
221
- | DataModeToggle in UI | **NO — never** | **NO — never** | **NO never** |
222
- | Custom field metadata | Skip | Suggest wait | |
223
- | ChatBar (Eva) | Skip | Skip | 4 surgical edits |
224
- | `useEvaAgent` hook | Skip | Skip | Import (pre-installed) |
182
+ | Live data wiring | Skip | Surgical edits | — |
183
+ | Flip `dataStrategy.ts` to `false` | Skip | **Don't skip** | — |
184
+ | ChatBar / AI assistant | Skip | Skip | Surgical edits |
185
+ | Agent hook | Skip | Skip | Import (pre-installed) |
225
186
  | Wrapper hooks / adapters | **NO — never** | **NO — never** | **NO — never** |
226
- | Platform event | Skip | Skip | Suggest → wait |
227
- | Apex service | Skip | Skip | Suggest → wait |
187
+ | Salesforce metadata | Skip | Suggest → wait | Suggest → wait |
228
188
 
229
- **Data mode control:** `ENABLE_SAMPLE_DATA_CACHE` in `src/lib/dataStrategy.ts` is the backend switch. Phase 1 leaves it `true`. Phase 2 flips it to `false`. There is NO UI toggle — never add `DataModeToggle`.
189
+ **Data mode control:** `ENABLE_SAMPLE_DATA_CACHE` in `src/lib/dataStrategy.ts` is the backend switch. Phase 1 leaves it `true`. Phase 2 flips it to `false`.
230
190
 
231
- **Agent communication:** `useEvaAgent` hook in `src/hooks/useEvaAgent.ts` handles OAuth → session → messages → cleanup via the Agent REST API. Config is in `src/config/agentApi.ts`. Vite proxy rules (`/sf-oauth`, `/sf-agent`) in `vite.config.ts` forward requests. All three files are pre-installed — do NOT recreate them.
191
+ **Agent communication:** The agent hook handles OAuth → session → messages → cleanup via the Agent REST API. Config is in `src/config/agentApi.ts`. Vite proxy rules forward requests. These files are pre-installed — do NOT recreate them.
@@ -2,9 +2,9 @@
2
2
 
3
3
  ## The #1 Rule: Phase 1 Writes, Phases 2-3 Edit
4
4
 
5
- - **Phase 1** creates `EngineDashboard.tsx` from scratch (Write). Also writes CommandCenter.tsx, Home.tsx, edits routes.tsx.
6
- - **Phase 2** makes exactly 5 surgical edits. Never rewrites the file.
7
- - **Phase 3** makes exactly 4 surgical edits. Never rewrites the file.
5
+ - **Phase 1** creates your dashboard file from scratch (Write). Also writes CommandCenter.tsx, Home.tsx, edits routes.tsx.
6
+ - **Phase 2** makes targeted surgical edits to wire live data. Never rewrites the file.
7
+ - **Phase 3** makes targeted surgical edits to add AI chat. Never rewrites the file.
8
8
 
9
9
  Rewriting a 400+ line file from scratch takes 60 seconds, risks losing prior work, and can introduce regressions. Surgical edits take seconds each and preserve everything.
10
10
 
@@ -12,58 +12,55 @@ Rewriting a 400+ line file from scratch takes 60 seconds, risks losing prior wor
12
12
 
13
13
  1. **Load only `command-center-builder` skill before building.** Do NOT load component-library, command-center-project, outer-app, agentforce-test, or agentforce-observability — they add latency and aren't needed.
14
14
 
15
- 2. **Do NOT read component source files.** This means ALL files inside `src/components/library/` are off-limits: GeoMap.jsx, BaseCard.jsx, Avatar.jsx, ChatBar.jsx, D3Chart.jsx, useDataSource.jsx, DataModeProvider.jsx, DataModeToggle.jsx, etc. Props/patterns are documented in the build guide and PRD.
15
+ 2. **Do NOT read component source files.** This means ALL files inside `src/components/library/` are off-limits: GeoMap.jsx, BaseCard.jsx, Avatar.jsx, ChatBar.jsx, D3Chart.jsx, useDataSource.jsx, DataModeProvider.jsx, DataModeToggle.jsx, etc. Props/patterns are documented in the build guide.
16
16
 
17
17
  3. **Phase 1: Write the dashboard in one pass.** Plan the full file before writing. Write the complete component with all imports, data, and JSX in a single Write call.
18
18
 
19
- 4. **Phases 2-3: Make the exact edits listed in the build guide.** Phase 2 = 5 edits. Phase 3 = 4 edits. No more, no less.
19
+ 4. **Phases 2-3: Make the edits listed in the build guide.** Targeted surgical edits only. No full rewrites.
20
20
 
21
21
  5. **Do NOT run `npm run build`, `npm run dev`, `tsc`, or `npm run validate:dashboard` during the build.** Vite handles it. TS7016 errors are pre-existing and expected.
22
22
 
23
- 6. **STOP and ASK before creating metadata.** Custom fields, platform events, and Apex classes are scripted demo moments. Suggest, wait, create.
23
+ 6. **STOP and ASK before creating metadata.** Custom fields, platform events, and Apex classes should be suggested first. Wait for confirmation.
24
24
 
25
- 7. **Do NOT create extra files.** No wrapper hooks (useEvaChatAdapter, useDisruptionAlerts), no .env files, no adapter files. The build guide lists every file to create or edit.
25
+ 7. **Do NOT create extra files.** No wrapper hooks, no .env files, no adapter files. The build guide lists every file to create or edit.
26
26
 
27
27
  ## Phase 1 File Write Order
28
28
 
29
29
  ```
30
- 1. WRITE src/pages/EngineDashboard.tsx ← full dashboard, one pass
31
- 2. EDIT src/components/workspace/CommandCenter.tsx ← swap BlankDashboard → EngineDashboard
32
- 3. WRITE src/pages/Home.tsx ← 3-line CommandCenter wrapper
33
- 4. EDIT src/routes.tsx ← change index route label to "Dashboard"
30
+ 1. WRITE src/pages/YourDashboard.tsx ← full dashboard, one pass
31
+ 2. EDIT src/components/workspace/CommandCenter.tsx ← swap BlankDashboard → YourDashboard
32
+ 3. WRITE src/pages/Home.tsx ← 3-line CommandCenter wrapper
33
+ 4. EDIT src/routes.tsx ← change index route label to "Dashboard"
34
34
  ```
35
35
 
36
- ## Phase 2 Edit Order (5 edits)
36
+ ## Phase 2 Edit Order
37
37
 
38
38
  ```
39
- 1. Add useEngineLiveData import to EngineDashboard.tsx
40
- 2. Add const live = useEngineLiveData() hook call
39
+ 1. Add live data import to your dashboard file
40
+ 2. Add live data hook call inside the component
41
41
  3. Update each useDataSource({ sample, live: [] }) → live: live.xxx
42
- 4. Update KPI derivations to use activeMetrics
42
+ 4. Update any derived values to react to active data
43
43
  5. Flip ENABLE_SAMPLE_DATA_CACHE to false in src/lib/dataStrategy.ts
44
- → STOP — suggest Weather_Impact__c, wait for confirmation
44
+ → STOP — suggest metadata if applicable, wait for confirmation
45
45
  ```
46
46
 
47
- ⚠️ **Edit 5 is the most critical.** Without it, the data never switches and the demo fails.
47
+ ⚠️ **The final edit (flipping the flag) is the most critical.** Without it, the data never switches.
48
48
 
49
- **NEVER add DataModeToggle to the UI.** The switch is `ENABLE_SAMPLE_DATA_CACHE` in `dataStrategy.ts`.
50
-
51
- ## Phase 3 Edit Order (4 edits)
49
+ ## Phase 3 Edit Order
52
50
 
53
51
  ```
54
- 1. Add ChatBar + useEvaAgent imports to EngineDashboard.tsx
55
- 2. Add CHAT_SUGGESTIONS constant at module scope
56
- 3. Add useEvaAgent hook call + handleChat inside component
57
- 4. Insert <ChatBar /> JSX between map and data panels
58
- → STOP — suggest platform event, wait for confirmation
59
- → STOP — suggest Apex class, wait for confirmation
52
+ 1. Add ChatBar + agent hook imports to your dashboard file
53
+ 2. Add chat suggestions constant at module scope
54
+ 3. Add agent hook call + handleChat inside component
55
+ 4. Insert <ChatBar /> JSX between visualization and data panels
56
+ → STOP — suggest metadata if applicable, wait for confirmation
60
57
  ```
61
58
 
62
- **useEvaAgent, agentApi.ts, and vite.config.ts proxy rules are pre-installed.** Do NOT recreate them. Just import `useEvaAgent` from `@/hooks/useEvaAgent`.
59
+ **Agent hook and config files are pre-installed.** Do NOT recreate them. Just import and use.
63
60
 
64
- **NEVER use AgentforceConversationClient.** We use the Agent REST API via `useEvaAgent`.
61
+ **NEVER use AgentforceConversationClient.** Use the Agent REST API via the dedicated hook.
65
62
 
66
- **NEVER create wrapper hooks** (useEvaChatAdapter, useDisruptionAlerts, etc.). Use `useEvaAgent` directly.
63
+ **NEVER create wrapper hooks.** Use the agent hook directly.
67
64
 
68
65
  ## Common Time Wasters
69
66
 
@@ -71,10 +68,7 @@ Rewriting a 400+ line file from scratch takes 60 seconds, risks losing prior wor
71
68
  |-------|-----|
72
69
  | Loading 4-5 skills before starting | Load only command-center-builder |
73
70
  | Reading GeoMap.jsx, ChatBar.jsx, useDataSource.js source | Props are in the build guide — trust the docs |
74
- | Rewriting EngineDashboard.tsx in Phase 2/3 | Make 5 or 4 targeted edits |
71
+ | Rewriting the dashboard in Phase 2/3 | Make targeted surgical edits |
75
72
  | Running `npm run build` between edits | Don't — Vite handles it |
76
- | Adding DataModeToggle to the UI | **NEVER** — the switch is dataStrategy.ts |
77
- | Creating useEvaChatAdapter or useDisruptionAlerts | **NEVER** — use useEvaAgent directly, no wrappers |
73
+ | Creating wrapper hooks or adapter files | **NEVER** — use hooks directly |
78
74
  | Creating .env or .env.local files | **NEVER** — config is hardcoded in src/config/agentApi.ts |
79
- | Renaming imports with SAMPLE_ prefix | Don't rename — just fill in the `live:` props |
80
- | Suggesting 3+ custom fields | Suggest only Weather_Impact__c |