TUI: refresh token counts after agent runs complete. Closes #1078
parent
6d969fe58e
commit
cddf198321
|
|
@ -8,10 +8,11 @@ type EventHandlerContext = {
|
||||||
tui: TUI;
|
tui: TUI;
|
||||||
state: TuiStateAccess;
|
state: TuiStateAccess;
|
||||||
setActivityStatus: (text: string) => void;
|
setActivityStatus: (text: string) => void;
|
||||||
|
refreshSessionInfo?: () => Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function createEventHandlers(context: EventHandlerContext) {
|
export function createEventHandlers(context: EventHandlerContext) {
|
||||||
const { chatLog, tui, state, setActivityStatus } = context;
|
const { chatLog, tui, state, setActivityStatus, refreshSessionInfo } = context;
|
||||||
const finalizedRuns = new Map<string, number>();
|
const finalizedRuns = new Map<string, number>();
|
||||||
|
|
||||||
const noteFinalizedRun = (runId: string) => {
|
const noteFinalizedRun = (runId: string) => {
|
||||||
|
|
@ -64,6 +65,8 @@ export function createEventHandlers(context: EventHandlerContext) {
|
||||||
noteFinalizedRun(evt.runId);
|
noteFinalizedRun(evt.runId);
|
||||||
state.activeChatRunId = null;
|
state.activeChatRunId = null;
|
||||||
setActivityStatus(stopReason === "error" ? "error" : "idle");
|
setActivityStatus(stopReason === "error" ? "error" : "idle");
|
||||||
|
// Refresh session info to update token counts in footer
|
||||||
|
void refreshSessionInfo?.();
|
||||||
}
|
}
|
||||||
if (evt.state === "aborted") {
|
if (evt.state === "aborted") {
|
||||||
chatLog.addSystem("run aborted");
|
chatLog.addSystem("run aborted");
|
||||||
|
|
|
||||||
|
|
@ -399,6 +399,7 @@ export async function runTui(opts: TuiOptions) {
|
||||||
tui,
|
tui,
|
||||||
state,
|
state,
|
||||||
setActivityStatus,
|
setActivityStatus,
|
||||||
|
refreshSessionInfo,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { handleCommand, sendMessage, openModelSelector, openAgentSelector, openSessionSelector } =
|
const { handleCommand, sendMessage, openModelSelector, openAgentSelector, openSessionSelector } =
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue