* Stream endpoint for execution processes (vibe-kanban c5144da6)
I want an endpoint that's similar to task stream in crates/server/src/routes/tasks.rs but contains execution processes.
The structure of the document should be:
```json
{
"execution_processes": {
[EXECUTION_PROCESS_ID]: {
... execution process fields
}
}
}
```
The endpoint should be at `/api/execution_processes/stream?task_attempt_id=...`
crates/server/src/routes/execution_processes.rs
* add virtualizedlist component
* WIP remove execution processes
* rebase syntax fix
* tmp fix lint
* lint
* VirtuosoMessageList
* cache
* event based hook
* historic
* handle failed historic
* running processes
* user message
* loading
* cleanup
* render user message
* style
* fmt
* better indication for setup/cleanup scripts
* fix ref issue
* virtuoso license
* fmt
* update loader
* loading
* fmt
* loading improvements
* copy as markdown styles
* spacing improvement
* flush all historic at once
* padding fix
* markdown copy sticky
* make user message editable
* edit message
* reset
* cleanup
* hook order
* remove dead code
59 lines
1.4 KiB
TypeScript
59 lines
1.4 KiB
TypeScript
// useNormalizedLogs.ts
|
|
import { useCallback, useMemo } from 'react';
|
|
import { useJsonPatchStream } from './useJsonPatchStream';
|
|
import { NormalizedEntry } from 'shared/types';
|
|
|
|
type EntryType = { type: string };
|
|
|
|
export interface NormalizedEntryContent {
|
|
timestamp: string | null;
|
|
entry_type: EntryType;
|
|
content: string;
|
|
metadata: Record<string, unknown> | null;
|
|
}
|
|
|
|
export interface NormalizedLogsState {
|
|
entries: NormalizedEntry[];
|
|
session_id: string | null;
|
|
executor_type: string;
|
|
prompt: string | null;
|
|
summary: string | null;
|
|
}
|
|
|
|
interface UseNormalizedLogsResult {
|
|
entries: NormalizedEntry[];
|
|
state: NormalizedLogsState | undefined;
|
|
isLoading: boolean;
|
|
isConnected: boolean;
|
|
error: string | null;
|
|
}
|
|
|
|
export const useNormalizedLogs = (
|
|
processId: string,
|
|
enabled: boolean = true
|
|
): UseNormalizedLogsResult => {
|
|
const endpoint = `/api/execution-processes/${encodeURIComponent(processId)}/normalized-logs`;
|
|
|
|
const initialData = useCallback<() => NormalizedLogsState>(
|
|
() => ({
|
|
entries: [],
|
|
session_id: null,
|
|
executor_type: '',
|
|
prompt: null,
|
|
summary: null,
|
|
}),
|
|
[]
|
|
);
|
|
|
|
const { data, isConnected, error } = useJsonPatchStream<NormalizedLogsState>(
|
|
endpoint,
|
|
Boolean(processId) && enabled,
|
|
initialData
|
|
);
|
|
|
|
const entries = useMemo(() => data?.entries ?? [], [data?.entries]);
|
|
const isLoading = !data && !error;
|
|
|
|
return { entries, state: data, isLoading, isConnected, error };
|
|
};
|