Файли
openidea/src/features/agents/session/shared.ts
T
Mr0Bread a67b094e2c refactor(agents): split the session editor into per-component modules (#3760)
SessionEditor.tsx (about 3,500 lines) is split into modules under src/features/agents/session/: the status line, composer, stream, messages, tool entries, question form, changes pane, find bar, folds, process and working rows. The declarations move unchanged apart from their exports; SessionEditor.tsx keeps the task session shell. Changes main made to the session editor after the split was prepared (#3961, #4013, #4015) are carried into the modules that now hold that code.

Co-authored-by: Mr0Bread <[email protected]>
2026-11-18 09:54:52 +08:00

23 рядки
810 B
TypeScript

import type { AgentEntry, AgentTask } from "@/bindings";
import { useEffect, useState } from "react";
import { useAgents } from "../store";
export function providerName(id: string) {
return useAgents.getState().providers.find((p) => p.id === id)?.name ?? id;
}
/** `Date.now()`, updated every `interval` ms. */
export function useNow(interval: number): number {
const [now, setNow] = useState(() => Date.now());
useEffect(() => {
const t = setInterval(() => setNow(Date.now()), interval);
return () => clearInterval(t);
}, [interval]);
return now;
}
export type UserEntry = Extract<AgentEntry, { type: "user" }>;
/** Agent-written titles with the task's own folder dropped from paths. */
export const shortTitle = (task: AgentTask, title: string) => title.replaceAll(`${task.cwd}/`, "");