InsForge Dev Dashboard
Use this skill for dashboard work in the InsForge repository.
Scope
packages/dashboard/src/**
packages/dashboard/package.json
packages/dashboard/README.md
packages/dashboard/*.config.*
frontend/src/**
frontend/package.json
Working Rules
Respect the shared-package versus host-app boundary.
- This dashboard is built with React and TypeScript.
packages/dashboard/ is the source of truth for the dashboard product.
- The package must support both
self-hosting and cloud-hosting modes.
- Keep self-hosting-only bootstrap, local env defaults, and shell styling in
frontend/.
- Do not let
packages/dashboard/ depend on frontend/.
- If both modes need a capability, define it in the package API first.
Preserve dashboard data-flow conventions.
- Follow the flow
service -> hook -> UI.
- Use
apiClient for HTTP calls so auth refresh and error handling stay consistent.
- Put request logic in services, data fetching and mutation state in hooks, and rendering/orchestration in UI components and pages.
- Reuse existing contexts, host abstractions, and hooks before creating new global state.
Reuse the existing component layers.
- Use
@insforge/ui for generic primitives.
- Use shared dashboard components when the pattern is already present.
- Keep reusable dashboard UI in
packages/dashboard/.
- Only add UI to
frontend/ when it is specific to the local self-hosting shell.
- Keep package styles scoped to the dashboard container.
Keep the package surface aligned with shared contracts.
- Import cross-package types and Zod-derived shapes from
@insforge/shared-schemas.
- When backend payloads change, update the related services, hooks, UI, and exported types together.
- Keep
packages/dashboard/src/index.ts and packages/dashboard/src/types aligned with the public package API.
- Never use the TypeScript
any type. Prefer precise prop, state, API, and hook result types.
Frontend Testing
Use the lowest test layer that covers the risk. Add one focused regression test for bug fixes when practical.
| Change type |
Test layer |
Location |
Command |
| Pure helper, parser, formatter, state reducer |
Unit |
packages/dashboard/src/**/__tests__/*.test.ts |
npm --workspace @insforge/dashboard run test:unit |
| React component behavior, forms, dialogs, conditional rendering |
Component |
packages/dashboard/src/**/__tests__/*.test.tsx |
npm --workspace @insforge/dashboard run test:component |
| Routing, auth redirects, host-mode integration, browser-only behavior |
UI smoke |
packages/dashboard/tests/ui/*.spec.ts |
npm --workspace @insforge/dashboard run test:ui |
Conventions:
npm --workspace @insforge/dashboard run test runs the full Vitest suite: unit plus component.
- GitHub Actions splits dashboard checks into unit, component, and UI jobs in
.github/workflows/frontend-tests.yml. Update the workflow when adding or renaming test scripts.
- Unit tests should avoid React rendering and network mocking. Test data transformations directly.
- Component tests use Testing Library with
packages/dashboard/src/test/setup.ts. Mock hooks, services, and host context at the package boundary; assert user-visible behavior and callback effects, not implementation details or CSS class strings.
- UI smoke tests use Playwright against the local
frontend/ shell. Mock backend API routes in packages/dashboard/tests/ui/fixtures/; every mocked route must either fulfill, fallback, or abort. Do not leave requests pending after a test branch.
- Prefer one clear test per user-observable behavior over broad snapshot tests. Avoid brittle assertions tied to copy that is not part of the behavior being protected.
Local debug: viewing cloud-hosting-only UI in self-hosting
Use when previewing UI gated on useIsCloudHostingMode(), isInsForgeCloudProject(), or a PostHog feature flag (e.g. the CTest dashboard variant, dashboard-v3-experiment === 'c_test', the CLI connect panel) while running the local frontend/ self-hosting shell.
The lowest-friction approach is to temporarily hardcode the three gates below to true/the new branch, then restart the Vite dev server. These edits bypass real host/project detection and MUST be fully reverted before committing — landing them breaks both self-hosting and cloud-hosting users.
Hardcodes
packages/dashboard/src/lib/config/DashboardHostContext.tsx — useIsCloudHostingMode() → return true; (was useDashboardHost().mode === 'cloud-hosting').
packages/dashboard/src/lib/utils/utils.ts — isInsForgeCloudProject() → return true; (was the .insforge.app hostname check).
- If the UI is also feature-flag-gated, hardcode the consumer. For CTest:
AppRoutes.tsx → const DashboardHomePage = CTestDashboardPage; and, if relevant, the matching branch in AppLayout.tsx for <ConnectDialogV2>.
Mark every hardcode with a trailing // LOCAL DEBUG: <original expression> comment so revert is a mechanical search.
Revert checklist — run all before committing
git grep -n "LOCAL DEBUG" packages/dashboard/src/ returns zero matches.
- Each gate is restored to its original expression, not just an equivalent value (the
mode === 'cloud-hosting' comparison, the hostname check, the getFeatureFlag(...) call must all be back).
- Any imports deleted during debug (commonly
DashboardPage, getFeatureFlag, ConnectDialog) are restored.
cd packages/dashboard && npm run lint && npm run typecheck both pass.
git diff of the four files above shows only intended changes — no return true;, no missing imports.
Rationalizations to reject
| Excuse |
Reality |
| "I'll revert in a follow-up PR." |
Follow-up = a window where prod is broken. Revert now. |
| "The original check was effectively the same." |
If it were, you wouldn't have needed the hardcode. Restore the expression, not a value-equivalent. |
| "Lint passed, so the deleted import doesn't matter." |
Lint passed because the import was deleted; on revert the original code needs it back. |
| "I'll ship the env-var override instead." |
No env-var override is wired in the code. Don't invent one on the commit path — restore the original. |
Locale / language preference
The dashboard has a language preference layer (selector + cloud sync) and
bundled react-i18next translations for the chrome, overview page, and Backend
Advisor (lib/i18n/, namespace chrome). Feature pages beyond those are
still English — extend the same namespace as they get translated.
lib/contexts/LocaleContext.tsx — LocaleProvider / useLocale /
SUPPORTED_LOCALES / normalizeLocale. Resolution order: cloud account
preference → insforge-locale localStorage → navigator.language → en.
Mirrors the ThemeContext pattern.
components/LanguageSelect.tsx — endonym-labelled selector; rendered in
AppHeader (self-host) and the AppSidebar bottom in cloud-hosting mode
(the header is hidden inside the iframe).
- Cloud sync contract (
@insforge/shared-schemas cloud-events):
parent → child USER_INFO carries optional preferredLocale;
child → parent UPDATE_PREFERRED_LOCALE { locale } is fire-and-forget and
the shell persists it to users.preferred_locale via the profile API
(plumbed through the onUpdatePreferredLocale host prop).
- Version-skew tolerance is a contract: old shells ignore unknown message
types; old dashboards ignore extra
USER_INFO fields. Never make either
side require the locale fields.
- Adding a language: extend
SUPPORTED_LOCALES + LOCALE_LABELS, and keep
the list aligned with the cloud marketing site's src/i18n/routing.ts
(insforge-cloud repo) or the account preference will name a locale one
surface can't render. Route locale-ish input through normalizeLocale.
- Self-host mode must work with zero cloud callbacks (localStorage only);
extend
lib/contexts/__tests__/LocaleContext.test.tsx when touching this.
- Every key added to
lib/i18n/locales/en.json must exist in all four locale
files — lib/i18n/__tests__/localeParity.test.ts fails CI otherwise
(plural suffixes normalized; zh carries only _other).
- Never translate user-generated names (tables, buckets) — only static ids.
See the note in
components/FeatureSidebar.tsx.
Validation
cd packages/dashboard && npm run test:unit when changing pure helpers or reducers
cd packages/dashboard && npm run test:component when changing React component behavior
cd packages/dashboard && npm run test:ui when changing routing, auth, host-mode integration, or browser-only behavior
cd packages/dashboard && npm run typecheck
cd packages/dashboard && npm run build
cd frontend && npm run build when the local self-hosting shell changes
For shared contract changes, also validate packages/shared-schemas/ and the affected backend surface.
1---2name: dashboard3description: Use this skill when contributing to InsForge's shared dashboard package. This is for maintainers editing `packages/dashboard`, which ships in `self-hosting` and `cloud-hosting` modes, and the local `frontend/` shell used for `self-hosting` in this repo.4---56# InsForge Dev Dashboard78Use this skill for dashboard work in the InsForge repository.910## Scope1112- `packages/dashboard/src/**`13- `packages/dashboard/package.json`14- `packages/dashboard/README.md`15- `packages/dashboard/*.config.*`16- `frontend/src/**`17- `frontend/package.json`1819## Working Rules20211. Respect the shared-package versus host-app boundary.22 - This dashboard is built with React and TypeScript.23 - `packages/dashboard/` is the source of truth for the dashboard product.24 - The package must support both `self-hosting` and `cloud-hosting` modes.25 - Keep self-hosting-only bootstrap, local env defaults, and shell styling in `frontend/`.26 - Do not let `packages/dashboard/` depend on `frontend/`.27 - If both modes need a capability, define it in the package API first.28292. Preserve dashboard data-flow conventions.30 - Follow the flow `service -> hook -> UI`.31 - Use `apiClient` for HTTP calls so auth refresh and error handling stay consistent.32 - Put request logic in services, data fetching and mutation state in hooks, and rendering/orchestration in UI components and pages.33 - Reuse existing contexts, host abstractions, and hooks before creating new global state.34353. Reuse the existing component layers.36 - Use `@insforge/ui` for generic primitives.37 - Use shared dashboard components when the pattern is already present.38 - Keep reusable dashboard UI in `packages/dashboard/`.39 - Only add UI to `frontend/` when it is specific to the local self-hosting shell.40 - Keep package styles scoped to the dashboard container.41424. Keep the package surface aligned with shared contracts.43 - Import cross-package types and Zod-derived shapes from `@insforge/shared-schemas`.44 - When backend payloads change, update the related services, hooks, UI, and exported types together.45 - Keep `packages/dashboard/src/index.ts` and `packages/dashboard/src/types` aligned with the public package API.46 - Never use the TypeScript `any` type. Prefer precise prop, state, API, and hook result types.4748## Frontend Testing4950Use the lowest test layer that covers the risk. Add one focused regression test for bug fixes when practical.5152| Change type | Test layer | Location | Command |53| --- | --- | --- | --- |54| Pure helper, parser, formatter, state reducer | Unit | `packages/dashboard/src/**/__tests__/*.test.ts` | `npm --workspace @insforge/dashboard run test:unit` |55| React component behavior, forms, dialogs, conditional rendering | Component | `packages/dashboard/src/**/__tests__/*.test.tsx` | `npm --workspace @insforge/dashboard run test:component` |56| Routing, auth redirects, host-mode integration, browser-only behavior | UI smoke | `packages/dashboard/tests/ui/*.spec.ts` | `npm --workspace @insforge/dashboard run test:ui` |5758Conventions:5960- `npm --workspace @insforge/dashboard run test` runs the full Vitest suite: unit plus component.61- GitHub Actions splits dashboard checks into unit, component, and UI jobs in `.github/workflows/frontend-tests.yml`. Update the workflow when adding or renaming test scripts.62- Unit tests should avoid React rendering and network mocking. Test data transformations directly.63- Component tests use Testing Library with `packages/dashboard/src/test/setup.ts`. Mock hooks, services, and host context at the package boundary; assert user-visible behavior and callback effects, not implementation details or CSS class strings.64- UI smoke tests use Playwright against the local `frontend/` shell. Mock backend API routes in `packages/dashboard/tests/ui/fixtures/`; every mocked route must either fulfill, fallback, or abort. Do not leave requests pending after a test branch.65- Prefer one clear test per user-observable behavior over broad snapshot tests. Avoid brittle assertions tied to copy that is not part of the behavior being protected.6667## Local debug: viewing cloud-hosting-only UI in self-hosting6869**Use when** previewing UI gated on `useIsCloudHostingMode()`, `isInsForgeCloudProject()`, or a PostHog feature flag (e.g. the CTest dashboard variant, `dashboard-v3-experiment === 'c_test'`, the CLI connect panel) while running the local `frontend/` self-hosting shell.7071The lowest-friction approach is to **temporarily hardcode** the three gates below to `true`/the new branch, then restart the Vite dev server. These edits bypass real host/project detection and MUST be fully reverted before committing — landing them breaks both self-hosting and cloud-hosting users.7273### Hardcodes74751. `packages/dashboard/src/lib/config/DashboardHostContext.tsx` — `useIsCloudHostingMode()` → `return true;` (was `useDashboardHost().mode === 'cloud-hosting'`).762. `packages/dashboard/src/lib/utils/utils.ts` — `isInsForgeCloudProject()` → `return true;` (was the `.insforge.app` hostname check).773. If the UI is also feature-flag-gated, hardcode the consumer. For CTest: `AppRoutes.tsx` → `const DashboardHomePage = CTestDashboardPage;` and, if relevant, the matching branch in `AppLayout.tsx` for `<ConnectDialogV2>`.7879Mark every hardcode with a trailing `// LOCAL DEBUG: <original expression>` comment so revert is a mechanical search.8081### Revert checklist — run all before committing82831. `git grep -n "LOCAL DEBUG" packages/dashboard/src/` returns zero matches.842. Each gate is restored to its **original expression**, not just an equivalent value (the `mode === 'cloud-hosting'` comparison, the hostname check, the `getFeatureFlag(...)` call must all be back).853. Any imports deleted during debug (commonly `DashboardPage`, `getFeatureFlag`, `ConnectDialog`) are restored.864. `cd packages/dashboard && npm run lint && npm run typecheck` both pass.875. `git diff` of the four files above shows only intended changes — no `return true;`, no missing imports.8889### Rationalizations to reject9091| Excuse | Reality |92|--------|---------|93| "I'll revert in a follow-up PR." | Follow-up = a window where prod is broken. Revert now. |94| "The original check was effectively the same." | If it were, you wouldn't have needed the hardcode. Restore the expression, not a value-equivalent. |95| "Lint passed, so the deleted import doesn't matter." | Lint passed because the import was deleted; on revert the original code needs it back. |96| "I'll ship the env-var override instead." | No env-var override is wired in the code. Don't invent one on the commit path — restore the original. |9798## Locale / language preference99100The dashboard has a language preference layer (selector + cloud sync) and101bundled react-i18next translations for the chrome, overview page, and Backend102Advisor (`lib/i18n/`, namespace `chrome`). Feature pages beyond those are103still English — extend the same namespace as they get translated.104105- `lib/contexts/LocaleContext.tsx` — `LocaleProvider` / `useLocale` /106 `SUPPORTED_LOCALES` / `normalizeLocale`. Resolution order: cloud account107 preference → `insforge-locale` localStorage → `navigator.language` → `en`.108 Mirrors the ThemeContext pattern.109- `components/LanguageSelect.tsx` — endonym-labelled selector; rendered in110 `AppHeader` (self-host) and the `AppSidebar` bottom in cloud-hosting mode111 (the header is hidden inside the iframe).112- Cloud sync contract (`@insforge/shared-schemas` cloud-events):113 parent → child `USER_INFO` carries optional `preferredLocale`;114 child → parent `UPDATE_PREFERRED_LOCALE { locale }` is fire-and-forget and115 the shell persists it to `users.preferred_locale` via the profile API116 (plumbed through the `onUpdatePreferredLocale` host prop).117- **Version-skew tolerance is a contract**: old shells ignore unknown message118 types; old dashboards ignore extra `USER_INFO` fields. Never make either119 side require the locale fields.120- Adding a language: extend `SUPPORTED_LOCALES` + `LOCALE_LABELS`, and keep121 the list aligned with the cloud marketing site's `src/i18n/routing.ts`122 (insforge-cloud repo) or the account preference will name a locale one123 surface can't render. Route locale-ish input through `normalizeLocale`.124- Self-host mode must work with zero cloud callbacks (localStorage only);125 extend `lib/contexts/__tests__/LocaleContext.test.tsx` when touching this.126- Every key added to `lib/i18n/locales/en.json` must exist in all four locale127 files — `lib/i18n/__tests__/localeParity.test.ts` fails CI otherwise128 (plural suffixes normalized; zh carries only `_other`).129- Never translate user-generated names (tables, buckets) — only static ids.130 See the note in `components/FeatureSidebar.tsx`.131132## Validation133134- `cd packages/dashboard && npm run test:unit` when changing pure helpers or reducers135- `cd packages/dashboard && npm run test:component` when changing React component behavior136- `cd packages/dashboard && npm run test:ui` when changing routing, auth, host-mode integration, or browser-only behavior137- `cd packages/dashboard && npm run typecheck`138- `cd packages/dashboard && npm run build`139- `cd frontend && npm run build` when the local self-hosting shell changes140141For shared contract changes, also validate `packages/shared-schemas/` and the affected backend surface.