Merge pull request #1079 from d-ploutarchos/fix/tui-token-refresh
TUI: refresh token counts after agent runs complete
This commit is contained in:
@@ -8,10 +8,11 @@ type EventHandlerContext = {
|
||||
tui: TUI;
|
||||
state: TuiStateAccess;
|
||||
setActivityStatus: (text: string) => void;
|
||||
refreshSessionInfo?: () => Promise<void>;
|
||||
};
|
||||
|
||||
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 noteFinalizedRun = (runId: string) => {
|
||||
@@ -64,6 +65,8 @@ export function createEventHandlers(context: EventHandlerContext) {
|
||||
noteFinalizedRun(evt.runId);
|
||||
state.activeChatRunId = null;
|
||||
setActivityStatus(stopReason === "error" ? "error" : "idle");
|
||||
// Refresh session info to update token counts in footer
|
||||
void refreshSessionInfo?.();
|
||||
}
|
||||
if (evt.state === "aborted") {
|
||||
chatLog.addSystem("run aborted");
|
||||
|
||||
@@ -399,6 +399,7 @@ export async function runTui(opts: TuiOptions) {
|
||||
tui,
|
||||
state,
|
||||
setActivityStatus,
|
||||
refreshSessionInfo,
|
||||
});
|
||||
|
||||
const { handleCommand, sendMessage, openModelSelector, openAgentSelector, openSessionSelector } =
|
||||
|
||||
Reference in New Issue
Block a user