This keeps the testing branch aligned with the current Popi.TV interaction direction: generation is controlled from the selected node context, model/provider selection is simplified around the NewAPI gateway path, Popiai embedding can hydrate workflow state, and media nodes expose names plus dimensions in the canvas header.
Constraint: Testing branch needs the full current source state, not runtime logs or local browser artifacts
Rejected: Commit logs, browserfs state, and handoff bundles | they are local runtime artifacts rather than application source
Confidence: high
Scope-risk: moderate
Reversibility: clean
Directive: Keep model selection consolidated around the NewAPI gateway unless supplier-specific behavior is intentionally reintroduced
Tested: npm run test:run -- src/components/__tests__/FloatingNodeHeader.test.tsx src/components/__tests__/nodeHeaderMedia.test.ts src/components/__tests__/WorkflowCanvas.test.tsx
Tested: npm run test:run -- src/components/__tests__/ImageInputNode.test.tsx src/components/__tests__/GenerateVideoNode.test.tsx src/components/__tests__/GenerateImageNode.test.tsx
Tested: npm run build
Tested: git diff --check -- src
Not-tested: npm run lint | existing script uses next lint and resolves to nonexistent ./lint directory
The right-side assistant now uses the existing chat/tooling path as a docked canvas surface instead of a hidden floating experiment. It can prepare workflow edits, prepare run actions, and keep all mutations behind an explicit preview/apply step.
A shared chat node schema keeps the model prompt and local edit validator aligned with real node types, while the context builder strips broader media payloads before chat requests.
Constraint: Keep the deployed master/TEST-s version stable while this work proceeds on a feature branch
Constraint: No new dependencies and no broad canvas rewrite
Rejected: Directly applying model-suggested edits | local validation and preview remain the safety boundary
Rejected: Full multimodal image upload in the first pass | current implementation only exposes media metadata and failure state
Confidence: high
Scope-risk: moderate
Reversibility: clean
Directive: Add new AI-editable node fields through src/lib/chat/nodeSchema.ts before exposing them in prompts
Tested: npm run test:run -- src/lib/chat/contextBuilder.test.ts src/lib/chat/tools.test.ts src/lib/chat/editOperations.test.ts src/components/__tests__/ChatPanel.test.tsx src/components/__tests__/WorkflowCanvas.test.tsx src/app/api/chat/__tests__/route.test.ts
Tested: PROVIDER_MODE=popi NEXT_PUBLIC_PROVIDER_MODE=popi npm run build
Tested: Browser smoke on http://localhost:3000 verified docked assistant, close/reopen, selected-node focus, and run controls
Not-tested: Live LLM tool-call execution against the gateway
Create editOperations.ts with EditOperation type union covering all 5 operation types (addNode, removeNode, updateNode, addEdge, removeEdge). Implement applyEditOperations function with batched immutable updates, proper ID generation, and validation with skip tracking. Add narrateOperations function for human-readable summaries.
Create contextBuilder.ts with WorkflowContext interface and buildWorkflowContext function that strips base64 data, history arrays, and internal state. Add formatContextForPrompt function for system prompt injection.
Both modules are pure TypeScript with no UI or API dependencies.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>