Files
moteva/task_plan.md
T
2026-07-10 22:19:28 +08:00

3.8 KiB

Task Plan: Server-Backed Brand Kit Canvas Context

Goal

Persist Brand Kits by authenticated user, bind one optional Brand Kit to each project/canvas, expose a canvas-header selector, and make every Agent Chat turn and newly created thread use the selected kit as authoritative creative context.

Current Phase

Phase 5

Phases

Phase 1: Architecture Discovery

  • Map Brand Kit frontend state, project persistence, chat/thread creation, and generation context flow
  • Confirm API generation, storage-driver, schema, and test patterns
  • Status: complete

Phase 2: API and Domain Design

  • Update the .api contract before generated code
  • Define user-owned Brand Kit storage and project binding invariants
  • Define server-side prompt injection behavior for all project chat sessions
  • Status: complete

Phase 3: Backend Implementation

  • Generate handlers/types from the validated API specification
  • Implement memory and PostgreSQL Brand Kit persistence keyed by user ID
  • Persist and expose project brandKitId
  • Inject selected Brand Kit into Agent Chat and new-thread context
  • Add backend tests and API documentation
  • Status: complete

Phase 4: Frontend Integration

  • Replace local-only Brand Kit persistence with authenticated API persistence
  • Add canvas-title Brand Kit selector with None and user-owned kits
  • Add a Brand Kit selector to the Home prompt composer, including an empty create action
  • Keep Brand Kit editor, defaults, and project binding synchronized
  • Status: complete

Phase 5: Verification

  • Run API validation, generation checks, Go tests/build, frontend typecheck/build
  • Verify CRUD, user isolation, project binding, chat context, and selector behavior
  • Inspect desktop and mobile browser layouts
  • Status: in_progress

Phase 6: Delivery

  • Review scope, generated files, and prohibited product references
  • Provide preview URL and concise implementation notes
  • Status: pending

Invariants

  • Brand Kits are owned and queried only through the authenticated user ID from request context.
  • A project may reference zero or one Brand Kit owned by the same user.
  • Selecting None clears the binding without deleting the Brand Kit.
  • Server-side Agent Chat context is derived from the persisted project binding, never trusted from a client-supplied prompt.
  • Home may request a Brand Kit ID only from the authenticated user's list; the server revalidates ownership before binding it.
  • Deleting a Brand Kit clears project bindings to it.

Errors Encountered

Error Attempt Resolution
zsh rejected an unmatched HomePage/*.css glob 1 Replaced the glob with explicit files discovered via rg --files.
Assumed CanvasWorkspace/index.css, which does not exist 1 Locate the workspace stylesheet from its imports before reading it.
rg treated a pattern beginning with -- name: as a flag 1 Use rg -- <pattern> when searching SQLC query annotations.
Assumed AuthProvider.tsx instead of the component directory entry 1 Locate the file with rg --files before any further auth-provider reads.
PostgreSQL package test failed after adding project mapping because text conversion helpers were not yet defined 1 Add nullable pgtype.Text conversion helpers and rerun the package tests.
One patch to remove a temporary err = nil line used the wrong surrounding field name 1 Reapplied the patch against the exact current lines; no code change was lost.
Workspace import patch assumed a nonexistent BrandMark import 1 Located the actual import block and applied the selector change against current source.
First i18n patch used an inexact Chinese source string 1 Re-read the locale file and patched the exact key/value context.