Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/src/components/chat/ChatContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useHotkeys } from 'react-hotkeys-hook';
import { Loader2, FileCode, X, List, Plus, Plug, Pause } from 'lucide-react';
import { PencilSimple, Storefront } from '@phosphor-icons/react';
import { nodeConfigEvents } from '../../utils/nodeConfigEvents';
import { notifyFileMutationsFromAgentEvent } from '../../utils/agentFileEvents';
import { useCommandHandlers } from '../../contexts/CommandContext';
import { ChatMessage } from './ChatMessage';
import { ChatInput } from './ChatInput';
Expand Down Expand Up @@ -1315,6 +1316,8 @@ export function ChatContainer({
// Guard against state updates after unmount (orphaned SSE callbacks)
if (!isMountedRef.current) return;

notifyFileMutationsFromAgentEvent(event);

// Capture task ID from streaming events for cancellation/reconnection
if (event.data?.task_id) {
agentTaskIdRef.current = event.data.task_id as string;
Expand Down
2 changes: 2 additions & 0 deletions app/src/contexts/AgentRunsProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import type { ReactNode } from 'react';
import { chatApi } from '../lib/api';
import { notifyFileMutationsFromAgentEvent } from '../utils/agentFileEvents';
import {
AgentRunsContext,
type AgentRunsContextValue,
Expand Down Expand Up @@ -82,6 +83,7 @@ export function AgentRunsProvider({
latestEvent: payload,
lastEventId: lastEventId || undefined,
});
notifyFileMutationsFromAgentEvent(payload);
const type = (payload && (payload as { type?: string }).type) || '';
if (type === 'complete' || type === 'error') {
const reason =
Expand Down
7 changes: 6 additions & 1 deletion app/src/utils/fileEvents.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
// Custom event system for file changes
// This allows components to communicate file changes without polling the server

type FileEventType = 'file-created' | 'file-updated' | 'file-deleted' | 'files-changed';
type FileEventType =
| 'file-created'
| 'file-updated'
| 'file-deleted'
| 'files-changed'
| 'files-written';

interface FileEventDetail {
type: FileEventType;
Expand Down