chat: rename usePiChat → useChat, PiMonoInner → AgenticTaskRunner

Frontend de-Pi (Stage 3). Renames the chat hook usePiChat → useChat (+ UsePiChatType
→ UseChatType, file moved to hooks/useChat.ts) across all consumers, and renames
the TaskRunnerModal agentic runner PiMonoInner → AgenticTaskRunner (dropping the
dead defaultProvider === 'pi' check → always the Claude default). Pure rename, no
behavior change. The WS route stays /api/pi/chat/ws until Stage 4.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-24 14:57:34 +00:00
co-authored by Claude Opus 4.8
parent 260d201731
commit 2e3c45ddfb
11 changed files with 28 additions and 28 deletions
@@ -9,7 +9,7 @@ import { Button } from '@/components/ui/button';
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from '@/components/ui/dialog'; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from '@/components/ui/dialog';
import { useClient } from 'hooks/useClient'; import { useClient } from 'hooks/useClient';
import { Card } from '@/components/Card'; import { Card } from '@/components/Card';
import { usePiChat, EmbeddableChat } from 'officerdev'; import { useChat, EmbeddableChat } from 'officerdev';
type CapabilitySummary = { type CapabilitySummary = {
dirName: string; dirName: string;
name: string; name: string;
@@ -279,7 +279,7 @@ export const CapabilityChat = ({
? (description ?? `Help me create the content for this new ${kind} file`) ? (description ?? `Help me create the content for this new ${kind} file`)
: `Help me understand and improve this ${kind} file`; : `Help me understand and improve this ${kind} file`;
const pi = usePiChat(undefined, undefined, { replaceUrl: false }); const pi = useChat(undefined, undefined, { replaceUrl: false });
const onResponseEndRef = useRef(onResponseEnd); const onResponseEndRef = useRef(onResponseEnd);
onResponseEndRef.current = onResponseEnd; onResponseEndRef.current = onResponseEnd;
@@ -20,12 +20,12 @@ import { useClient } from 'hooks/useClient';
const DEBOUNCE_MS = 1000; const DEBOUNCE_MS = 1000;
export function usePiChat(sessionId?: string, model?: string | null) { export function useChat(sessionId?: string, model?: string | null) {
// ... // ...
return { messages, sendPrompt, stopGeneration }; return { messages, sendPrompt, stopGeneration };
} }
export type UsePiChatType = ReturnType<typeof usePiChat>; export type UseChatType = ReturnType<typeof useChat>;
// ── Types ── // ── Types ──
@@ -46,7 +46,7 @@ Hooks that are self-contained (one function, a few types, maybe some helpers) st
``` ```
hooks/ hooks/
├── useFilesAPI.ts ├── useFilesAPI.ts
├── usePiChat.ts ├── useChat.ts
└── index.ts └── index.ts
``` ```
@@ -113,7 +113,7 @@ The root `hooks/index.ts` re-exports everything. Each entry is a single `export
export * from './appRegistry'; export * from './appRegistry';
export * from './useFilesAPI'; export * from './useFilesAPI';
export * from './useFileViewerPanels'; export * from './useFileViewerPanels';
export * from './usePiChat'; export * from './useChat';
``` ```
When adding a new hook, add one line here. Order alphabetically. When adding a new hook, add one line here. Order alphabetically.
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
import { useWorkspace } from '../../components/Workspace'; import { useWorkspace } from '../../components/Workspace';
import { usePanelChannel } from 'hooks/usePanelChannel'; import { usePanelChannel } from 'hooks/usePanelChannel';
import { useSavedSessions, messagesToTranscript, type RawMessage } from 'state/useSavedSessions'; import { useSavedSessions, messagesToTranscript, type RawMessage } from 'state/useSavedSessions';
import { usePiChat } from '../../hooks/usePiChat'; import { useChat } from '../../hooks/useChat';
import { EmbeddableChat } from './EmbeddableChat'; import { EmbeddableChat } from './EmbeddableChat';
import type { ChatSessionSelection } from './ChatHeader'; import type { ChatSessionSelection } from './ChatHeader';
@@ -56,7 +56,7 @@ const ChatPanelInner = ({
[onTurnComplete, updateSessionMessages], [onTurnComplete, updateSessionMessages],
); );
const chat = usePiChat(sessionId, model, { const chat = useChat(sessionId, model, {
replaceUrl: false, replaceUrl: false,
projectScoped: scoped, projectScoped: scoped,
onTurnComplete: handleTurnComplete, onTurnComplete: handleTurnComplete,
@@ -1,4 +1,4 @@
import type { UsePiChatType } from '../../../hooks/usePiChat'; import type { UseChatType } from '../../../hooks/useChat';
import { useEmbeddableChat } from './useEmbeddableChat'; import { useEmbeddableChat } from './useEmbeddableChat';
import { MessageList } from '../components/MessageList'; import { MessageList } from '../components/MessageList';
import { InputArea } from '../components/InputArea'; import { InputArea } from '../components/InputArea';
@@ -19,7 +19,7 @@ type EmbeddableChatProps = {
sandboxed?: boolean; sandboxed?: boolean;
replaceUrl?: boolean; replaceUrl?: boolean;
autoSend?: boolean; autoSend?: boolean;
chat?: UsePiChatType; chat?: UseChatType;
context?: string; context?: string;
contextId?: string; contextId?: string;
onMessageComplete?: () => void; onMessageComplete?: () => void;
@@ -1,7 +1,7 @@
import type { KeyboardEvent } from 'react'; import type { KeyboardEvent } from 'react';
import { useState, useRef, useEffect } from 'react'; import { useState, useRef, useEffect } from 'react';
import { useUserVisibleModels } from 'state/useModels'; import { useUserVisibleModels } from 'state/useModels';
import { usePiChat, type UsePiChatType } from '../../../hooks/usePiChat'; import { useChat, type UseChatType } from '../../../hooks/useChat';
import { useAttachments } from '../useAttachments'; import { useAttachments } from '../useAttachments';
import { useSlashCommands } from '../useSlashCommands'; import { useSlashCommands } from '../useSlashCommands';
@@ -20,7 +20,7 @@ type UseEmbeddableChatParams = {
sandboxed?: boolean; sandboxed?: boolean;
replaceUrl?: boolean; replaceUrl?: boolean;
autoSend?: boolean; autoSend?: boolean;
chat?: UsePiChatType; chat?: UseChatType;
context?: string; context?: string;
contextId?: string; contextId?: string;
}; };
@@ -28,7 +28,7 @@ type UseEmbeddableChatParams = {
export function useEmbeddableChat(params: UseEmbeddableChatParams, onMessageComplete?: () => void) { export function useEmbeddableChat(params: UseEmbeddableChatParams, onMessageComplete?: () => void) {
const { initialMessage, defaultInput = '', promptPrefix, cwd, sandboxed, autoSend = false, chat: externalChat } = params; const { initialMessage, defaultInput = '', promptPrefix, cwd, sandboxed, autoSend = false, chat: externalChat } = params;
const internalChat = usePiChat(params.sessionId, params.initialModel, { replaceUrl: params.replaceUrl ?? false, context: params.context, contextId: params.contextId }); const internalChat = useChat(params.sessionId, params.initialModel, { replaceUrl: params.replaceUrl ?? false, context: params.context, contextId: params.contextId });
const chat = externalChat ?? internalChat; const chat = externalChat ?? internalChat;
const { const {
@@ -14,7 +14,7 @@ export { AttachmentList } from './components/AttachmentList';
export { AttachButton } from './components/AttachButton'; export { AttachButton } from './components/AttachButton';
export { WebpageDialog } from './components/WebpageDialog'; export { WebpageDialog } from './components/WebpageDialog';
export { EmbeddableChat, type UseEmbeddableChatType } from './EmbeddableChat'; export { EmbeddableChat, type UseEmbeddableChatType } from './EmbeddableChat';
export { usePiChat, type UsePiChatType } from '../../hooks/usePiChat'; export { useChat, type UseChatType } from '../../hooks/useChat';
export { ChatList } from './ChatList'; export { ChatList } from './ChatList';
export { useSlashCommands } from './useSlashCommands'; export { useSlashCommands } from './useSlashCommands';
export { useAttachments, type UseAttachmentsType } from './useAttachments'; export { useAttachments, type UseAttachmentsType } from './useAttachments';
@@ -5,7 +5,7 @@ import { usePanelChannel } from 'hooks/usePanelChannel';
import { useAuth } from 'hooks/useAuth'; import { useAuth } from 'hooks/useAuth';
import { useSavedSessions } from 'state/useSavedSessions'; import { useSavedSessions } from 'state/useSavedSessions';
import { useClaudeSessions } from 'state/useClaudeSessions'; import { useClaudeSessions } from 'state/useClaudeSessions';
import { usePiChat, EmbeddableChat } from '../Chat'; import { useChat, EmbeddableChat } from '../Chat';
import type { ChatMessage } from '../Chat/types'; import type { ChatMessage } from '../Chat/types';
export type SelectedSession = { export type SelectedSession = {
@@ -113,7 +113,7 @@ function NewChat({ resumeSummary, resumeSessionId, initialMessages, savedId: ini
// context 'chat' tells the backend to run this session from the dedicated claude_sessions cwd, so // context 'chat' tells the backend to run this session from the dedicated claude_sessions cwd, so
// its transcript lands in Claude's own store as an isolated project group (source of truth). // its transcript lands in Claude's own store as an isolated project group (source of truth).
const chat = usePiChat(undefined, locationState?.model, { resumeSummary, resumeSessionId, initialMessages, onTurnComplete, context: 'chat' }); const chat = useChat(undefined, locationState?.model, { resumeSummary, resumeSessionId, initialMessages, onTurnComplete, context: 'chat' });
chatSessionRef.current = chat.sessionId; chatSessionRef.current = chat.sessionId;
const isSaved = savedId != null; const isSaved = savedId != null;
@@ -5,7 +5,7 @@ import { Dialog, DialogOverlay, DialogPortal } from '@/components/ui/dialog';
import * as DialogPrimitive from '@radix-ui/react-dialog'; import * as DialogPrimitive from '@radix-ui/react-dialog';
import { cardStyle } from '@/components/Card'; import { cardStyle } from '@/components/Card';
import type { TaskInfo, ChatMessage } from '../../../Chat'; import type { TaskInfo, ChatMessage } from '../../../Chat';
import { usePiChat, MessageBubble, StreamingBubble, ModelSelector } from '../../../Chat'; import { useChat, MessageBubble, StreamingBubble, ModelSelector } from '../../../Chat';
import { useSettings } from 'state/useSettings'; import { useSettings } from 'state/useSettings';
import { useUserVisibleModels } from 'state/useModels'; import { useUserVisibleModels } from 'state/useModels';
import { useClient } from 'hooks/useClient'; import { useClient } from 'hooks/useClient';
@@ -40,7 +40,7 @@ const playDing = () => {
type Phase = 'ready' | 'running' | 'done'; type Phase = 'ready' | 'running' | 'done';
type PiMonoInnerProps = { type AgenticTaskRunnerProps = {
taskDirName: string; taskDirName: string;
defaultInput: string; defaultInput: string;
cwd: { root?: string; path: string }; cwd: { root?: string; path: string };
@@ -50,9 +50,9 @@ type PiMonoInnerProps = {
context: Record<string, string>; context: Record<string, string>;
}; };
const PiMonoInner = ({ taskDirName, defaultInput, cwd, initialModel, taskInfo, sandboxed, context }: PiMonoInnerProps) => { const AgenticTaskRunner = ({ taskDirName, defaultInput, cwd, initialModel, taskInfo, sandboxed, context }: AgenticTaskRunnerProps) => {
const [phase, setPhase] = useState<Phase>('ready'); const [phase, setPhase] = useState<Phase>('ready');
const chat = usePiChat(undefined, initialModel, { replaceUrl: false, taskInfo }); const chat = useChat(undefined, initialModel, { replaceUrl: false, taskInfo });
const availableModels = useUserVisibleModels(); const availableModels = useUserVisibleModels();
const client = useClient(); const client = useClient();
const [inputDefs, setInputDefs] = useState<Record<string, TaskInputDef> | null>(null); const [inputDefs, setInputDefs] = useState<Record<string, TaskInputDef> | null>(null);
@@ -1513,12 +1513,12 @@ export const TaskRunnerModal = ({ open, onOpenChange, task, entryName, entryFull
onClose={() => onOpenChange(false)} onClose={() => onOpenChange(false)}
/> />
) : ( ) : (
<PiMonoInner <AgenticTaskRunner
key="pi" key="agentic"
taskDirName={task.dirName} taskDirName={task.dirName}
defaultInput={defaultInput} defaultInput={defaultInput}
cwd={entryType === 'directory' && entryName ? { ...cwd, path: cwd.path ? `${cwd.path}/${entryName}` : entryName } : cwd} cwd={entryType === 'directory' && entryName ? { ...cwd, path: cwd.path ? `${cwd.path}/${entryName}` : entryName } : cwd}
initialModel={taskSettings.defaultProvider === 'pi' ? taskSettings.defaultModel : null} initialModel={null}
taskInfo={taskInfo} taskInfo={taskInfo}
sandboxed={sandboxed} sandboxed={sandboxed}
context={autofillContext} context={autofillContext}
+1 -1
View File
@@ -1,4 +1,4 @@
export * from './useFilesAPI'; export * from './useFilesAPI';
export * from './useFileViewerPanels'; export * from './useFileViewerPanels';
export * from './usePiChat'; export * from './useChat';
export * from './useDock'; export * from './useDock';
@@ -25,7 +25,7 @@ type UsePiChatOptions = {
onTurnComplete?: (hadToolCalls: boolean) => void; onTurnComplete?: (hadToolCalls: boolean) => void;
}; };
export function usePiChat(initialSessionId?: string, initialModel?: string | null, options?: UsePiChatOptions) { export function useChat(initialSessionId?: string, initialModel?: string | null, options?: UsePiChatOptions) {
const { const {
replaceUrl = true, replaceUrl = true,
storage, storage,
@@ -366,4 +366,4 @@ export function usePiChat(initialSessionId?: string, initialModel?: string | nul
}; };
} }
export type UsePiChatType = ReturnType<typeof usePiChat>; export type UseChatType = ReturnType<typeof useChat>;
+2 -2
View File
@@ -16,13 +16,13 @@ export {
AttachButton, AttachButton,
WebpageDialog, WebpageDialog,
EmbeddableChat, EmbeddableChat,
usePiChat, useChat,
ChatList, ChatList,
useSlashCommands, useSlashCommands,
useAttachments, useAttachments,
useAudioRecording, useAudioRecording,
} from './apps/Chat'; } from './apps/Chat';
export type { UseEmbeddableChatType, UsePiChatType, UseAttachmentsType, UseAudioRecordingType } from './apps/Chat'; export type { UseEmbeddableChatType, UseChatType, UseAttachmentsType, UseAudioRecordingType } from './apps/Chat';
export * from './apps/Chat/types'; export * from './apps/Chat/types';
export { SessionBar, SessionList, ChatDetailPanel } from './apps/ChatHistory'; export { SessionBar, SessionList, ChatDetailPanel } from './apps/ChatHistory';
export type { SelectedSession } from './apps/ChatHistory'; export type { SelectedSession } from './apps/ChatHistory';