fix: reload TUI history after reconnect

This commit is contained in:
Peter Steinberger
2026-01-25 00:36:36 +00:00
parent 5ea15ff7fe
commit a6c97b5a48
2 changed files with 12 additions and 10 deletions

View File

@@ -19,6 +19,7 @@ Docs: https://docs.clawd.bot
- BlueBubbles: keep part-index GUIDs in reply tags when short IDs are missing.
- Web UI: hide internal `message_id` hints in chat bubbles.
- Heartbeat: normalize target identifiers for consistent routing.
- TUI: reload history after gateway reconnect to restore session state. (#1663)
- Telegram: use wrapped fetch for long-polling on Node to normalize AbortSignal handling. (#1639)
- Exec: keep approvals for elevated ask unless full mode. (#1616) Thanks @ivancasco.
- Agents: auto-compact on context overflow prompt errors before failing. (#1627) Thanks @rodrigouroz.

View File

@@ -90,6 +90,7 @@ export async function runTui(opts: TuiOptions) {
let activeChatRunId: string | null = null;
let historyLoaded = false;
let isConnected = false;
let wasDisconnected = false;
let toolsExpanded = false;
let showThinking = false;
@@ -584,20 +585,18 @@ export async function runTui(opts: TuiOptions) {
client.onConnected = () => {
isConnected = true;
const reconnected = wasDisconnected;
wasDisconnected = false;
setConnectionStatus("connected");
void (async () => {
await refreshAgents();
updateHeader();
if (!historyLoaded) {
await loadHistory();
setConnectionStatus("gateway connected", 4000);
tui.requestRender();
if (!autoMessageSent && autoMessage) {
autoMessageSent = true;
await sendMessage(autoMessage);
}
} else {
setConnectionStatus("gateway reconnected", 4000);
await loadHistory();
setConnectionStatus(reconnected ? "gateway reconnected" : "gateway connected", 4000);
tui.requestRender();
if (!autoMessageSent && autoMessage) {
autoMessageSent = true;
await sendMessage(autoMessage);
}
updateFooter();
tui.requestRender();
@@ -606,6 +605,8 @@ export async function runTui(opts: TuiOptions) {
client.onDisconnected = (reason) => {
isConnected = false;
wasDisconnected = true;
historyLoaded = false;
const reasonLabel = reason?.trim() ? reason.trim() : "closed";
setConnectionStatus(`gateway disconnected: ${reasonLabel}`, 5000);
setActivityStatus("idle");