Skip to content
Shell
6.1 KB
Raw Blame

Plan Mode UI Implementation

Overview

Add "Plan Mode" to the chat interface - a toggle that changes AI reasoning to be "zoomed out" for big-picture planning. Triggered by Shift+Tab, shows visual indicator in chat.

Requirements

  • Trigger: Shift+Tab toggles Plan Mode on/off
  • Close: Escape also closes Plan Mode
  • Visual: Cyan glow/badge in chat header and input border
  • AI Behavior: (Phase 2) Injects planning-focused system prompt
  • Scope: UI-first implementation, backend/AI changes later

Execution Strategy

Agent Assignments

Task Agent/Tool Role
Step 1: UI Store Changes fullstack-developer Add state and actions to Zustand store
Step 2: ChatHeader Badge frontend-developer Add visual badge component
Step 3: ChatInput Glow frontend-developer Add conditional border styling
Step 4: Integration fullstack-developer Connect keyboard handlers and props
Verification code-reviewer Review all changes for quality
TypeScript Check Bash npm run type-check Verify no type errors
Build Check Bash npm run build Verify build passes

Orchestration Flow

Claude (Orchestrator)
├── Launch: fullstack-developer → Step 1 (UI Store)
├── Wait for completion, verify, fix errors
├── Launch: frontend-developer → Steps 2+3 (UI Components) [parallel]
├── Wait for completion, verify, fix errors
├── Launch: fullstack-developer → Step 4 (Integration)
├── Wait for completion, verify, fix errors
├── Run: npm run type-check && npm run build
├── Launch: code-reviewer → Final review
└── Create PR via /git-workflow:feature

### Quality Gates
- [ ] TypeScript passes after each step
- [ ] Build passes before PR
- [ ] Code reviewer approves changes

Implementation Steps

Step 1: Add Plan Mode State to UI Store

File: src/stores/ui-state-store.ts

Add to UIState interface (around line 100):

isPlanMode: boolean;

Add to store actions:

togglePlanMode: () => void;
setPlanMode: (active: boolean) => void;

Add to initial state:

isPlanMode: false,

Add action implementations:

togglePlanMode: () => {
  set((state) => {
    state.isPlanMode = !state.isPlanMode;
  });
},
setPlanMode: (active) => {
  set((state) => {
    state.isPlanMode = active;
  });
},

Step 2: Update ChatHeader with Plan Mode Badge

File: src/components/chat/ChatHeader.tsx

Add prop:

export interface ChatHeaderProps {
  // ... existing props
  isPlanMode?: boolean;
}

Add visual badge after personality (around line 81):

{isPlanMode && (
  <span className="text-xs text-cyan-400 bg-cyan-400/10 px-2 py-0.5 rounded-full border border-cyan-400/30 flex items-center gap-1 ml-2">
    <span className="w-1.5 h-1.5 rounded-full bg-cyan-400 animate-pulse" />
    Plan Mode
  </span>
)}

Step 3: Update ChatInput with Glow Border

File: src/components/chat/ChatInput.tsx

Add prop:

interface ChatInputProps {
  // ... existing props
  isPlanMode?: boolean;
}

Add conditional border styling:

className={cn(
  // ... existing classes
  isPlanMode && "ring-2 ring-cyan-400/50 shadow-[0_0_12px_rgba(34,211,238,0.3)]"
)}

Step 4: Connect Everything in UnifiedChatInterface

File: src/components/chat/UnifiedChatInterface.tsx

Import store:

import { useUIStore } from '@/stores/ui-state-store';

Get state and actions:

const isPlanMode = useUIStore((state) => state.isPlanMode);
const togglePlanMode = useUIStore((state) => state.togglePlanMode);
const setPlanMode = useUIStore((state) => state.setPlanMode);

Add keyboard handler (in useEffect):

useEffect(() => {
  const handleKeyDown = (e: KeyboardEvent) => {
    // Shift+Tab toggles Plan Mode
    if (e.key === 'Tab' && e.shiftKey) {
      e.preventDefault();
      togglePlanMode();
    }
    // Escape closes Plan Mode (if active)
    if (e.key === 'Escape' && isPlanMode) {
      e.preventDefault();
      setPlanMode(false);
    }
  };

  window.addEventListener('keydown', handleKeyDown);
  return () => window.removeEventListener('keydown', handleKeyDown);
}, [isPlanMode, togglePlanMode, setPlanMode]);

Pass prop to ChatHeader:

<ChatHeader
  // ... existing props
  isPlanMode={isPlanMode}
/>

Pass prop to ChatInput:

<ChatInput
  // ... existing props
  isPlanMode={isPlanMode}
/>

Files to Modify

File Changes
src/stores/ui-state-store.ts Add isPlanMode, togglePlanMode(), setPlanMode()
src/components/chat/ChatHeader.tsx Add isPlanMode prop and cyan badge
src/components/chat/ChatInput.tsx Add isPlanMode prop and glow border
src/components/chat/UnifiedChatInterface.tsx Connect store, keyboard handlers, pass props

Visual Design

Plan Mode Badge (ChatHeader)

  • Color: Cyan (text-cyan-400, bg-cyan-400/10, border-cyan-400/30)
  • Pulsing dot indicator
  • Positioned after personality name

Input Glow (ChatInput)

  • Ring: ring-2 ring-cyan-400/50
  • Shadow: shadow-[0_0_12px_rgba(34,211,238,0.3)]

Phase 2 (Future): AI Integration

File: src/app/api/ai/chat/stream/route.ts

In buildEnhancedSystemPrompt(), append when Plan Mode active:

if (isPlanMode) {
  enhancedPrompt += `\n\n## PLAN MODE ACTIVE ##
You are in PLAN MODE. In this mode:
- Think at a HIGH LEVEL - focus on structure, outlines, and big picture
- DO NOT write detailed prose or final copy
- Provide BULLET POINTS, numbered lists, and structural frameworks
- Ask clarifying questions about scope and direction
- Focus on: Story arcs, character journeys, episode structures, act breaks
- Avoid: Detailed dialogue, scene descriptions, final drafts`;
}

Testing Checklist

  • Shift+Tab toggles Plan Mode on/off
  • Escape closes Plan Mode when active
  • Cyan badge appears in ChatHeader when Plan Mode active
  • Cyan glow appears on ChatInput when Plan Mode active
  • Visual indicators disappear when Plan Mode closes
  • Plan Mode state persists across component re-renders