- Extract theme constants (THEMES, THEME_CLASSES, DARK_SURFACES) into a new
framework-free lib/themes.ts so server and client code share one source of
truth; re-export from theme-provider for backward compatibility.
- Add nullable `theme` column to Project (Prisma migration + schema), plus
ProjectThemeSchema validation and a setProjectTheme server action.
- Introduce a ThemeScope context in the provider: a subtree can temporarily
override the global preference via useThemeScope().setScope(name); the
scoped theme wins for resolvedTheme/DOM while active, then lifts on cleanup.
- Render an inline no-FOUC script (themeSwitchScript) on project pages that
applies the theme class before first paint and leaves a data-project-theme
marker the provider reads at hydration.
- Add ProjectThemeScope component that sets/clears the scope from live
ProjectsContext state, so picking a new theme updates instantly without
waiting for the server re-render.
- Add ProjectThemePicker dropdown (Default + light/dark options) rendered
beside the project title in the kanban board header.
- Wire optimistic setProjectTheme into ProjectsContext with rollback and
error toast on failure.
- Update use-dark-theme hooks to read resolvedTheme from context instead of
resolving locally, so they reflect scoped themes correctly.
## Conversation Overview
A single user message. The user pasted a large, partially garbled/mangled unified diff of changes to a **Next.js self‑hosted board/to‑do web app** and asked the assistant to *"Generate a concise and descriptive git commit message for the selected code changes. The message should summarize the changes made, their purpose, and any relevant context. Do not edit any files, just provide the commit message as output."* No assistant reply has been produced yet.
## Subject of the Diff (what the changes do)
The diff introduces two related **AI features** plus shared AI plumbing:
1. **Per‑group "Status Update" feature**
- New `components/board/status-update-dialog.tsx` — a dialog that generates a group status update, supports a follow‑up chat list (`ChatMessageList`, `MarkdownPreview`), copy‑to‑clipboard, and calls `converseAboutGroupStatus(group.id, next)`.
- `components/board/group-card.tsx` (modified) — imports `ClipboardList` + `StatusUpdateDialog`, adds `statusUpdateOpen` state, and a **"Status Update"** dropdown item gated on `aiConfigured`.
- New `lib/actions/group-status-ai.ts` (`"use server"`) — backing server action(s) incl. `converseAboutGroupStatus`.
2. **"Global Chat" feature**
- New `lib/actions/global-chat.ts` (`"use server"`) — `sendChatMessage(messages: ChatMessage[])`: free‑form Q&A across every board the user owns (Home + all Projects). Re‑fetches/re‑serializes context each turn; uses `requireUserId()`, `getAllGroupsForUser()`, `formatAllGroupsForPrompt()`, and a shared `callChatCompletion` helper. Includes a `SYSTEM_PROMPT_HEADER` instructing the model to answer only from provided context.
3. **Shared AI context/formatting layer**
- New `lib/ai/context.ts` (`server-only`) — `formatAllGroupsForPrompt`, truncation with hard caps: `NOTE_CHAR_CAP=4,000`, `DETAILS_CHAR_CAP=300`, `TOTAL_CHAR_CAP=60,000`. Comment notes single‑user scale (no RAG; whole dataset goes into the prompt, capped by these limits).
- New `types/ai.ts` — `AiGroupContext` interface (group + scope label + category + archived flag + todos). **Deliberately includes archived groups** so historical questions are answerable.
- `lib/board.ts` (modified) — new `getAllGroupsForUser(userId)` using one Prisma query with `categoryAccessFilter`, flattening all categories/groups/todos (unlike `getBoard`, it does **not** filter archived groups).
## Key Technical Details
- Stack: Next.js, React, Tailwind, shadcn‑style UI (Dialog/Button), `MarkdownPreview`/`ChatMessageList`.
- `"use server"` server actions; `"server-only"` context module; Prisma ORM; `requireUserId()` auth; `categoryAccessFilter` access control.
- A shared `callChatCompletion` helper is referenced (handles provider errors, 401/403 API‑key rejection, empty/invalid JSON responses) — its full definition is not cleanly visible in the pasted diff.
- The pasted diff/file contents contain visible corruption (broken lines, garbled characters), but the feature intent is clearly discernible.
## User Request (deliverable)
Produce **only** a concise, descriptive git commit message (no file edits). The expected message should summarize: adding per‑group AI "Status Update" + a global cross‑board "Chat", along with shared AI context formatting (`lib/ai/context.ts`, `types/ai.ts`, `getAllGroupsForUser`) and new server actions (`global-chat.ts`, `group-status-ai.ts`). A representative phrasing would be something like: *"Add AI status updates per group and a global chat across all boards, backed by shared AI context formatting."*
## Current State / Next Steps
- No assistant response exists yet.
- Next step is to emit the commit message as plain text output (no code/file changes).
- Scheduled to-dos: new ScheduledTodo + ScheduledTodoCompletion models
(owner-XOR-project ownership like Category, per-occurrence completion
so a recurring to-do tracks done state per calendar date), recurrence
built server-side from validated parts via rrule-utils, CRUD +
occurrence-toggle server actions, add/edit dialog, and a collapsible
Scheduled side panel (overdue / today / upcoming) with UTC-safe
date-key formatting.
- AI to-dos: group-level AI dialog (lib/actions/todo-ai.ts) that chats
then proposes a finalize list of to-dos; editable proposals and bulk
add via BoardProvider.addTodos; speech recognition gains better error
handling (network/firewall message, error logging).
- Building upgrades: new `upgradesFrom` rule — Nuclear Power Plant can
replace a friendly Energy Generator and Advanced Metal Generator a
Mass Generator (same tile + footprint, per TALogic.findUpgradeTarget),
crediting a 50% refund of the replaced building's OWN cost;
compileRules validates the references, topperFrame gets a generic
spinning-glyph fallback in TAArt.
- Movement rework: pushOutOfObstacles replaces the hard tile-snap with a
damped circle-vs-tile overlap push, and pathfinding routes at exact-fit
clearance instead of +1 padding (fixes corner grinding/stalling).
- New map m06 "Annihilation" (medium, snowfields, Klaxon skill 5, seed
90123 — pre-vetted for early-economy balance).
- Tests: upgrade placement (ownership, type match, exact footprint,
refund, army-less fallback), obstacle routing/settling, corridor
moves; sprites.md updated for upgradesFrom and toppers.
- Add `AiSettingsCard` component and server actions for configuring an
OpenAI-compatible AI endpoint (e.g. OpenWebUI) from the admin panel
- Introduce `AiSettings` Prisma model with masked API key display and
connection testing UI
- Track `completedAt` on todos with a migration and backfill for existing
completed items
- Surface `createdAt`, `updatedAt`, and `completedAt` in the todo edit
dialog via a new `formatDateTime` utility
- Update `TodoDTO`, `getBoard`, `createTodo`, `toggleTodo`, and the board
context to carry and optimistically update timestamp fields
- Add `Select` UI component built on `@base-ui/react`
- Add Project model with owner-based access and cascade delete
- Restructure Category to belong to either Home (userId) or a Project (projectId), enforced by DB constraints and access filters
- Scope all board operations (create, update, delete, reorder) to the correct board context using `categoryAccessFilter` and `projectAccessFilter`
- Replace hardcoded `revalidatePath("/")` with dynamic `boardPath()` for proper cache invalidation
- Add `ProjectsProvider` and `ProjectsNavSection` for project sidebar navigation
- Make KanbanBoard accept `projectId` and `title` props to render Home or Project boards
- Extract `getBoard()` utility to centralize board data fetching
- Refactor group/todo/notes actions to derive board context from category membership rather than trusting caller input