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:
@@ -9,7 +9,7 @@ import { Button } from '@/components/ui/button';
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from '@/components/ui/dialog';
|
||||
import { useClient } from 'hooks/useClient';
|
||||
import { Card } from '@/components/Card';
|
||||
import { usePiChat, EmbeddableChat } from 'officerdev';
|
||||
import { useChat, EmbeddableChat } from 'officerdev';
|
||||
type CapabilitySummary = {
|
||||
dirName: string;
|
||||
name: string;
|
||||
@@ -279,7 +279,7 @@ export const CapabilityChat = ({
|
||||
? (description ?? `Help me create the content for this new ${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);
|
||||
onResponseEndRef.current = onResponseEnd;
|
||||
|
||||
@@ -20,12 +20,12 @@ import { useClient } from 'hooks/useClient';
|
||||
|
||||
const DEBOUNCE_MS = 1000;
|
||||
|
||||
export function usePiChat(sessionId?: string, model?: string | null) {
|
||||
export function useChat(sessionId?: string, model?: string | null) {
|
||||
// ...
|
||||
return { messages, sendPrompt, stopGeneration };
|
||||
}
|
||||
|
||||
export type UsePiChatType = ReturnType<typeof usePiChat>;
|
||||
export type UseChatType = ReturnType<typeof useChat>;
|
||||
|
||||
// ── Types ──
|
||||
|
||||
@@ -46,7 +46,7 @@ Hooks that are self-contained (one function, a few types, maybe some helpers) st
|
||||
```
|
||||
hooks/
|
||||
├── useFilesAPI.ts
|
||||
├── usePiChat.ts
|
||||
├── useChat.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 './useFilesAPI';
|
||||
export * from './useFileViewerPanels';
|
||||
export * from './usePiChat';
|
||||
export * from './useChat';
|
||||
```
|
||||
|
||||
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 { usePanelChannel } from 'hooks/usePanelChannel';
|
||||
import { useSavedSessions, messagesToTranscript, type RawMessage } from 'state/useSavedSessions';
|
||||
import { usePiChat } from '../../hooks/usePiChat';
|
||||
import { useChat } from '../../hooks/useChat';
|
||||
import { EmbeddableChat } from './EmbeddableChat';
|
||||
|
||||
import type { ChatSessionSelection } from './ChatHeader';
|
||||
@@ -56,7 +56,7 @@ const ChatPanelInner = ({
|
||||
[onTurnComplete, updateSessionMessages],
|
||||
);
|
||||
|
||||
const chat = usePiChat(sessionId, model, {
|
||||
const chat = useChat(sessionId, model, {
|
||||
replaceUrl: false,
|
||||
projectScoped: scoped,
|
||||
onTurnComplete: handleTurnComplete,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { UsePiChatType } from '../../../hooks/usePiChat';
|
||||
import type { UseChatType } from '../../../hooks/useChat';
|
||||
import { useEmbeddableChat } from './useEmbeddableChat';
|
||||
import { MessageList } from '../components/MessageList';
|
||||
import { InputArea } from '../components/InputArea';
|
||||
@@ -19,7 +19,7 @@ type EmbeddableChatProps = {
|
||||
sandboxed?: boolean;
|
||||
replaceUrl?: boolean;
|
||||
autoSend?: boolean;
|
||||
chat?: UsePiChatType;
|
||||
chat?: UseChatType;
|
||||
context?: string;
|
||||
contextId?: string;
|
||||
onMessageComplete?: () => void;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { KeyboardEvent } from 'react';
|
||||
import { useState, useRef, useEffect } from 'react';
|
||||
import { useUserVisibleModels } from 'state/useModels';
|
||||
import { usePiChat, type UsePiChatType } from '../../../hooks/usePiChat';
|
||||
import { useChat, type UseChatType } from '../../../hooks/useChat';
|
||||
import { useAttachments } from '../useAttachments';
|
||||
import { useSlashCommands } from '../useSlashCommands';
|
||||
|
||||
@@ -20,7 +20,7 @@ type UseEmbeddableChatParams = {
|
||||
sandboxed?: boolean;
|
||||
replaceUrl?: boolean;
|
||||
autoSend?: boolean;
|
||||
chat?: UsePiChatType;
|
||||
chat?: UseChatType;
|
||||
context?: string;
|
||||
contextId?: string;
|
||||
};
|
||||
@@ -28,7 +28,7 @@ type UseEmbeddableChatParams = {
|
||||
export function useEmbeddableChat(params: UseEmbeddableChatParams, onMessageComplete?: () => void) {
|
||||
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 {
|
||||
|
||||
@@ -14,7 +14,7 @@ export { AttachmentList } from './components/AttachmentList';
|
||||
export { AttachButton } from './components/AttachButton';
|
||||
export { WebpageDialog } from './components/WebpageDialog';
|
||||
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 { useSlashCommands } from './useSlashCommands';
|
||||
export { useAttachments, type UseAttachmentsType } from './useAttachments';
|
||||
|
||||
@@ -5,7 +5,7 @@ import { usePanelChannel } from 'hooks/usePanelChannel';
|
||||
import { useAuth } from 'hooks/useAuth';
|
||||
import { useSavedSessions } from 'state/useSavedSessions';
|
||||
import { useClaudeSessions } from 'state/useClaudeSessions';
|
||||
import { usePiChat, EmbeddableChat } from '../Chat';
|
||||
import { useChat, EmbeddableChat } from '../Chat';
|
||||
import type { ChatMessage } from '../Chat/types';
|
||||
|
||||
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
|
||||
// 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;
|
||||
|
||||
const isSaved = savedId != null;
|
||||
|
||||
+7
-7
@@ -5,7 +5,7 @@ import { Dialog, DialogOverlay, DialogPortal } from '@/components/ui/dialog';
|
||||
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
||||
import { cardStyle } from '@/components/Card';
|
||||
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 { useUserVisibleModels } from 'state/useModels';
|
||||
import { useClient } from 'hooks/useClient';
|
||||
@@ -40,7 +40,7 @@ const playDing = () => {
|
||||
|
||||
type Phase = 'ready' | 'running' | 'done';
|
||||
|
||||
type PiMonoInnerProps = {
|
||||
type AgenticTaskRunnerProps = {
|
||||
taskDirName: string;
|
||||
defaultInput: string;
|
||||
cwd: { root?: string; path: string };
|
||||
@@ -50,9 +50,9 @@ type PiMonoInnerProps = {
|
||||
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 chat = usePiChat(undefined, initialModel, { replaceUrl: false, taskInfo });
|
||||
const chat = useChat(undefined, initialModel, { replaceUrl: false, taskInfo });
|
||||
const availableModels = useUserVisibleModels();
|
||||
const client = useClient();
|
||||
const [inputDefs, setInputDefs] = useState<Record<string, TaskInputDef> | null>(null);
|
||||
@@ -1513,12 +1513,12 @@ export const TaskRunnerModal = ({ open, onOpenChange, task, entryName, entryFull
|
||||
onClose={() => onOpenChange(false)}
|
||||
/>
|
||||
) : (
|
||||
<PiMonoInner
|
||||
key="pi"
|
||||
<AgenticTaskRunner
|
||||
key="agentic"
|
||||
taskDirName={task.dirName}
|
||||
defaultInput={defaultInput}
|
||||
cwd={entryType === 'directory' && entryName ? { ...cwd, path: cwd.path ? `${cwd.path}/${entryName}` : entryName } : cwd}
|
||||
initialModel={taskSettings.defaultProvider === 'pi' ? taskSettings.defaultModel : null}
|
||||
initialModel={null}
|
||||
taskInfo={taskInfo}
|
||||
sandboxed={sandboxed}
|
||||
context={autofillContext}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export * from './useFilesAPI';
|
||||
export * from './useFileViewerPanels';
|
||||
export * from './usePiChat';
|
||||
export * from './useChat';
|
||||
export * from './useDock';
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ type UsePiChatOptions = {
|
||||
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 {
|
||||
replaceUrl = true,
|
||||
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>;
|
||||
@@ -16,13 +16,13 @@ export {
|
||||
AttachButton,
|
||||
WebpageDialog,
|
||||
EmbeddableChat,
|
||||
usePiChat,
|
||||
useChat,
|
||||
ChatList,
|
||||
useSlashCommands,
|
||||
useAttachments,
|
||||
useAudioRecording,
|
||||
} 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 { SessionBar, SessionList, ChatDetailPanel } from './apps/ChatHistory';
|
||||
export type { SelectedSession } from './apps/ChatHistory';
|
||||
|
||||
Reference in New Issue
Block a user