TUI/Gateway: fix pi streaming + tool routing + model display + msg updating (#8432)

* TUI/Gateway: fix pi streaming + tool routing

* Tests: clarify verbose tool output expectation

* fix: avoid seq gaps for targeted tool events (#8432) (thanks @gumadeiras)
This commit is contained in:
Gustavo Madeira Santana
2026-02-04 17:12:16 -05:00
committed by GitHub
parent a42e3cb78a
commit 38e6da1fe0
32 changed files with 1227 additions and 208 deletions

View File

@@ -95,6 +95,7 @@ export async function runTui(opts: TuiOptions) {
let wasDisconnected = false;
let toolsExpanded = false;
let showThinking = false;
const localRunIds = new Set<string>();
const deliverDefault = opts.deliver ?? false;
const autoMessage = opts.message?.trim();
@@ -225,6 +226,29 @@ export async function runTui(opts: TuiOptions) {
},
};
const noteLocalRunId = (runId: string) => {
if (!runId) {
return;
}
localRunIds.add(runId);
if (localRunIds.size > 200) {
const [first] = localRunIds;
if (first) {
localRunIds.delete(first);
}
}
};
const forgetLocalRunId = (runId: string) => {
localRunIds.delete(runId);
};
const isLocalRunId = (runId: string) => localRunIds.has(runId);
const clearLocalRunIds = () => {
localRunIds.clear();
};
const client = new GatewayChatClient({
url: opts.url,
token: opts.token,
@@ -522,9 +546,16 @@ export async function runTui(opts: TuiOptions) {
updateFooter,
updateAutocompleteProvider,
setActivityStatus,
clearLocalRunIds,
});
const { refreshAgents, refreshSessionInfo, loadHistory, setSession, abortActive } =
sessionActions;
const {
refreshAgents,
refreshSessionInfo,
applySessionInfoFromPatch,
loadHistory,
setSession,
abortActive,
} = sessionActions;
const { handleChatEvent, handleAgentEvent } = createEventHandlers({
chatLog,
@@ -532,6 +563,10 @@ export async function runTui(opts: TuiOptions) {
state,
setActivityStatus,
refreshSessionInfo,
loadHistory,
isLocalRunId,
forgetLocalRunId,
clearLocalRunIds,
});
const { handleCommand, sendMessage, openModelSelector, openAgentSelector, openSessionSelector } =
@@ -545,12 +580,15 @@ export async function runTui(opts: TuiOptions) {
openOverlay,
closeOverlay,
refreshSessionInfo,
applySessionInfoFromPatch,
loadHistory,
setSession,
refreshAgents,
abortActive,
setActivityStatus,
formatSessionKey,
noteLocalRunId,
forgetLocalRunId,
});
const { runLocalShellLine } = createLocalShellRunner({