PRD-38.1: Widget-Ready Chatbot Workspace

Version: 1.0 Status: 🟡 Ready for Implementation Priority: HIGH Author: Automatos AI Platform Team Last Updated: 2026-01-27 Dependencies: PRD-31 (Chatbot UX), PRD-38.0 (Master Plan) Timeline: Weeks 1-3


Executive Summary

Transform the current chatbot interface from a modal-based artifact viewer into a canvas-based workspace where widgets (artifacts) persist, can be arranged, and remain accessible throughout the conversation. This phase establishes the widget architecture foundation that enables all future phases.

Before & After

CURRENT STATE                          TARGET STATE
─────────────────────────────────      ─────────────────────────────────
┌─────────┐ ┌──────────────────┐      ┌────────┐ ┌────────────────────┐
│ Sidebar │ │                  │      │        │ │                    │
│         │ │   Chat Area      │      │  Chat  │ │      Canvas        │
│ History │ │                  │      │  Panel │ │                    │
│         │ │   [Message]      │      │        │ │ ┌────┐ ┌────┐      │
│         │ │   [Message]      │      │ [Msgs] │ │ │Code│ │Data│      │
│         │ │   [Artifact      │      │        │ │ └────┘ └────┘      │
│         │ │    MODAL]        │      │        │ │ ┌─────────────┐    │
│         │ │                  │      │        │ │ │  Document   │    │
│         │ │   [Input]        │      │[Input] │ │ └─────────────┘    │
└─────────┘ └──────────────────┘      └────────┘ └────────────────────┘
                                      └─────────Widget Tray────────────┘

• Single artifact at a time          • Multiple widgets visible
• Modal overlay                      • Persistent canvas
• Lost on close                      • Saved in workspace
• No arrangement                     • Drag, resize, arrange

1) Goals & Success Metrics

Goals

ID
Goal
Description

G1

Widget Foundation

Create reusable widget architecture for all future phases

G2

Canvas Workspace

Replace modal artifact viewer with persistent canvas

G3

Multi-Widget

Support viewing multiple widgets simultaneously

G4

Tool Integration

Tool results automatically create widgets in canvas

G5

Zero Regression

Existing chat functionality must not break

Success Metrics

Metric
Target
Measurement

Widget render time

< 200ms

Performance profiling

Canvas with 10 widgets

60fps

Chrome DevTools FPS

Tool → Widget latency

< 500ms

Time from tool-end to widget visible

Existing tests passing

100%

CI pipeline

User can view 4+ widgets

Working

Manual QA


2) Current State Analysis

Existing Files to Modify

File
Lines
Current Purpose
Changes Needed

components/chatbot/chat.tsx

668

Main chat container

Add canvas, split layout

components/chatbot/message.tsx

602

Message rendering

Emit widgets to canvas instead of inline

components/chatbot/artifact-viewer.tsx

175

Modal artifact display

Transform to widget wrapper

components/chatbot/code-artifact.tsx

51

Code display

Move to widgets/CodeWidget

components/chatbot/text-artifact.tsx

278

Document display

Move to widgets/DocumentWidget

components/chatbot/sheet-artifact.tsx

302

Table display

Move to widgets/DataWidget

lib/chat/hooks.ts

~300

Chat state

Add widget event handling

Existing Files to Reuse As-Is

File
Purpose
Reuse Strategy

components/ui/*

Shadcn components

Use in widgets

components/chatbot/multimodal-input.tsx

Input handling

Keep unchanged

components/chatbot/model-selector.tsx

Model selection

Keep unchanged

components/chatbot/agent-selector.tsx

Agent selection

Keep unchanged

components/chatbot/sidebar.tsx

Chat history

Keep unchanged

Existing Patterns to Follow


3) Technical Architecture

3.1 Component Hierarchy

3.2 State Flow

3.3 Zustand Store Design


4) Implementation Plan

Week 1: Foundation

Task 1.1: Create Widget Types & Registry

Files to Create:

types.ts:

registry.ts:

router.ts:

Task 1.2: Create Zustand Store

File to Create:

Full implementation as shown in section 3.3 above.

Install Zustand:

Task 1.3: Create WidgetBase Component

Files to Create:

WidgetBase.tsx:

WidgetWrapper.tsx:


Week 2: Migrate Existing Artifacts

Task 2.1: Create CodeWidget (from code-artifact.tsx)

Files:

  • DELETE after migration: components/chatbot/code-artifact.tsx

  • CREATE: components/widgets/CodeWidget/index.tsx

Task 2.2: Create DataWidget (from sheet-artifact.tsx)

Files:

  • DELETE after migration: components/chatbot/sheet-artifact.tsx

  • CREATE: components/widgets/DataWidget/index.tsx

Task 2.3: Create DocumentWidget (from text-artifact.tsx)

Files:

  • DELETE after migration: components/chatbot/text-artifact.tsx

  • CREATE: components/widgets/DocumentWidget/index.tsx

Task 2.4: Create ImageWidget

File: components/widgets/ImageWidget/index.tsx


Week 3: Canvas & Integration

Task 3.1: Create Canvas Component

Install dependencies:

File: components/workspace/Canvas.tsx

Task 3.2: Create WidgetTray Component

File: components/workspace/WidgetTray.tsx

Task 3.3: Modify Chat Component

File to Modify: components/chatbot/chat.tsx

Key changes:

  1. Import workspace store

  2. Replace artifact viewer modal with canvas

  3. Add workspace container layout

Task 3.4: Modify Message Component

File to Modify: components/chatbot/message.tsx

Key changes:

  1. Instead of inline artifacts, emit to workspace store

  2. Show small "widget created" indicators

Task 3.5: Update useChat Hook

File to Modify: lib/chat/hooks.ts

Add widget event handling for tool-data events:


5) Files Summary

Files to CREATE

File
Purpose

frontend/components/widgets/types.ts

Type definitions

frontend/components/widgets/registry.ts

Widget registration

frontend/components/widgets/router.ts

Tool → Widget routing

frontend/components/widgets/WidgetBase.tsx

Base component

frontend/components/widgets/WidgetWrapper.tsx

Widget container

frontend/components/widgets/CodeWidget/index.tsx

Code display

frontend/components/widgets/DataWidget/index.tsx

Data tables/charts

frontend/components/widgets/DocumentWidget/index.tsx

Documents/RAG

frontend/components/widgets/ImageWidget/index.tsx

Images

frontend/components/workspace/Canvas.tsx

Canvas layout

frontend/components/workspace/WidgetTray.tsx

Widget tray

frontend/stores/workspace-store.ts

Zustand store

Files to MODIFY

File
Changes

frontend/components/chatbot/chat.tsx

Add canvas layout, remove artifact modal

frontend/components/chatbot/message.tsx

Emit to workspace, show widget indicators

frontend/lib/chat/hooks.ts

Add widget event handling

Files to DELETE (after migration)

File
Reason

frontend/components/chatbot/code-artifact.tsx

Moved to CodeWidget

frontend/components/chatbot/text-artifact.tsx

Moved to DocumentWidget

frontend/components/chatbot/sheet-artifact.tsx

Moved to DataWidget

frontend/components/chatbot/artifact-viewer.tsx

Replaced by Canvas


6) Dependencies to Install


7) Testing Checklist

Unit Tests

Integration Tests

E2E Tests

Performance Tests


8) Rollout Plan

Week 1: Foundation (Dev Environment)

  • Create all widget types and registry

  • Create workspace store

  • Create widget base components

Week 2: Migration (Dev Environment)

  • Create all 4 widget components

  • Test each widget independently

  • Ensure feature parity with existing artifacts

Week 3: Integration (Staging)

  • Create Canvas and WidgetTray

  • Modify chat.tsx and message.tsx

  • Integration testing

  • Performance testing

Week 4: Rollout (Production)

  • Feature flag for gradual rollout

  • Monitor performance and errors

  • Collect user feedback

  • Delete deprecated files


9) Open Questions (Resolved)

The following architectural decisions are required before Phase 2 can start:

9.1 Widget Persistence in Zustand Store

Decision: YES - widgets persist across browser sessions via useWorkspaceStore.

Implementation:

  • The Zustand store already uses persist() middleware (see Section 3.3)

  • Widget data stored in localStorage under key automatos-workspace

  • Partialize strategy: persist widgets, widgetIds, positions, sizes, layoutMode

  • Session-specific state (like isLoading) is NOT persisted

9.2 Widget Reference Syntax

Decision: Use @widget-<short-id> pattern with the following rules:

Syntax Rules:

Parsing Implementation:

Scope: References are resolved within the current workspace/conversation context.

9.3 Mobile Layout Strategy

Decision: Use responsive breakpoints with simplified layout on mobile.

Strategy:

  • Desktop (≥1024px): Full React Grid Layout with drag-drop

  • Tablet (768-1023px): Simplified 2-column grid, drag-drop disabled

  • Mobile (<768px): Single-column stack with swipeable widget cards

Implementation:

Rationale: React Grid Layout is not mobile-friendly due to drag-drop interaction patterns. A swipeable card stack provides better UX on touch devices.

Alternative Considered: Using a modal/drawer pattern on mobile. Rejected because it breaks the multi-widget visibility goal.


9.4) Phase 1.5: Architecture Decisions Checklist

Before Phase 2 can start, the following must be verified:

Decision
Status
Verified By
Date

Widget persistence works in Zustand store

☐ Pending

QA Test

-

Widget reference syntax parser implemented

☐ Pending

Code Review

-

Mobile layout renders correctly on iOS/Android

☐ Pending

Device Test

-

No data loss on page refresh with 10+ widgets

☐ Pending

QA Test

-

Widget references resolve in chat input

☐ Pending

Integration Test

-

Acceptance Criteria:


10) References


Document Version: 1.0 Created: 2026-01-27 Estimated Implementation: 3 weeks

Last updated