farai 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -3635,7 +3635,7 @@ function proxyConfig(value) {
3635
3635
  }
3636
3636
  function resolveProxyConfig(config) {
3637
3637
  return {
3638
- transparent: config.proxy?.transparent === true,
3638
+ transparent: config.proxy?.transparent !== false,
3639
3639
  ports: config.proxy?.ports?.length ? config.proxy.ports : DEFAULT_TRANSPARENT_PROXY_PORTS
3640
3640
  };
3641
3641
  }
@@ -3960,7 +3960,7 @@ function atomicWriteFile(path, content, mode) {
3960
3960
  var DEFAULT_TRANSPARENT_PROXY_PORTS, LSP_SERVER_IDS, DEFAULT_CONFIG_TEMPLATE = `model = "big-pickle"
3961
3961
 
3962
3962
  [proxy]
3963
- transparent = false
3963
+ transparent = true
3964
3964
 
3965
3965
  [mcp_servers.mitmproxy-mcp]
3966
3966
  command = "mitmproxy-mcp"
@@ -24103,6 +24103,17 @@ var init_tool_call_journal = () => {};
24103
24103
  import { createHash as createHash4 } from "crypto";
24104
24104
  import { existsSync as existsSync12, mkdirSync as mkdirSync6, realpathSync as realpathSync3, writeFileSync as writeFileSync7 } from "fs";
24105
24105
  import { isAbsolute as isAbsolute4, join as join16, relative as relative6 } from "path";
24106
+ function shouldBufferInitialTextStream(text) {
24107
+ if (isInternalMetaReasoning(text))
24108
+ return true;
24109
+ if (text.includes(`
24110
+ `))
24111
+ return false;
24112
+ const normalized = text.trimStart().toLowerCase().replace(/\s+/g, " ");
24113
+ if (!normalized)
24114
+ return false;
24115
+ return INTERNAL_META_STREAM_PREFIXES.some((prefix) => prefix.startsWith(normalized));
24116
+ }
24106
24117
 
24107
24118
  class AgentRuntime {
24108
24119
  turnControllers = new Map;
@@ -25037,7 +25048,7 @@ class AgentRuntime {
25037
25048
  this.autoCompactFailures.delete(sessionId);
25038
25049
  this.fileState.clear(sessionId);
25039
25050
  for (const turn of this.store.listTurns(sessionId, 1000)) {
25040
- this.streamingParts.delete(turn.id);
25051
+ this.deleteStreamingParts(turn.id);
25041
25052
  }
25042
25053
  return this.store.clearSessionChat(sessionId);
25043
25054
  }
@@ -25752,7 +25763,7 @@ This completion is already terminal and was delivered automatically. Do not call
25752
25763
  } else if (action.kind === "respond") {
25753
25764
  sawResponse = true;
25754
25765
  if (hasToolAction && isInternalMetaReasoning(action.text)) {
25755
- this.discardStreamingText(turn.id);
25766
+ this.discardStreamingText(session.id, turn.id);
25756
25767
  shouldContinue = true;
25757
25768
  continue;
25758
25769
  }
@@ -25789,7 +25800,7 @@ This completion is already terminal and was delivered automatically. Do not call
25789
25800
  });
25790
25801
  const request = buildChatRequest(plannerInput, requestController.signal);
25791
25802
  let lastError = "";
25792
- this.streamingParts.delete(turn.id);
25803
+ this.deleteStreamingParts(turn.id);
25793
25804
  try {
25794
25805
  for (let attempt = 1;; attempt += 1) {
25795
25806
  this.emitPlannerAttempt(session, turn, assistantMessage, plannerName, attempt, plannerInput, context);
@@ -25928,7 +25939,7 @@ This completion is already terminal and was delivered automatically. Do not call
25928
25939
  shouldContinue: shouldContinue2
25929
25940
  };
25930
25941
  }
25931
- this.prepareStreamingRetry(turn.id);
25942
+ this.prepareStreamingRetry(session.id, turn.id);
25932
25943
  const retry = plannerRetryState(error, attempt, dispatched.length === 0);
25933
25944
  const errorPayload = {
25934
25945
  turnId: turn.id,
@@ -25997,7 +26008,7 @@ This completion is already terminal and was delivered automatically. Do not call
25997
26008
  const rawRespondText = content.trim();
25998
26009
  const respondText = dispatched.length > 0 && isInternalMetaReasoning(rawRespondText) ? "" : rawRespondText;
25999
26010
  if (!respondText && rawRespondText && dispatched.length > 0)
26000
- this.discardStreamingText(turn.id);
26011
+ this.discardStreamingText(session.id, turn.id);
26001
26012
  const outcomes = await Promise.all(dispatched);
26002
26013
  const toolCancelled = outcomes.some((outcome) => outcome.cancelled);
26003
26014
  for (const outcome of outcomes) {
@@ -26151,9 +26162,11 @@ This completion is already terminal and was delivered automatically. Do not call
26151
26162
  rationale: ""
26152
26163
  });
26153
26164
  if (state) {
26165
+ state.reasoningAccum = "";
26166
+ this.publishStreamingReasoning(session.id, turn.id, state);
26154
26167
  delete state.reasoningPartId;
26155
26168
  delete state.reasoningAccum;
26156
- delete state.lastReasoningRender;
26169
+ delete state.lastReasoningPersist;
26157
26170
  }
26158
26171
  return;
26159
26172
  }
@@ -26162,13 +26175,15 @@ This completion is already terminal and was delivered automatically. Do not call
26162
26175
  rationale
26163
26176
  });
26164
26177
  if (state?.reasoningPartId) {
26178
+ state.reasoningAccum = rationale;
26179
+ this.publishStreamingReasoning(session.id, turn.id, state);
26165
26180
  this.store.updatePartPayload(state.reasoningPartId, {
26166
26181
  planner: plannerName,
26167
26182
  rationale
26168
26183
  });
26169
26184
  delete state.reasoningPartId;
26170
26185
  delete state.reasoningAccum;
26171
- delete state.lastReasoningRender;
26186
+ delete state.lastReasoningPersist;
26172
26187
  } else {
26173
26188
  this.store.addPart({
26174
26189
  sessionId: session.id,
@@ -26186,6 +26201,8 @@ This completion is already terminal and was delivered automatically. Do not call
26186
26201
  responses.push(text);
26187
26202
  const streamed = this.streamingParts.get(turn.id);
26188
26203
  if (streamed?.textPartId) {
26204
+ streamed.textAccum = text;
26205
+ this.publishStreamingText(session.id, turn.id, streamed);
26189
26206
  this.store.updatePartPayload(streamed.textPartId, {
26190
26207
  text
26191
26208
  });
@@ -26669,6 +26686,40 @@ This completion is already terminal and was delivered automatically. Do not call
26669
26686
  };
26670
26687
  }
26671
26688
  }
26689
+ deleteStreamingParts(turnId) {
26690
+ this.streamingParts.delete(turnId);
26691
+ }
26692
+ publishStreamingText(sessionId, turnId, state) {
26693
+ if (!state.textPartId)
26694
+ return;
26695
+ this.store.publishTransientEvent({
26696
+ id: id(),
26697
+ sessionId,
26698
+ type: "stream_text",
26699
+ payload: {
26700
+ turnId,
26701
+ partId: state.textPartId,
26702
+ text: state.textAccum
26703
+ },
26704
+ createdAt: nowIso()
26705
+ });
26706
+ }
26707
+ publishStreamingReasoning(sessionId, turnId, state) {
26708
+ if (!state.reasoningPartId)
26709
+ return;
26710
+ const rationale = normalizeReasoningSummary(state.reasoningAccum ?? "");
26711
+ this.store.publishTransientEvent({
26712
+ id: id(),
26713
+ sessionId,
26714
+ type: "stream_reasoning",
26715
+ payload: {
26716
+ turnId,
26717
+ partId: state.reasoningPartId,
26718
+ rationale
26719
+ },
26720
+ createdAt: nowIso()
26721
+ });
26722
+ }
26672
26723
  applyStreamEvent(session, turn, assistantMessage, event) {
26673
26724
  const now = Date.now();
26674
26725
  const state = this.streamingParts.get(turn.id) ?? {
@@ -26693,26 +26744,39 @@ This completion is already terminal and was delivered automatically. Do not call
26693
26744
  }
26694
26745
  });
26695
26746
  state.reasoningPartId = part.id;
26696
- state.lastReasoningRender = now;
26697
- } else if (now - (state.lastReasoningRender ?? 0) >= STREAM_RENDER_INTERVAL_MS) {
26747
+ state.lastReasoningPersist = now;
26748
+ } else if (now - (state.lastReasoningPersist ?? 0) >= STREAM_PERSIST_INTERVAL_MS) {
26698
26749
  this.store.updatePartPayload(state.reasoningPartId, {
26699
26750
  rationale
26700
26751
  });
26701
- state.lastReasoningRender = now;
26752
+ state.lastReasoningPersist = now;
26702
26753
  }
26754
+ this.publishStreamingReasoning(session.id, turn.id, state);
26703
26755
  this.streamingParts.set(turn.id, state);
26704
26756
  return;
26705
26757
  }
26706
26758
  state.textAccum += event.delta;
26707
26759
  if (!state.textPartId) {
26708
- if (isInternalMetaReasoning(state.textAccum)) {
26760
+ if (shouldBufferInitialTextStream(state.textAccum)) {
26709
26761
  this.streamingParts.set(turn.id, state);
26710
26762
  return;
26711
26763
  }
26712
- if (state.textAccum.length < 80 && !state.textAccum.includes(`
26713
- `)) {
26714
- this.streamingParts.set(turn.id, state);
26715
- return;
26764
+ if (!state.reasoningPartId && state.reasoningAccum) {
26765
+ const rationale = normalizeReasoningSummary(state.reasoningAccum);
26766
+ if (rationale) {
26767
+ const reasoningPart = this.store.addPart({
26768
+ sessionId: session.id,
26769
+ turnId: turn.id,
26770
+ messageId: assistantMessage.id,
26771
+ type: "reasoning_summary",
26772
+ payload: {
26773
+ rationale
26774
+ }
26775
+ });
26776
+ state.reasoningPartId = reasoningPart.id;
26777
+ state.lastReasoningPersist = now;
26778
+ this.publishStreamingReasoning(session.id, turn.id, state);
26779
+ }
26716
26780
  }
26717
26781
  const part = this.store.addPart({
26718
26782
  sessionId: session.id,
@@ -26724,30 +26788,17 @@ This completion is already terminal and was delivered automatically. Do not call
26724
26788
  }
26725
26789
  });
26726
26790
  state.textPartId = part.id;
26727
- state.lastTextRender = now;
26728
26791
  state.lastTextPersist = now;
26729
26792
  } else if (now - (state.lastTextPersist ?? 0) >= STREAM_PERSIST_INTERVAL_MS) {
26730
26793
  this.store.updatePartPayload(state.textPartId, {
26731
26794
  text: state.textAccum
26732
26795
  });
26733
- state.lastTextRender = now;
26734
26796
  state.lastTextPersist = now;
26735
- } else if (now - (state.lastTextRender ?? 0) >= STREAM_RENDER_INTERVAL_MS) {
26736
- this.store.publishTransientEvent({
26737
- id: id(),
26738
- sessionId: session.id,
26739
- type: "stream_text",
26740
- payload: {
26741
- partId: state.textPartId,
26742
- text: state.textAccum
26743
- },
26744
- createdAt: nowIso()
26745
- });
26746
- state.lastTextRender = now;
26747
26797
  }
26798
+ this.publishStreamingText(session.id, turn.id, state);
26748
26799
  this.streamingParts.set(turn.id, state);
26749
26800
  }
26750
- discardStreamingText(turnId) {
26801
+ discardStreamingText(sessionId, turnId) {
26751
26802
  const state = this.streamingParts.get(turnId);
26752
26803
  if (!state)
26753
26804
  return;
@@ -26756,11 +26807,11 @@ This completion is already terminal and was delivered automatically. Do not call
26756
26807
  text: ""
26757
26808
  });
26758
26809
  state.textAccum = "";
26810
+ this.publishStreamingText(sessionId, turnId, state);
26759
26811
  delete state.textPartId;
26760
- delete state.lastTextRender;
26761
26812
  delete state.lastTextPersist;
26762
26813
  }
26763
- prepareStreamingRetry(turnId) {
26814
+ prepareStreamingRetry(sessionId, turnId) {
26764
26815
  const state = this.streamingParts.get(turnId);
26765
26816
  if (!state)
26766
26817
  return;
@@ -26773,11 +26824,13 @@ This completion is already terminal and was delivered automatically. Do not call
26773
26824
  rationale: ""
26774
26825
  });
26775
26826
  state.textAccum = "";
26827
+ state.reasoningAccum = "";
26828
+ this.publishStreamingText(sessionId, turnId, state);
26829
+ this.publishStreamingReasoning(sessionId, turnId, state);
26776
26830
  delete state.reasoningPartId;
26777
26831
  delete state.reasoningAccum;
26778
- delete state.lastReasoningRender;
26779
- state.lastTextRender = Date.now();
26780
- state.lastTextPersist = state.lastTextRender;
26832
+ delete state.lastReasoningPersist;
26833
+ state.lastTextPersist = Date.now();
26781
26834
  }
26782
26835
  async planWithRetry(planner, input, session, turn, assistantMessage, context, timeoutMs, allowEmpty = false) {
26783
26836
  let lastError = "";
@@ -26786,7 +26839,7 @@ This completion is already terminal and was delivered automatically. Do not call
26786
26839
  release,
26787
26840
  timedOut
26788
26841
  } = this.registerTurnController(turn.id, timeoutMs);
26789
- this.streamingParts.delete(turn.id);
26842
+ this.deleteStreamingParts(turn.id);
26790
26843
  const onStreamEvent = (event) => this.applyStreamEvent(session, turn, assistantMessage, event);
26791
26844
  try {
26792
26845
  for (let attempt = 1;; attempt += 1) {
@@ -26813,7 +26866,7 @@ This completion is already terminal and was delivered automatically. Do not call
26813
26866
  lastError = "cancelled";
26814
26867
  break;
26815
26868
  }
26816
- this.prepareStreamingRetry(turn.id);
26869
+ this.prepareStreamingRetry(session.id, turn.id);
26817
26870
  const retry = plannerRetryState(error, attempt, true);
26818
26871
  const errorPayload = {
26819
26872
  turnId: turn.id,
@@ -26935,7 +26988,7 @@ This completion is already terminal and was delivered automatically. Do not call
26935
26988
  } : {}
26936
26989
  });
26937
26990
  this.modelCallsByTurn.delete(turn.id);
26938
- this.streamingParts.delete(turn.id);
26991
+ this.deleteStreamingParts(turn.id);
26939
26992
  this.fireHooks({
26940
26993
  id: turn.sessionId
26941
26994
  }, "turn.stop", undefined, {
@@ -28405,7 +28458,7 @@ function sameExistingPath(left, right) {
28405
28458
  return false;
28406
28459
  }
28407
28460
  }
28408
- var REASONING_MAX_BYTES2, STREAM_RENDER_INTERVAL_MS = 100, STREAM_PERSIST_INTERVAL_MS = 2000, LIVE_OUTPUT_MAX_BYTES, LIVE_OUTPUT_FLUSH_INTERVAL_MS = 150, LIVE_OUTPUT_INITIAL_DELAY_MS = 320, TOOL_HUMAN_RESULT_MAX_BYTES, LOOP_SUPERVISION_NO_PROGRESS_STEPS = 12, LOOP_SUPERVISION_STEER_INTERVAL = 5, LOOP_PATTERN_MAX_PERIOD = 8, PROGRESS_ACTION_TOOLS, AUTO_COMPACTION_CONTINUATION = "[internal continuation after context compaction: Continue the active user task from the compacted prior context. Do not repeat, regenerate, or explain the summary. Resume with the exact next useful action.]", WRAPUP_MODEL_TIMEOUT_MS = 15000, DEFAULT_SHUTDOWN_GRACE_PERIOD_MS = 2000, RUNTIME_LEASE_MS = 60000, RUNTIME_HEARTBEAT_MS = 15000, RESTART_TOOL_ERROR = "Interrupted by runtime restart; tool execution was not replayed.", STEP_LIMIT_WRAPUP_DIRECTIVE = "You have reached the maximum number of steps allowed for this turn, so tools are no longer available. Do not attempt to call any tool. In a few sentences, summarize what you accomplished, the key findings or evidence so far, any blockers, and the single most useful next step. This is your final message for this turn.", TIME_LIMIT_WRAPUP_DIRECTIVE = "You have reached the interactive wall-clock budget for this turn, so tools are no longer available. Do not attempt to call any tool. Concisely summarize completed work, proven evidence, active background jobs, remaining uncertainty, and the single best next action. This is your final message for this turn.", IneffectiveCompactionError, ModelCallDeadlineError, PlannerOutputValidationError;
28461
+ var REASONING_MAX_BYTES2, STREAM_PERSIST_INTERVAL_MS = 2000, LIVE_OUTPUT_MAX_BYTES, LIVE_OUTPUT_FLUSH_INTERVAL_MS = 150, LIVE_OUTPUT_INITIAL_DELAY_MS = 320, TOOL_HUMAN_RESULT_MAX_BYTES, LOOP_SUPERVISION_NO_PROGRESS_STEPS = 12, LOOP_SUPERVISION_STEER_INTERVAL = 5, LOOP_PATTERN_MAX_PERIOD = 8, PROGRESS_ACTION_TOOLS, AUTO_COMPACTION_CONTINUATION = "[internal continuation after context compaction: Continue the active user task from the compacted prior context. Do not repeat, regenerate, or explain the summary. Resume with the exact next useful action.]", WRAPUP_MODEL_TIMEOUT_MS = 15000, DEFAULT_SHUTDOWN_GRACE_PERIOD_MS = 2000, RUNTIME_LEASE_MS = 60000, RUNTIME_HEARTBEAT_MS = 15000, RESTART_TOOL_ERROR = "Interrupted by runtime restart; tool execution was not replayed.", STEP_LIMIT_WRAPUP_DIRECTIVE = "You have reached the maximum number of steps allowed for this turn, so tools are no longer available. Do not attempt to call any tool. In a few sentences, summarize what you accomplished, the key findings or evidence so far, any blockers, and the single most useful next step. This is your final message for this turn.", TIME_LIMIT_WRAPUP_DIRECTIVE = "You have reached the interactive wall-clock budget for this turn, so tools are no longer available. Do not attempt to call any tool. Concisely summarize completed work, proven evidence, active background jobs, remaining uncertainty, and the single best next action. This is your final message for this turn.", INTERNAL_META_STREAM_PREFIXES, IneffectiveCompactionError, ModelCallDeadlineError, PlannerOutputValidationError;
28409
28462
  var init_runtime = __esm(() => {
28410
28463
  init_sqlite_store();
28411
28464
  init_registry4();
@@ -28453,6 +28506,7 @@ var init_runtime = __esm(() => {
28453
28506
  LIVE_OUTPUT_MAX_BYTES = 2 * 1024;
28454
28507
  TOOL_HUMAN_RESULT_MAX_BYTES = 24 * 1024;
28455
28508
  PROGRESS_ACTION_TOOLS = new Set(["http_request", "subdomain_enum", "dir_enum", "port_scan", "nmap_scan", "fs_edit", "fs_write", "patch_apply", "code_write_script", "campaign_verify", "campaign_test", "callback_oast", "exploit_search"]);
28509
+ INTERNAL_META_STREAM_PREFIXES = ["the user", "user asked", "user wants", "user requested", "user said", "per my", "per the", "my communication", "my instruction", "my instructions", "my rules", "my task", "according to my", "according to the", "the tool search", "tool_search", "there's no dedicated tool", "there is no dedicated tool", "there's no specific tool", "there is no specific tool", "there's no matching tool", "there is no matching tool", "i have access to", "let me inspect the available tool", "let me check the available tool", "let me search the available tool", "i should report", "i will report", "i need to report", "i must report", "i can report", "we should report", "we will report", "we need to report", "we must report", "we can report"];
28456
28510
  IneffectiveCompactionError = class IneffectiveCompactionError extends Error {
28457
28511
  constructor(preTokens, postTokens) {
28458
28512
  super(`compaction did not reduce active context: ${preTokens} -> ${postTokens} estimated tokens`);
@@ -32644,6 +32698,17 @@ function createRuntimePort(runtime, options = {}) {
32644
32698
  return;
32645
32699
  if (evt.type === "snapshot.changed" && pending.some((item) => item.type === "snapshot.changed" && item.sessionId === evt.sessionId))
32646
32700
  return;
32701
+ const streamIdentity = transientStreamIdentity(evt);
32702
+ if (streamIdentity) {
32703
+ const existing = pending.length - 1;
32704
+ if (existing >= 0 && transientStreamIdentity(pending[existing]) === streamIdentity)
32705
+ pending[existing] = evt;
32706
+ else
32707
+ pending.push(evt);
32708
+ if (!flushTimer)
32709
+ flushTimer = setTimeout(flush, BATCH_DEBOUNCE_MS);
32710
+ return;
32711
+ }
32647
32712
  if (evt.type === "activity.changed") {
32648
32713
  const existing = pending.findIndex((item) => item.type === "activity.changed" && item.sessionId === evt.sessionId);
32649
32714
  if (existing >= 0)
@@ -32976,16 +33041,32 @@ function createRuntimePort(runtime, options = {}) {
32976
33041
  }
32977
33042
  });
32978
33043
  } catch {
32979
- mcpResult = await callMcpServerTool({
32980
- workspace: session.workspace,
32981
- configWorkspace: runtime.workspace,
32982
- session,
32983
- server: "mitmproxy-mcp",
32984
- tool: "get_traffic_summary",
32985
- args: {
32986
- limit: options2.limit ?? 300
32987
- }
32988
- });
33044
+ try {
33045
+ mcpResult = await callMcpServerTool({
33046
+ workspace: session.workspace,
33047
+ configWorkspace: runtime.workspace,
33048
+ session,
33049
+ server: "mitmproxy-mcp",
33050
+ tool: "get_flow_summary_v2",
33051
+ args: {
33052
+ limit: options2.limit ?? 300,
33053
+ ...options2.kind ? {
33054
+ kind: options2.kind
33055
+ } : {}
33056
+ }
33057
+ });
33058
+ } catch {
33059
+ mcpResult = await callMcpServerTool({
33060
+ workspace: session.workspace,
33061
+ configWorkspace: runtime.workspace,
33062
+ session,
33063
+ server: "mitmproxy-mcp",
33064
+ tool: "get_traffic_summary",
33065
+ args: {
33066
+ limit: options2.limit ?? 300
33067
+ }
33068
+ });
33069
+ }
32989
33070
  }
32990
33071
  const flows = proxyFlowsFromMcpTrafficSummary(mcpResult, options2);
32991
33072
  if (flows.length > 0 || listMcpServerStatuses(activeSessionId).some((status2) => status2.name === "mitmproxy-mcp" && status2.running))
@@ -33018,6 +33099,21 @@ function createRuntimePort(runtime, options = {}) {
33018
33099
  if (detail)
33019
33100
  return detail;
33020
33101
  } catch {}
33102
+ try {
33103
+ const compatibleResult = await callMcpServerTool({
33104
+ workspace: session.workspace,
33105
+ configWorkspace: runtime.workspace,
33106
+ session,
33107
+ server: "mitmproxy-mcp",
33108
+ tool: "inspect_flow_v2",
33109
+ args: {
33110
+ flow_id: id2
33111
+ }
33112
+ });
33113
+ const compatibleDetail = proxyFlowDetailFromMcpInspect(compatibleResult);
33114
+ if (compatibleDetail)
33115
+ return compatibleDetail;
33116
+ } catch {}
33021
33117
  const legacyResult = await callMcpServerTool({
33022
33118
  workspace: session.workspace,
33023
33119
  configWorkspace: runtime.workspace,
@@ -33249,6 +33345,16 @@ function createRuntimePort(runtime, options = {}) {
33249
33345
  }
33250
33346
  };
33251
33347
  }
33348
+ function transientStreamIdentity(event) {
33349
+ if (event.type !== "event.appended")
33350
+ return;
33351
+ if (event.event.type !== "stream_text" && event.event.type !== "stream_reasoning")
33352
+ return;
33353
+ const payload = event.event.payload;
33354
+ if (typeof payload?.turnId !== "string" || typeof payload.partId !== "string")
33355
+ return;
33356
+ return `${event.sessionId}:${payload.turnId}:${event.event.type}:${payload.partId}`;
33357
+ }
33252
33358
  function storeChangeIdentity(change) {
33253
33359
  switch (change.kind) {
33254
33360
  case "part":
@@ -34292,19 +34398,6 @@ function createActions(store, setStore) {
34292
34398
  errorSet(message) {
34293
34399
  setStore("ui", "lastError", message);
34294
34400
  },
34295
- streamTextUpdated(partId, text) {
34296
- setStore(produce((s) => {
34297
- for (const message of s.snapshot.messages) {
34298
- const part = message.parts.find((item) => item.id === partId);
34299
- if (!part)
34300
- continue;
34301
- part.payload = {
34302
- text
34303
- };
34304
- return;
34305
- }
34306
- }));
34307
- },
34308
34401
  toolInputPreviewUpdated(preview) {
34309
34402
  setStore(produce((s) => {
34310
34403
  const index = s.snapshot.toolInputPreviews.findIndex((item) => item.id === preview.id);
@@ -34746,9 +34839,11 @@ async function handleTuiEvent(evt, ctx) {
34746
34839
  }
34747
34840
  switch (evt.type) {
34748
34841
  case "turn.started":
34842
+ ctx.onTurnStarted?.(evt.turnId);
34749
34843
  ctx.actions.turnStarted(evt.turnId, evt.startedAt);
34750
34844
  break;
34751
34845
  case "turn.finished":
34846
+ ctx.onTurnFinished?.(evt.turnId);
34752
34847
  ctx.actions.turnFinished(evt.turnId);
34753
34848
  await refreshSnapshot(evt.sessionId);
34754
34849
  queueMicrotask(() => {
@@ -34779,8 +34874,14 @@ async function handleTuiEvent(evt, ctx) {
34779
34874
  }
34780
34875
  if (evt.event.type === "stream_text") {
34781
34876
  const payload = evt.event.payload;
34782
- if (typeof payload?.partId === "string" && typeof payload.text === "string") {
34783
- ctx.actions.streamTextUpdated(payload.partId, payload.text);
34877
+ if (typeof payload?.turnId === "string" && typeof payload.partId === "string" && typeof payload.text === "string") {
34878
+ ctx.onStreamText?.(payload.partId, payload.text, payload.turnId);
34879
+ }
34880
+ }
34881
+ if (evt.event.type === "stream_reasoning") {
34882
+ const payload = evt.event.payload;
34883
+ if (typeof payload?.turnId === "string" && typeof payload.partId === "string" && typeof payload.rationale === "string") {
34884
+ ctx.onStreamReasoning?.(payload.partId, payload.rationale, payload.turnId);
34784
34885
  }
34785
34886
  }
34786
34887
  const detail = statusDetailFor(evt.event);
@@ -34986,6 +35087,243 @@ var init_runtime2 = __esm(() => {
34986
35087
  RuntimeContext = createContext();
34987
35088
  });
34988
35089
 
35090
+ // src/agent-tui/transcript/stream-engine.ts
35091
+ function createTranscriptStreamEngine() {
35092
+ const [state, setState] = createStore({
35093
+ text: {},
35094
+ reasoning: {},
35095
+ diagnostics: {
35096
+ revision: 0,
35097
+ flushes: 0,
35098
+ coalescedUpdates: 0,
35099
+ lastIntervalMs: BASE_FRAME_INTERVAL_MS,
35100
+ lastFlushAt: undefined
35101
+ }
35102
+ });
35103
+ const pending = new Map;
35104
+ let activeTurnId;
35105
+ let timer;
35106
+ let timerDueAt = 0;
35107
+ let lastFlushAt = 0;
35108
+ let updatesSinceFlush = 0;
35109
+ let coalescedUpdates = 0;
35110
+ let currentInterval = BASE_FRAME_INTERVAL_MS;
35111
+ let acceptingUpdates = false;
35112
+ let disposed = false;
35113
+ function key(kind, partId) {
35114
+ return `${kind}:${partId}`;
35115
+ }
35116
+ function intervalFor(contentLength, updateCount) {
35117
+ const sizePressure = Math.log2(1 + contentLength / 4096) * 8;
35118
+ const updatePressure = Math.max(0, updateCount - 3) * 2;
35119
+ return Math.round(Math.max(MIN_FRAME_INTERVAL_MS, Math.min(MAX_FRAME_INTERVAL_MS, BASE_FRAME_INTERVAL_MS + sizePressure + updatePressure)));
35120
+ }
35121
+ function schedule() {
35122
+ if (disposed || pending.size === 0)
35123
+ return;
35124
+ const now = Date.now();
35125
+ const maxLength = Math.max(0, ...[...pending.values()].map((entry) => entry.content.length));
35126
+ const interval = intervalFor(maxLength, updatesSinceFlush);
35127
+ currentInterval = interval;
35128
+ const elapsed = now - lastFlushAt;
35129
+ if (lastFlushAt === 0 || elapsed >= interval) {
35130
+ flush();
35131
+ return;
35132
+ }
35133
+ const dueAt = lastFlushAt + interval;
35134
+ if (timer && dueAt <= timerDueAt)
35135
+ return;
35136
+ if (timer)
35137
+ clearTimeout(timer);
35138
+ timerDueAt = dueAt;
35139
+ timer = setTimeout(flush, Math.max(0, dueAt - now));
35140
+ }
35141
+ function flush() {
35142
+ if (disposed)
35143
+ return;
35144
+ if (timer) {
35145
+ clearTimeout(timer);
35146
+ timer = undefined;
35147
+ }
35148
+ timerDueAt = 0;
35149
+ if (pending.size === 0)
35150
+ return;
35151
+ const entries = [...pending.values()];
35152
+ pending.clear();
35153
+ const now = Date.now();
35154
+ lastFlushAt = now;
35155
+ updatesSinceFlush = 0;
35156
+ setState(produce((draft) => {
35157
+ draft.diagnostics.revision += 1;
35158
+ draft.diagnostics.flushes += 1;
35159
+ draft.diagnostics.coalescedUpdates = coalescedUpdates;
35160
+ draft.diagnostics.lastIntervalMs = currentInterval;
35161
+ draft.diagnostics.lastFlushAt = now;
35162
+ const revision = draft.diagnostics.revision;
35163
+ for (const entry of entries) {
35164
+ const target = entry.kind === "text" ? draft.text : draft.reasoning;
35165
+ target[entry.partId] = {
35166
+ content: entry.content,
35167
+ revision
35168
+ };
35169
+ }
35170
+ }));
35171
+ }
35172
+ function clearVisible() {
35173
+ pending.clear();
35174
+ updatesSinceFlush = 0;
35175
+ if (timer) {
35176
+ clearTimeout(timer);
35177
+ timer = undefined;
35178
+ }
35179
+ timerDueAt = 0;
35180
+ setState(produce((draft) => {
35181
+ draft.text = {};
35182
+ draft.reasoning = {};
35183
+ }));
35184
+ }
35185
+ function update(kind, partId, content, turnId) {
35186
+ if (disposed || !acceptingUpdates || turnId !== activeTurnId)
35187
+ return;
35188
+ const pendingKey = key(kind, partId);
35189
+ const existing = pending.get(pendingKey);
35190
+ const visible = kind === "text" ? state.text[partId]?.content : state.reasoning[partId]?.content;
35191
+ if (existing?.content === content || !existing && visible === content)
35192
+ return;
35193
+ if (existing)
35194
+ coalescedUpdates += 1;
35195
+ pending.set(pendingKey, {
35196
+ kind,
35197
+ partId,
35198
+ content
35199
+ });
35200
+ updatesSinceFlush += 1;
35201
+ schedule();
35202
+ }
35203
+ function durableContent(messages, partId, kind) {
35204
+ for (const message of messages) {
35205
+ const part = message.parts.find((candidate2) => candidate2.id === partId);
35206
+ if (!part)
35207
+ continue;
35208
+ if (kind === "text") {
35209
+ if (typeof part.payload === "string")
35210
+ return part.payload;
35211
+ if (part.payload && typeof part.payload === "object" && "text" in part.payload) {
35212
+ const value = part.payload.text;
35213
+ return typeof value === "string" ? value : undefined;
35214
+ }
35215
+ return;
35216
+ }
35217
+ if (part.payload && typeof part.payload === "object") {
35218
+ const payload = part.payload;
35219
+ if (typeof payload.rationale === "string")
35220
+ return payload.rationale;
35221
+ if (typeof payload.text === "string")
35222
+ return payload.text;
35223
+ }
35224
+ return typeof part.payload === "string" ? part.payload : undefined;
35225
+ }
35226
+ return;
35227
+ }
35228
+ function reconciliationRemovals(kind, visible, messages) {
35229
+ const removals = [];
35230
+ for (const [partId, entry] of Object.entries(visible)) {
35231
+ const durable = durableContent(messages, partId, kind);
35232
+ if (durable === entry.content)
35233
+ removals.push(partId);
35234
+ }
35235
+ return removals;
35236
+ }
35237
+ function reconcile2(messages, runningTurnId) {
35238
+ if (disposed)
35239
+ return;
35240
+ if (!runningTurnId) {
35241
+ clearVisible();
35242
+ activeTurnId = undefined;
35243
+ acceptingUpdates = false;
35244
+ return;
35245
+ }
35246
+ if (activeTurnId && activeTurnId !== runningTurnId) {
35247
+ clearVisible();
35248
+ lastFlushAt = 0;
35249
+ currentInterval = BASE_FRAME_INTERVAL_MS;
35250
+ }
35251
+ if (activeTurnId !== runningTurnId)
35252
+ acceptingUpdates = true;
35253
+ activeTurnId = runningTurnId;
35254
+ const textRemovals = reconciliationRemovals("text", state.text, messages);
35255
+ const reasoningRemovals = reconciliationRemovals("reasoning", state.reasoning, messages);
35256
+ if (textRemovals.length === 0 && reasoningRemovals.length === 0)
35257
+ return;
35258
+ setState(produce((draft) => {
35259
+ for (const partId of textRemovals)
35260
+ delete draft.text[partId];
35261
+ for (const partId of reasoningRemovals)
35262
+ delete draft.reasoning[partId];
35263
+ }));
35264
+ }
35265
+ function beginTurn(turnId) {
35266
+ if (disposed)
35267
+ return;
35268
+ if (activeTurnId !== turnId) {
35269
+ clearVisible();
35270
+ lastFlushAt = 0;
35271
+ currentInterval = BASE_FRAME_INTERVAL_MS;
35272
+ }
35273
+ activeTurnId = turnId;
35274
+ acceptingUpdates = true;
35275
+ }
35276
+ function finishTurn(turnId) {
35277
+ if (disposed || activeTurnId !== turnId)
35278
+ return;
35279
+ flush();
35280
+ acceptingUpdates = false;
35281
+ }
35282
+ function reset2() {
35283
+ if (disposed)
35284
+ return;
35285
+ clearVisible();
35286
+ activeTurnId = undefined;
35287
+ acceptingUpdates = false;
35288
+ lastFlushAt = 0;
35289
+ coalescedUpdates = 0;
35290
+ currentInterval = BASE_FRAME_INTERVAL_MS;
35291
+ setState("diagnostics", {
35292
+ revision: 0,
35293
+ flushes: 0,
35294
+ coalescedUpdates: 0,
35295
+ lastIntervalMs: BASE_FRAME_INTERVAL_MS,
35296
+ lastFlushAt: undefined
35297
+ });
35298
+ }
35299
+ function dispose2() {
35300
+ if (disposed)
35301
+ return;
35302
+ clearVisible();
35303
+ disposed = true;
35304
+ }
35305
+ return {
35306
+ state,
35307
+ beginTurn,
35308
+ finishTurn,
35309
+ update,
35310
+ updateText(partId, content, turnId) {
35311
+ update("text", partId, content, turnId);
35312
+ },
35313
+ updateReasoning(partId, content, turnId) {
35314
+ update("reasoning", partId, content, turnId);
35315
+ },
35316
+ reconcile: reconcile2,
35317
+ reset: reset2,
35318
+ flush,
35319
+ dispose: dispose2
35320
+ };
35321
+ }
35322
+ var MIN_FRAME_INTERVAL_MS = 24, BASE_FRAME_INTERVAL_MS = 24, MAX_FRAME_INTERVAL_MS = 96;
35323
+ var init_stream_engine = __esm(() => {
35324
+ init_store2();
35325
+ });
35326
+
34989
35327
  // src/agent-tui/reasoning.ts
34990
35328
  function parseReasoning(text) {
34991
35329
  const trimmed = normalizeReasoningSummary(text);
@@ -36475,6 +36813,34 @@ var init_renderers2 = __esm(() => {
36475
36813
  TOOL_DETAIL_MAX_BYTES = 32 * 1024;
36476
36814
  });
36477
36815
 
36816
+ // src/agent-tui/transcript/projection.ts
36817
+ function createTranscriptProjection(store, width) {
36818
+ const historyMessages = createMemo(() => {
36819
+ const runningTurnId = store.snapshot.runningTurnId;
36820
+ return runningTurnId ? store.snapshot.messages.filter((message) => message.turnId !== runningTurnId) : store.snapshot.messages;
36821
+ });
36822
+ const activeMessages = createMemo(() => {
36823
+ const runningTurnId = store.snapshot.runningTurnId;
36824
+ return runningTurnId ? store.snapshot.messages.filter((message) => message.turnId === runningTurnId) : [];
36825
+ });
36826
+ const activeMessageIds = createMemo(() => new Set(activeMessages().map((message) => message.id)));
36827
+ const historyToolCalls = createMemo(() => {
36828
+ const runningTurnId = store.snapshot.runningTurnId;
36829
+ return runningTurnId ? store.snapshot.toolCalls.filter((toolCall) => toolCall.turnId !== runningTurnId && (!toolCall.messageId || !activeMessageIds().has(toolCall.messageId))) : store.snapshot.toolCalls;
36830
+ });
36831
+ const activeToolCalls = createMemo(() => {
36832
+ const runningTurnId = store.snapshot.runningTurnId;
36833
+ return runningTurnId ? store.snapshot.toolCalls.filter((toolCall) => toolCall.turnId === runningTurnId || (toolCall.messageId ? activeMessageIds().has(toolCall.messageId) : toolCall.turnId === undefined)) : [];
36834
+ });
36835
+ const historyRows = createMemo(() => projectMessagesToRows(historyMessages(), width(), undefined, historyToolCalls()));
36836
+ const activeRows = createMemo(() => projectMessagesToRows(activeMessages(), width(), store.snapshot.runningTurnId, activeToolCalls(), store.snapshot.toolInputPreviews));
36837
+ return createMemo(() => [...historyRows(), ...activeRows()]);
36838
+ }
36839
+ var init_projection = __esm(() => {
36840
+ init_solid();
36841
+ init_renderers2();
36842
+ });
36843
+
36478
36844
  // src/agent-tui/context/store.tsx
36479
36845
  function proxyRefreshQuery() {
36480
36846
  return {
@@ -36493,6 +36859,7 @@ function TuiStoreProvider(props) {
36493
36859
  setStore: _set,
36494
36860
  actions
36495
36861
  } = createFaraiStore(workspace);
36862
+ const transcript = createTranscriptStreamEngine();
36496
36863
  let statusTimer;
36497
36864
  const proxyRefreshes = new Map;
36498
36865
  const mcpRefreshes = new Map;
@@ -36514,7 +36881,7 @@ function TuiStoreProvider(props) {
36514
36881
  actions.updateNoticeSet(notice);
36515
36882
  });
36516
36883
  }
36517
- const timelineRows = createMemo(() => projectMessagesToRows(store.snapshot.messages, Math.max(1, dims().width - 4), store.snapshot.runningTurnId, store.snapshot.toolCalls, store.snapshot.toolInputPreviews));
36884
+ const timelineRows = createTranscriptProjection(store, () => Math.max(1, dims().width - 4));
36518
36885
  function setStatusDetail(detail, timeoutMs) {
36519
36886
  if (disposed)
36520
36887
  return;
@@ -36582,6 +36949,7 @@ function TuiStoreProvider(props) {
36582
36949
  if (disposed || store.activeSessionId !== sid || snapshotGenerations.get(sid) !== generation)
36583
36950
  return;
36584
36951
  actions.snapshotApplied(snapshot);
36952
+ transcript.reconcile(snapshot.messages, snapshot.runningTurnId);
36585
36953
  for (const entry2 of promptHistoryFromMessages(snapshot.messages)) {
36586
36954
  actions.promptHistoryAdd(entry2, "session");
36587
36955
  }
@@ -36611,12 +36979,16 @@ function TuiStoreProvider(props) {
36611
36979
  return;
36612
36980
  if (sessionId === store.activeSessionId)
36613
36981
  return;
36982
+ transcript.reset();
36614
36983
  actions.activeSessionSet(sessionId);
36615
36984
  const pendingSubmission = promptSubmissions.get(sessionId);
36616
36985
  if (pendingSubmission)
36617
36986
  pendingSubmission.generation = actions.promptSubmissionStarted();
36618
36987
  props.onActiveSessionChange?.(sessionId);
36619
36988
  port.setActiveSession(sessionId);
36989
+ const runningTurnId = port.getRunningTurnId?.(sessionId);
36990
+ if (runningTurnId)
36991
+ transcript.beginTurn(runningTurnId);
36620
36992
  try {
36621
36993
  await requestSnapshotRefresh(sessionId);
36622
36994
  } catch (error) {
@@ -37113,9 +37485,11 @@ function TuiStoreProvider(props) {
37113
37485
  setStatusDetail,
37114
37486
  refreshSnapshot: requestSnapshotRefresh,
37115
37487
  refreshSessions,
37116
- onSnapshot: () => {
37117
- return;
37118
- }
37488
+ onSnapshot: (snapshot) => transcript.reconcile(snapshot.messages, snapshot.runningTurnId),
37489
+ onTurnStarted: (turnId) => transcript.beginTurn(turnId),
37490
+ onTurnFinished: (turnId) => transcript.finishTurn(turnId),
37491
+ onStreamText: (partId, text, turnId) => transcript.updateText(partId, text, turnId),
37492
+ onStreamReasoning: (partId, rationale, turnId) => transcript.updateReasoning(partId, rationale, turnId)
37119
37493
  }, (error) => {
37120
37494
  if (!disposed)
37121
37495
  actions.errorSet(error instanceof Error ? error.message : String(error));
@@ -37123,8 +37497,9 @@ function TuiStoreProvider(props) {
37123
37497
  const off = port.event.on((event) => {
37124
37498
  if (disposed)
37125
37499
  return;
37126
- if (event.type === "store.changed" || event.type === "store.batch")
37500
+ if (event.type === "store.changed" || event.type === "store.batch" || event.type === "turn.started") {
37127
37501
  invalidateSnapshot(event.sessionId);
37502
+ }
37128
37503
  eventDispatcher.dispatch(event);
37129
37504
  });
37130
37505
  onCleanup(() => {
@@ -37135,6 +37510,7 @@ function TuiStoreProvider(props) {
37135
37510
  mcpOverlayGeneration += 1;
37136
37511
  off();
37137
37512
  eventDispatcher.dispose();
37513
+ transcript.dispose();
37138
37514
  if (statusTimer)
37139
37515
  clearTimeout(statusTimer);
37140
37516
  });
@@ -37180,6 +37556,7 @@ function TuiStoreProvider(props) {
37180
37556
  store,
37181
37557
  actions,
37182
37558
  timelineRows,
37559
+ transcript,
37183
37560
  submitPrompt,
37184
37561
  submitUserInput,
37185
37562
  answerUserInputQuestion,
@@ -37264,7 +37641,8 @@ var init_store4 = __esm(() => {
37264
37641
  init_solid();
37265
37642
  init_store3();
37266
37643
  init_runtime2();
37267
- init_renderers2();
37644
+ init_stream_engine();
37645
+ init_projection();
37268
37646
  StoreContext = createContext();
37269
37647
  });
37270
37648
 
@@ -38398,6 +38776,18 @@ function routeSlash(key) {
38398
38776
  }
38399
38777
  }
38400
38778
  function routeBase(key, ctx) {
38779
+ if (key.meta) {
38780
+ if (key.name === "1")
38781
+ return consumed({
38782
+ kind: "mainTab.set",
38783
+ tab: "chat"
38784
+ });
38785
+ if (key.name === "2")
38786
+ return consumed({
38787
+ kind: "mainTab.set",
38788
+ tab: "proxy"
38789
+ });
38790
+ }
38401
38791
  if (key.ctrl) {
38402
38792
  switch (key.name) {
38403
38793
  case "1":
@@ -39846,7 +40236,10 @@ function KeyboardController() {
39846
40236
  for (const message of [...tui.store.snapshot.messages].reverse()) {
39847
40237
  if (message.role !== "assistant")
39848
40238
  continue;
39849
- const parts = message.parts.map((part) => {
40239
+ const parts = message.parts.filter((part) => part.type === "text").map((part) => {
40240
+ const streamed = tui.transcript.state.text[part.id]?.content;
40241
+ if (streamed !== undefined)
40242
+ return streamed;
39850
40243
  if (typeof part.payload === "string")
39851
40244
  return part.payload;
39852
40245
  if (part.payload && typeof part.payload === "object" && "text" in part.payload) {
@@ -40044,10 +40437,8 @@ function args(value) {
40044
40437
 
40045
40438
  // src/agent-tui/transcript/cells/user-cell.tsx
40046
40439
  function UserPrompt(props) {
40047
- const dims = useTerminalDimensions();
40048
40440
  const lines = createMemo(() => stripOuterBlankLines2(sanitizeText2(props.row.text)).split(`
40049
40441
  `));
40050
- const width = () => Math.max(1, dims().width);
40051
40442
  return (() => {
40052
40443
  var _el$ = createElement("box");
40053
40444
  insert(_el$, createComponent2(For, {
@@ -40062,7 +40453,8 @@ function UserPrompt(props) {
40062
40453
  insert(_el$4, line || " ");
40063
40454
  effect((_p$) => {
40064
40455
  var _v$ = {
40065
- width: width(),
40456
+ width: "100%",
40457
+ minWidth: 0,
40066
40458
  flexDirection: "row",
40067
40459
  backgroundColor: COLOR.userMessageBg
40068
40460
  }, _v$2 = index() === 0 ? COLOR.accent : COLOR.dim, _v$3 = COLOR.text;
@@ -40079,7 +40471,8 @@ function UserPrompt(props) {
40079
40471
  })()
40080
40472
  }));
40081
40473
  effect((_$p) => setProp(_el$, "style", {
40082
- width: width(),
40474
+ width: "100%",
40475
+ minWidth: 0,
40083
40476
  flexDirection: "column",
40084
40477
  marginTop: 1,
40085
40478
  marginBottom: 1,
@@ -40099,7 +40492,6 @@ var init_user_cell = __esm(() => {
40099
40492
  init_solid2();
40100
40493
  init_solid2();
40101
40494
  init_solid();
40102
- init_solid2();
40103
40495
  init_theme();
40104
40496
  });
40105
40497
 
@@ -40244,11 +40636,13 @@ function AssistantMessage(props) {
40244
40636
  insertNode(_el$, _el$2);
40245
40637
  setProp(_el$, "style", {
40246
40638
  flexDirection: "column",
40639
+ flexShrink: 0,
40247
40640
  marginBottom: 1
40248
40641
  });
40249
40642
  insertNode(_el$2, _el$3);
40250
40643
  setProp(_el$2, "style", {
40251
40644
  flexDirection: "row",
40645
+ flexShrink: 0,
40252
40646
  minWidth: 0
40253
40647
  });
40254
40648
  insert(_el$2, createComponent2(TranscriptMarker, {
@@ -40264,23 +40658,23 @@ function AssistantMessage(props) {
40264
40658
  minWidth: 0
40265
40659
  });
40266
40660
  setProp(_el$4, "width", "100%");
40661
+ setProp(_el$4, "streaming", true);
40662
+ setProp(_el$4, "internalBlockMode", "top-level");
40267
40663
  setProp(_el$4, "tableOptions", {
40268
40664
  style: "columns",
40269
40665
  widthMode: "content",
40270
40666
  cellPaddingX: 1
40271
40667
  });
40272
40668
  effect((_p$) => {
40273
- var _v$ = props.row.text, _v$2 = props.row.streaming, _v$3 = syntax(), _v$4 = COLOR.markdownText;
40669
+ var _v$ = props.streamedText ?? props.row.text, _v$2 = syntax(), _v$3 = COLOR.markdownText;
40274
40670
  _v$ !== _p$.e && (_p$.e = setProp(_el$4, "content", _v$, _p$.e));
40275
- _v$2 !== _p$.t && (_p$.t = setProp(_el$4, "streaming", _v$2, _p$.t));
40276
- _v$3 !== _p$.a && (_p$.a = setProp(_el$4, "syntaxStyle", _v$3, _p$.a));
40277
- _v$4 !== _p$.o && (_p$.o = setProp(_el$4, "fg", _v$4, _p$.o));
40671
+ _v$2 !== _p$.t && (_p$.t = setProp(_el$4, "syntaxStyle", _v$2, _p$.t));
40672
+ _v$3 !== _p$.a && (_p$.a = setProp(_el$4, "fg", _v$3, _p$.a));
40278
40673
  return _p$;
40279
40674
  }, {
40280
40675
  e: undefined,
40281
40676
  t: undefined,
40282
- a: undefined,
40283
- o: undefined
40677
+ a: undefined
40284
40678
  });
40285
40679
  return _el$;
40286
40680
  })();
@@ -40359,18 +40753,24 @@ function ReasoningRow(props) {
40359
40753
  const tui = useTuiStore();
40360
40754
  const dims = useTerminalDimensions();
40361
40755
  const expanded = () => Boolean(tui.store.ui.expandedCells[props.row.id]);
40362
- const label = () => truncateLine2(props.row.title === "reasoning" ? "thinking" : props.row.title, Math.max(1, dims().width - 4));
40756
+ const content = createMemo(() => props.streamedReasoning === undefined ? {
40757
+ title: props.row.title,
40758
+ body: props.row.body
40759
+ } : parseReasoning(props.streamedReasoning));
40760
+ const label = () => truncateLine2(content().title === "reasoning" ? "thinking" : content().title, Math.max(1, dims().width - 4));
40363
40761
  const toggleClick = createPrimaryClickGesture(() => tui.actions.cellExpandedToggle(props.row.id));
40364
40762
  return (() => {
40365
40763
  var _el$ = createElement("box"), _el$2 = createElement("box"), _el$3 = createElement("text");
40366
40764
  insertNode(_el$, _el$2);
40367
40765
  setProp(_el$, "style", {
40368
40766
  flexDirection: "column",
40767
+ flexShrink: 0,
40369
40768
  marginBottom: 1
40370
40769
  });
40371
40770
  insertNode(_el$2, _el$3);
40372
40771
  setProp(_el$2, "style", {
40373
- flexDirection: "row"
40772
+ flexDirection: "row",
40773
+ flexShrink: 0
40374
40774
  });
40375
40775
  spread(_el$2, toggleClick, true);
40376
40776
  insert(_el$2, createComponent2(TranscriptMarker, {
@@ -40384,24 +40784,24 @@ function ReasoningRow(props) {
40384
40784
  insert(_el$3, label);
40385
40785
  insert(_el$, createComponent2(Show, {
40386
40786
  get when() {
40387
- return memo2(() => !!expanded())() && props.row.body.trim();
40787
+ return memo2(() => !!expanded())() && content().body.trim();
40388
40788
  },
40389
40789
  get children() {
40390
40790
  return createComponent2(ExpandedPanel, {
40391
40791
  get children() {
40392
40792
  var _el$4 = createElement("markdown");
40793
+ setProp(_el$4, "streaming", true);
40794
+ setProp(_el$4, "internalBlockMode", "top-level");
40393
40795
  effect((_p$) => {
40394
- var _v$ = props.row.body, _v$2 = props.row.streaming, _v$3 = syntax(), _v$4 = COLOR.dim;
40796
+ var _v$ = content().body, _v$2 = syntax(), _v$3 = COLOR.dim;
40395
40797
  _v$ !== _p$.e && (_p$.e = setProp(_el$4, "content", _v$, _p$.e));
40396
- _v$2 !== _p$.t && (_p$.t = setProp(_el$4, "streaming", _v$2, _p$.t));
40397
- _v$3 !== _p$.a && (_p$.a = setProp(_el$4, "syntaxStyle", _v$3, _p$.a));
40398
- _v$4 !== _p$.o && (_p$.o = setProp(_el$4, "fg", _v$4, _p$.o));
40798
+ _v$2 !== _p$.t && (_p$.t = setProp(_el$4, "syntaxStyle", _v$2, _p$.t));
40799
+ _v$3 !== _p$.a && (_p$.a = setProp(_el$4, "fg", _v$3, _p$.a));
40399
40800
  return _p$;
40400
40801
  }, {
40401
40802
  e: undefined,
40402
40803
  t: undefined,
40403
- a: undefined,
40404
- o: undefined
40804
+ a: undefined
40405
40805
  });
40406
40806
  return _el$4;
40407
40807
  }
@@ -40430,6 +40830,7 @@ var init_reasoning_cell = __esm(() => {
40430
40830
  init_expanded_panel();
40431
40831
  init_transcript_marker();
40432
40832
  init_mouse();
40833
+ init_reasoning();
40433
40834
  });
40434
40835
 
40435
40836
  // src/agent-tui/filetype.ts
@@ -42094,12 +42495,18 @@ function FaraiRow(props) {
42094
42495
  return createComponent2(AssistantMessage, {
42095
42496
  get row() {
42096
42497
  return props.row;
42498
+ },
42499
+ get streamedText() {
42500
+ return props.streamedText;
42097
42501
  }
42098
42502
  });
42099
42503
  case "thinking":
42100
42504
  return createComponent2(ReasoningRow, {
42101
42505
  get row() {
42102
42506
  return props.row;
42507
+ },
42508
+ get streamedReasoning() {
42509
+ return props.streamedReasoning;
42103
42510
  }
42104
42511
  });
42105
42512
  case "tool":
@@ -42225,7 +42632,16 @@ function Transcript() {
42225
42632
  byId
42226
42633
  };
42227
42634
  });
42228
- const rawRows = createMemo(() => tui.store.snapshot.messages.flatMap((message) => message.parts.map((part) => `${message.role}.${part.type} ${formatPayload(part.payload, 16000)}`)));
42635
+ const rawRows = createMemo(() => tui.store.snapshot.messages.flatMap((message) => message.parts.map((part) => {
42636
+ const streamText = tui.transcript.state.text[part.id]?.content;
42637
+ const streamReasoning = tui.transcript.state.reasoning[part.id]?.content;
42638
+ const payload = streamText !== undefined ? {
42639
+ text: streamText
42640
+ } : streamReasoning !== undefined ? {
42641
+ rationale: streamReasoning
42642
+ } : part.payload;
42643
+ return `${message.role}.${part.type} ${formatPayload(payload, 16000)}`;
42644
+ })));
42229
42645
  createEffect(() => {
42230
42646
  const request = tui.store.ui.messageNavigation;
42231
42647
  const userIds = transcriptRows().filter((row) => row.kind === "user").map((row) => row.id);
@@ -42242,6 +42658,7 @@ function Transcript() {
42242
42658
  typeof _ref$ === "function" ? use(_ref$, _el$) : scrollRef = _el$;
42243
42659
  setProp(_el$, "stickyScroll", true);
42244
42660
  setProp(_el$, "stickyStart", "bottom");
42661
+ setProp(_el$, "viewportCulling", true);
42245
42662
  setProp(_el$, "scrollbarOptions", {
42246
42663
  visible: false
42247
42664
  });
@@ -42307,6 +42724,12 @@ function Transcript() {
42307
42724
  children: (id2) => createComponent2(TranscriptRow, {
42308
42725
  get row() {
42309
42726
  return indexedRows().byId.get(id2);
42727
+ },
42728
+ get streamedText() {
42729
+ return tui.transcript.state.text[id2]?.content;
42730
+ },
42731
+ get streamedReasoning() {
42732
+ return tui.transcript.state.reasoning[id2]?.content;
42310
42733
  }
42311
42734
  })
42312
42735
  });
@@ -42422,12 +42845,19 @@ function TranscriptRow(props) {
42422
42845
  var _el$1 = createElement("box");
42423
42846
  setProp(_el$1, "style", {
42424
42847
  flexDirection: "column",
42848
+ flexShrink: 0,
42425
42849
  paddingLeft: isUser ? 0 : 1,
42426
42850
  paddingRight: isUser ? 0 : 1
42427
42851
  });
42428
42852
  insert(_el$1, createComponent2(FaraiRow, {
42429
42853
  get row() {
42430
42854
  return props.row;
42855
+ },
42856
+ get streamedText() {
42857
+ return props.streamedText;
42858
+ },
42859
+ get streamedReasoning() {
42860
+ return props.streamedReasoning;
42431
42861
  }
42432
42862
  }));
42433
42863
  effect((_$p) => setProp(_el$1, "id", props.row.id, _$p));
@@ -42456,6 +42886,7 @@ var init_transcript = __esm(() => {
42456
42886
  // src/agent-tui/surfaces/center-surface.tsx
42457
42887
  function CenterSurfaceView(props) {
42458
42888
  const tui = useTuiStore();
42889
+ const dims = useTerminalDimensions();
42459
42890
  const loader = createSurfaceLoader(() => props.frame);
42460
42891
  const title = () => surfaceTitle(props.frame);
42461
42892
  const kindLabel = () => props.frame.kind;
@@ -42497,13 +42928,13 @@ function CenterSurfaceView(props) {
42497
42928
  minWidth: 0
42498
42929
  });
42499
42930
  insertNode(_el$4, createTextNode(`\u203A `));
42500
- insert(_el$6, () => truncateLine2(title(), 96));
42931
+ insert(_el$6, () => truncateLine2(title(), Math.max(4, dims().width - terminalWidth(kindLabel()) - 10)));
42501
42932
  insert(_el$7, kindLabel);
42502
42933
  insertNode(_el$8, _el$9);
42503
42934
  setProp(_el$8, "style", {
42504
42935
  height: 1
42505
42936
  });
42506
- insert(_el$9, () => surfaceSubtitle(props.frame));
42937
+ insert(_el$9, () => truncateLine2(surfaceSubtitle(props.frame), Math.max(1, dims().width - 4)));
42507
42938
  insert(_el$, createComponent2(Show, {
42508
42939
  get when() {
42509
42940
  return props.frame.kind === "proxy_flow";
@@ -42797,7 +43228,7 @@ function WebSocketFlowView(props) {
42797
43228
  let lastScrollSequence = 0;
42798
43229
  const selectedIndex = createMemo(() => Math.min(Math.max(0, tui.store.ui.proxyWebSocketMessageIndex), Math.max(0, props.flow.messages.length - 1)));
42799
43230
  const selectedMessage = createMemo(() => props.flow.messages[selectedIndex()]);
42800
- const contentWidth = () => Math.max(36, dims().width - (props.compact ? 4 : 8));
43231
+ const contentWidth = () => Math.max(1, dims().width - (props.compact ? 4 : 8));
42801
43232
  const inspectorGap = () => dims().height >= 22 ? 1 : 0;
42802
43233
  createEffect(() => {
42803
43234
  const flowId = props.flow.id;
@@ -43470,7 +43901,8 @@ function ProxyLogView() {
43470
43901
  });
43471
43902
  const defaultListHeight = () => Math.max(7, Math.min(14, Math.floor(dims().height * 0.34)));
43472
43903
  const listHeight = () => clampProxyListHeight(listHeightOverride() ?? defaultListHeight(), dims().height);
43473
- const tableWidth = () => Math.max(30, dims().width - 4);
43904
+ const compactHeight = () => dims().height < 20;
43905
+ const tableWidth = () => Math.max(1, dims().width - 4);
43474
43906
  const beginListResize = (event) => {
43475
43907
  if (event.button !== 0)
43476
43908
  return;
@@ -43578,22 +44010,9 @@ function ProxyLogView() {
43578
44010
  });
43579
44011
  });
43580
44012
  return (() => {
43581
- var _el$ = createElement("box"), _el$2 = createElement("box"), _el$3 = createElement("text"), _el$5 = createElement("box"), _el$6 = createElement("box"), _el$7 = createElement("text"), _el$8 = createElement("scrollbox"), _el$9 = createElement("box"), _el$0 = createElement("text"), _el$1 = createElement("text"), _el$10 = createElement("box"), _el$11 = createElement("text"), _el$12 = createElement("box");
44013
+ var _el$ = createElement("box"), _el$2 = createElement("box"), _el$3 = createElement("text"), _el$5 = createElement("box"), _el$6 = createElement("box"), _el$7 = createElement("text"), _el$8 = createElement("scrollbox");
43582
44014
  insertNode(_el$, _el$2);
43583
44015
  insertNode(_el$, _el$5);
43584
- insertNode(_el$, _el$9);
43585
- insertNode(_el$, _el$10);
43586
- insertNode(_el$, _el$12);
43587
- setProp(_el$, "style", {
43588
- flexGrow: 1,
43589
- flexShrink: 1,
43590
- minHeight: 0,
43591
- flexDirection: "column",
43592
- paddingTop: 1,
43593
- paddingBottom: 1,
43594
- paddingLeft: 2,
43595
- paddingRight: 2
43596
- });
43597
44016
  setProp(_el$, "onMouseDrag", resizeList);
43598
44017
  setProp(_el$, "onMouseDragEnd", finishListResize);
43599
44018
  setProp(_el$, "onMouseUp", finishListResize);
@@ -43650,8 +44069,8 @@ function ProxyLogView() {
43650
44069
  flexDirection: "column",
43651
44070
  marginTop: 1
43652
44071
  });
43653
- insert(_el$14, () => `no ${tui.store.ui.proxyFilter === "all" ? "captured proxy" : tui.store.ui.proxyFilter} flows yet`);
43654
- insert(_el$15, () => proxyHint().toLowerCase());
44072
+ insert(_el$14, () => truncate2(`no ${tui.store.ui.proxyFilter === "all" ? "captured proxy" : tui.store.ui.proxyFilter} flows yet`, tableWidth()));
44073
+ insert(_el$15, () => truncate2(proxyHint().toLowerCase(), tableWidth()));
43655
44074
  effect((_p$) => {
43656
44075
  var _v$7 = COLOR.dim, _v$8 = COLOR.dim;
43657
44076
  _v$7 !== _p$.e && (_p$.e = setProp(_el$14, "fg", _v$7, _p$.e));
@@ -43700,103 +44119,140 @@ function ProxyLogView() {
43700
44119
  });
43701
44120
  }
43702
44121
  }));
43703
- insertNode(_el$9, _el$0);
43704
- insertNode(_el$9, _el$1);
43705
- setProp(_el$9, "style", {
43706
- height: 1,
43707
- flexShrink: 0,
43708
- flexDirection: "row",
43709
- justifyContent: "space-between",
43710
- marginTop: 1
43711
- });
43712
- insert(_el$0, () => truncate2(selectedFlow() && selectedPresentation() ? `${selectedPresentation().kind} \xB7 ${selectedPresentation().method} ${selectedFlow().url}` : "no flow selected", Math.max(8, tableWidth() - 20)));
43713
- insert(_el$1, () => truncate2(detailLoading() ? "loading detail" : detailError() ?? "", 18));
43714
- insertNode(_el$10, _el$11);
43715
- setProp(_el$10, "style", {
43716
- height: 1,
43717
- flexShrink: 0,
43718
- alignItems: "center",
43719
- justifyContent: "flex-start"
43720
- });
43721
- setProp(_el$10, "onMouseDown", beginListResize);
43722
- setProp(_el$11, "selectable", false);
43723
- insert(_el$11, () => "\u2500".repeat(Math.max(1, dims().width - 4)));
43724
- setProp(_el$12, "style", {
43725
- flexGrow: 1,
43726
- minHeight: 0,
43727
- flexDirection: "column",
43728
- paddingTop: 1
43729
- });
43730
- insert(_el$12, createComponent2(Show, {
44122
+ insert(_el$, createComponent2(Show, {
43731
44123
  get when() {
43732
- return detail();
44124
+ return !compactHeight();
43733
44125
  },
43734
- get fallback() {
43735
- return (() => {
43736
- var _el$17 = createElement("box"), _el$18 = createElement("text");
43737
- insertNode(_el$17, _el$18);
43738
- setProp(_el$17, "style", {
43739
- flexDirection: "column"
44126
+ get children() {
44127
+ return [(() => {
44128
+ var _el$9 = createElement("box"), _el$0 = createElement("text"), _el$1 = createElement("text");
44129
+ insertNode(_el$9, _el$0);
44130
+ insertNode(_el$9, _el$1);
44131
+ setProp(_el$9, "style", {
44132
+ height: 1,
44133
+ flexShrink: 0,
44134
+ flexDirection: "row",
44135
+ justifyContent: "space-between",
44136
+ marginTop: 1
43740
44137
  });
43741
- insertNode(_el$18, createTextNode(`select a flow to inspect protocol-aware details`));
43742
- effect((_$p) => setProp(_el$18, "fg", COLOR.dim, _$p));
43743
- return _el$17;
43744
- })();
43745
- },
43746
- children: (flow) => (() => {
43747
- var _el$20 = createElement("box");
43748
- setProp(_el$20, "style", {
43749
- flexGrow: 1,
43750
- minHeight: 0,
43751
- flexDirection: "column"
43752
- });
43753
- insert(_el$20, createComponent2(Show, {
43754
- get when() {
43755
- return isSummaryOnly(flow());
43756
- },
43757
- get children() {
43758
- var _el$21 = createElement("box"), _el$22 = createElement("text");
43759
- insertNode(_el$21, _el$22);
43760
- setProp(_el$21, "style", {
43761
- height: 1,
43762
- flexShrink: 0,
43763
- marginBottom: 1
43764
- });
43765
- insertNode(_el$22, createTextNode(`full body unavailable; showing captured metadata`));
43766
- effect((_$p) => setProp(_el$22, "fg", COLOR.warning, _$p));
43767
- return _el$21;
43768
- }
43769
- }), null);
43770
- insert(_el$20, createComponent2(ProxyFlowSplitView, {
43771
- get flow() {
43772
- return flow();
43773
- },
43774
- compact: true
43775
- }), null);
43776
- return _el$20;
43777
- })()
43778
- }));
44138
+ insert(_el$0, () => truncate2(selectedFlow() && selectedPresentation() ? `${selectedPresentation().kind} \xB7 ${selectedPresentation().method} ${selectedFlow().url}` : "no flow selected", Math.max(8, tableWidth() - 20)));
44139
+ insert(_el$1, () => truncate2(detailLoading() ? "loading detail" : detailError() ?? "", 18));
44140
+ effect((_p$) => {
44141
+ var _v$ = COLOR.dim, _v$2 = detailLoading() ? COLOR.accent : detailError() ? COLOR.error : COLOR.dim;
44142
+ _v$ !== _p$.e && (_p$.e = setProp(_el$0, "fg", _v$, _p$.e));
44143
+ _v$2 !== _p$.t && (_p$.t = setProp(_el$1, "fg", _v$2, _p$.t));
44144
+ return _p$;
44145
+ }, {
44146
+ e: undefined,
44147
+ t: undefined
44148
+ });
44149
+ return _el$9;
44150
+ })(), (() => {
44151
+ var _el$10 = createElement("box"), _el$11 = createElement("text");
44152
+ insertNode(_el$10, _el$11);
44153
+ setProp(_el$10, "style", {
44154
+ height: 1,
44155
+ flexShrink: 0,
44156
+ alignItems: "center",
44157
+ justifyContent: "flex-start"
44158
+ });
44159
+ setProp(_el$10, "onMouseDown", beginListResize);
44160
+ setProp(_el$11, "selectable", false);
44161
+ insert(_el$11, () => "\u2500".repeat(Math.max(1, dims().width - 4)));
44162
+ effect((_$p) => setProp(_el$11, "fg", dividerDragging() ? COLOR.accent : COLOR.border, _$p));
44163
+ return _el$10;
44164
+ })(), (() => {
44165
+ var _el$12 = createElement("box");
44166
+ setProp(_el$12, "style", {
44167
+ flexGrow: 1,
44168
+ minHeight: 0,
44169
+ flexDirection: "column",
44170
+ paddingTop: 1
44171
+ });
44172
+ insert(_el$12, createComponent2(Show, {
44173
+ get when() {
44174
+ return detail();
44175
+ },
44176
+ get fallback() {
44177
+ return (() => {
44178
+ var _el$17 = createElement("box"), _el$18 = createElement("text");
44179
+ insertNode(_el$17, _el$18);
44180
+ setProp(_el$17, "style", {
44181
+ flexDirection: "column"
44182
+ });
44183
+ insertNode(_el$18, createTextNode(`select a flow to inspect protocol-aware details`));
44184
+ effect((_$p) => setProp(_el$18, "fg", COLOR.dim, _$p));
44185
+ return _el$17;
44186
+ })();
44187
+ },
44188
+ children: (flow) => (() => {
44189
+ var _el$20 = createElement("box");
44190
+ setProp(_el$20, "style", {
44191
+ flexGrow: 1,
44192
+ minHeight: 0,
44193
+ flexDirection: "column"
44194
+ });
44195
+ insert(_el$20, createComponent2(Show, {
44196
+ get when() {
44197
+ return isSummaryOnly(flow());
44198
+ },
44199
+ get children() {
44200
+ var _el$21 = createElement("box"), _el$22 = createElement("text");
44201
+ insertNode(_el$21, _el$22);
44202
+ setProp(_el$21, "style", {
44203
+ height: 1,
44204
+ flexShrink: 0,
44205
+ marginBottom: 1
44206
+ });
44207
+ insertNode(_el$22, createTextNode(`full body unavailable; showing captured metadata`));
44208
+ effect((_$p) => setProp(_el$22, "fg", COLOR.warning, _$p));
44209
+ return _el$21;
44210
+ }
44211
+ }), null);
44212
+ insert(_el$20, createComponent2(ProxyFlowSplitView, {
44213
+ get flow() {
44214
+ return flow();
44215
+ },
44216
+ compact: true
44217
+ }), null);
44218
+ return _el$20;
44219
+ })()
44220
+ }));
44221
+ return _el$12;
44222
+ })()];
44223
+ }
44224
+ }), null);
43779
44225
  effect((_p$) => {
43780
- var _v$ = COLOR.text, _v$2 = {
44226
+ var _v$3 = {
44227
+ flexGrow: 1,
44228
+ flexShrink: 1,
44229
+ minHeight: 0,
44230
+ flexDirection: "column",
44231
+ paddingTop: compactHeight() ? 0 : 1,
44232
+ paddingBottom: compactHeight() ? 0 : 1,
44233
+ paddingLeft: 2,
44234
+ paddingRight: 2
44235
+ }, _v$4 = COLOR.text, _v$5 = compactHeight() ? {
44236
+ flexGrow: 1,
44237
+ flexShrink: 1,
44238
+ minHeight: 0,
44239
+ flexDirection: "column"
44240
+ } : {
43781
44241
  height: listHeight(),
43782
44242
  flexShrink: 0,
43783
44243
  flexDirection: "column",
43784
44244
  marginTop: 1
43785
- }, _v$3 = COLOR.dim, _v$4 = COLOR.dim, _v$5 = detailLoading() ? COLOR.accent : detailError() ? COLOR.error : COLOR.dim, _v$6 = dividerDragging() ? COLOR.accent : COLOR.border;
43786
- _v$ !== _p$.e && (_p$.e = setProp(_el$3, "fg", _v$, _p$.e));
43787
- _v$2 !== _p$.t && (_p$.t = setProp(_el$5, "style", _v$2, _p$.t));
43788
- _v$3 !== _p$.a && (_p$.a = setProp(_el$7, "fg", _v$3, _p$.a));
43789
- _v$4 !== _p$.o && (_p$.o = setProp(_el$0, "fg", _v$4, _p$.o));
43790
- _v$5 !== _p$.i && (_p$.i = setProp(_el$1, "fg", _v$5, _p$.i));
43791
- _v$6 !== _p$.n && (_p$.n = setProp(_el$11, "fg", _v$6, _p$.n));
44245
+ }, _v$6 = COLOR.dim;
44246
+ _v$3 !== _p$.e && (_p$.e = setProp(_el$, "style", _v$3, _p$.e));
44247
+ _v$4 !== _p$.t && (_p$.t = setProp(_el$3, "fg", _v$4, _p$.t));
44248
+ _v$5 !== _p$.a && (_p$.a = setProp(_el$5, "style", _v$5, _p$.a));
44249
+ _v$6 !== _p$.o && (_p$.o = setProp(_el$7, "fg", _v$6, _p$.o));
43792
44250
  return _p$;
43793
44251
  }, {
43794
44252
  e: undefined,
43795
44253
  t: undefined,
43796
44254
  a: undefined,
43797
- o: undefined,
43798
- i: undefined,
43799
- n: undefined
44255
+ o: undefined
43800
44256
  });
43801
44257
  return _el$;
43802
44258
  })();
@@ -43931,6 +44387,9 @@ function isSummaryOnly(flow) {
43931
44387
  return !flow.response && flow.answerCount > 0;
43932
44388
  }
43933
44389
  function proxyHeaderLine(width) {
44390
+ if (width < 38) {
44391
+ return truncate2([pad("", 2), pad("method", 8), "host / path"].join(""), width);
44392
+ }
43934
44393
  if (width < 96) {
43935
44394
  return truncate2([pad("", 2), pad("proto", 7), pad("method", 8), pad("sts", 5), "host / path"].join(""), width);
43936
44395
  }
@@ -43950,10 +44409,11 @@ function proxyFlowTablePresentation(flow, filter) {
43950
44409
  function ProxyRow(props) {
43951
44410
  const pathWidth = () => Math.max(18, props.width - 98);
43952
44411
  const compactTarget = () => truncate2(`${props.flow.host}${props.flow.path || "/"}`, Math.max(8, props.width - 22));
44412
+ const narrowTarget = () => truncate2(`${props.flow.host}${props.flow.path || "/"}`, Math.max(1, props.width - 10));
43953
44413
  const presentation = () => proxyFlowTablePresentation(props.flow, props.filter);
43954
44414
  return createComponent2(Show, {
43955
44415
  get when() {
43956
- return props.width >= 96;
44416
+ return props.width >= 38;
43957
44417
  },
43958
44418
  get fallback() {
43959
44419
  return [(() => {
@@ -43965,91 +44425,119 @@ function ProxyRow(props) {
43965
44425
  })(), (() => {
43966
44426
  var _el$38 = createElement("text");
43967
44427
  setProp(_el$38, "selectable", false);
43968
- insert(_el$38, () => pad(presentation().kind, 7));
43969
- effect((_$p) => setProp(_el$38, "fg", COLOR.dim, _$p));
44428
+ insert(_el$38, () => pad(presentation().method, 8));
44429
+ effect((_$p) => setProp(_el$38, "fg", methodColor(presentation().method), _$p));
43970
44430
  return _el$38;
43971
44431
  })(), (() => {
43972
44432
  var _el$39 = createElement("text");
43973
44433
  setProp(_el$39, "selectable", false);
43974
- insert(_el$39, () => pad(presentation().method, 8));
43975
- effect((_$p) => setProp(_el$39, "fg", methodColor(presentation().method), _$p));
44434
+ insert(_el$39, narrowTarget);
44435
+ effect((_$p) => setProp(_el$39, "fg", props.selected ? COLOR.accent : COLOR.text, _$p));
43976
44436
  return _el$39;
43977
- })(), (() => {
43978
- var _el$40 = createElement("text");
43979
- setProp(_el$40, "selectable", false);
43980
- insert(_el$40, () => pad(String(props.flow.status ?? "-"), 5));
43981
- effect((_$p) => setProp(_el$40, "fg", statusColor(props.flow.status), _$p));
43982
- return _el$40;
43983
- })(), (() => {
43984
- var _el$41 = createElement("text");
43985
- setProp(_el$41, "selectable", false);
43986
- insert(_el$41, compactTarget);
43987
- effect((_$p) => setProp(_el$41, "fg", props.selected ? COLOR.accent : COLOR.text, _$p));
43988
- return _el$41;
43989
44437
  })()];
43990
44438
  },
43991
44439
  get children() {
43992
- return [(() => {
43993
- var _el$27 = createElement("text");
43994
- setProp(_el$27, "selectable", false);
43995
- insert(_el$27, () => pad(props.selected ? ">" : "", 2));
43996
- effect((_$p) => setProp(_el$27, "fg", props.selected ? COLOR.accent : COLOR.dim, _$p));
43997
- return _el$27;
43998
- })(), (() => {
43999
- var _el$28 = createElement("text");
44000
- setProp(_el$28, "selectable", false);
44001
- insert(_el$28, () => pad(shortTime(props.flow.timestamp), 9));
44002
- effect((_$p) => setProp(_el$28, "fg", COLOR.dim, _$p));
44003
- return _el$28;
44004
- })(), (() => {
44005
- var _el$29 = createElement("text");
44006
- setProp(_el$29, "selectable", false);
44007
- insert(_el$29, () => pad(presentation().kind, 7));
44008
- effect((_$p) => setProp(_el$29, "fg", COLOR.dim, _$p));
44009
- return _el$29;
44010
- })(), (() => {
44011
- var _el$30 = createElement("text");
44012
- setProp(_el$30, "selectable", false);
44013
- insert(_el$30, () => pad(presentation().method, 8));
44014
- effect((_$p) => setProp(_el$30, "fg", methodColor(presentation().method), _$p));
44015
- return _el$30;
44016
- })(), (() => {
44017
- var _el$31 = createElement("text");
44018
- setProp(_el$31, "selectable", false);
44019
- insert(_el$31, () => pad(String(props.flow.status ?? "-"), 5));
44020
- effect((_$p) => setProp(_el$31, "fg", statusColor(props.flow.status), _$p));
44021
- return _el$31;
44022
- })(), (() => {
44023
- var _el$32 = createElement("text");
44024
- setProp(_el$32, "selectable", false);
44025
- insert(_el$32, () => pad(truncate2(props.flow.host, 29), 30));
44026
- effect((_$p) => setProp(_el$32, "fg", props.selected ? COLOR.accent : COLOR.text, _$p));
44027
- return _el$32;
44028
- })(), (() => {
44029
- var _el$33 = createElement("text");
44030
- setProp(_el$33, "selectable", false);
44031
- insert(_el$33, () => pad(truncate2(props.flow.path || "/", pathWidth() - 1), pathWidth()));
44032
- effect((_$p) => setProp(_el$33, "fg", props.selected ? COLOR.accent : COLOR.text, _$p));
44033
- return _el$33;
44034
- })(), (() => {
44035
- var _el$34 = createElement("text");
44036
- setProp(_el$34, "selectable", false);
44037
- insert(_el$34, () => pad(truncate2(normalizeContentType(props.flow.contentType), 15), 16));
44038
- effect((_$p) => setProp(_el$34, "fg", COLOR.dim, _$p));
44039
- return _el$34;
44040
- })(), (() => {
44041
- var _el$35 = createElement("text");
44042
- setProp(_el$35, "selectable", false);
44043
- insert(_el$35, () => pad(formatBytes(props.flow.responseBytes ?? props.flow.requestBytes), 8));
44044
- effect((_$p) => setProp(_el$35, "fg", COLOR.dim, _$p));
44045
- return _el$35;
44046
- })(), (() => {
44047
- var _el$36 = createElement("text");
44048
- setProp(_el$36, "selectable", false);
44049
- insert(_el$36, () => formatDuration(props.flow.durationMs));
44050
- effect((_$p) => setProp(_el$36, "fg", COLOR.dim, _$p));
44051
- return _el$36;
44052
- })()];
44440
+ return createComponent2(Show, {
44441
+ get when() {
44442
+ return props.width >= 96;
44443
+ },
44444
+ get fallback() {
44445
+ return [(() => {
44446
+ var _el$40 = createElement("text");
44447
+ setProp(_el$40, "selectable", false);
44448
+ insert(_el$40, () => pad(props.selected ? ">" : "", 2));
44449
+ effect((_$p) => setProp(_el$40, "fg", props.selected ? COLOR.accent : COLOR.dim, _$p));
44450
+ return _el$40;
44451
+ })(), (() => {
44452
+ var _el$41 = createElement("text");
44453
+ setProp(_el$41, "selectable", false);
44454
+ insert(_el$41, () => pad(presentation().kind, 7));
44455
+ effect((_$p) => setProp(_el$41, "fg", COLOR.dim, _$p));
44456
+ return _el$41;
44457
+ })(), (() => {
44458
+ var _el$42 = createElement("text");
44459
+ setProp(_el$42, "selectable", false);
44460
+ insert(_el$42, () => pad(presentation().method, 8));
44461
+ effect((_$p) => setProp(_el$42, "fg", methodColor(presentation().method), _$p));
44462
+ return _el$42;
44463
+ })(), (() => {
44464
+ var _el$43 = createElement("text");
44465
+ setProp(_el$43, "selectable", false);
44466
+ insert(_el$43, () => pad(String(props.flow.status ?? "-"), 5));
44467
+ effect((_$p) => setProp(_el$43, "fg", statusColor(props.flow.status), _$p));
44468
+ return _el$43;
44469
+ })(), (() => {
44470
+ var _el$44 = createElement("text");
44471
+ setProp(_el$44, "selectable", false);
44472
+ insert(_el$44, compactTarget);
44473
+ effect((_$p) => setProp(_el$44, "fg", props.selected ? COLOR.accent : COLOR.text, _$p));
44474
+ return _el$44;
44475
+ })()];
44476
+ },
44477
+ get children() {
44478
+ return [(() => {
44479
+ var _el$27 = createElement("text");
44480
+ setProp(_el$27, "selectable", false);
44481
+ insert(_el$27, () => pad(props.selected ? ">" : "", 2));
44482
+ effect((_$p) => setProp(_el$27, "fg", props.selected ? COLOR.accent : COLOR.dim, _$p));
44483
+ return _el$27;
44484
+ })(), (() => {
44485
+ var _el$28 = createElement("text");
44486
+ setProp(_el$28, "selectable", false);
44487
+ insert(_el$28, () => pad(shortTime(props.flow.timestamp), 9));
44488
+ effect((_$p) => setProp(_el$28, "fg", COLOR.dim, _$p));
44489
+ return _el$28;
44490
+ })(), (() => {
44491
+ var _el$29 = createElement("text");
44492
+ setProp(_el$29, "selectable", false);
44493
+ insert(_el$29, () => pad(presentation().kind, 7));
44494
+ effect((_$p) => setProp(_el$29, "fg", COLOR.dim, _$p));
44495
+ return _el$29;
44496
+ })(), (() => {
44497
+ var _el$30 = createElement("text");
44498
+ setProp(_el$30, "selectable", false);
44499
+ insert(_el$30, () => pad(presentation().method, 8));
44500
+ effect((_$p) => setProp(_el$30, "fg", methodColor(presentation().method), _$p));
44501
+ return _el$30;
44502
+ })(), (() => {
44503
+ var _el$31 = createElement("text");
44504
+ setProp(_el$31, "selectable", false);
44505
+ insert(_el$31, () => pad(String(props.flow.status ?? "-"), 5));
44506
+ effect((_$p) => setProp(_el$31, "fg", statusColor(props.flow.status), _$p));
44507
+ return _el$31;
44508
+ })(), (() => {
44509
+ var _el$32 = createElement("text");
44510
+ setProp(_el$32, "selectable", false);
44511
+ insert(_el$32, () => pad(truncate2(props.flow.host, 29), 30));
44512
+ effect((_$p) => setProp(_el$32, "fg", props.selected ? COLOR.accent : COLOR.text, _$p));
44513
+ return _el$32;
44514
+ })(), (() => {
44515
+ var _el$33 = createElement("text");
44516
+ setProp(_el$33, "selectable", false);
44517
+ insert(_el$33, () => pad(truncate2(props.flow.path || "/", pathWidth() - 1), pathWidth()));
44518
+ effect((_$p) => setProp(_el$33, "fg", props.selected ? COLOR.accent : COLOR.text, _$p));
44519
+ return _el$33;
44520
+ })(), (() => {
44521
+ var _el$34 = createElement("text");
44522
+ setProp(_el$34, "selectable", false);
44523
+ insert(_el$34, () => pad(truncate2(normalizeContentType(props.flow.contentType), 15), 16));
44524
+ effect((_$p) => setProp(_el$34, "fg", COLOR.dim, _$p));
44525
+ return _el$34;
44526
+ })(), (() => {
44527
+ var _el$35 = createElement("text");
44528
+ setProp(_el$35, "selectable", false);
44529
+ insert(_el$35, () => pad(formatBytes(props.flow.responseBytes ?? props.flow.requestBytes), 8));
44530
+ effect((_$p) => setProp(_el$35, "fg", COLOR.dim, _$p));
44531
+ return _el$35;
44532
+ })(), (() => {
44533
+ var _el$36 = createElement("text");
44534
+ setProp(_el$36, "selectable", false);
44535
+ insert(_el$36, () => formatDuration(props.flow.durationMs));
44536
+ effect((_$p) => setProp(_el$36, "fg", COLOR.dim, _$p));
44537
+ return _el$36;
44538
+ })()];
44539
+ }
44540
+ });
44053
44541
  }
44054
44542
  });
44055
44543
  }
@@ -44219,9 +44707,10 @@ function Composer() {
44219
44707
  const command = () => fitTerminal(option.title, commandWidth());
44220
44708
  const desc = () => truncateLine2(option.description ?? "", descWidth());
44221
44709
  return (() => {
44222
- var _el$9 = createElement("box"), _el$0 = createElement("text"), _el$1 = createElement("text");
44710
+ var _el$9 = createElement("box"), _el$0 = createElement("text"), _el$1 = createElement("text"), _el$10 = createElement("text");
44223
44711
  insertNode(_el$9, _el$0);
44224
44712
  insertNode(_el$9, _el$1);
44713
+ insertNode(_el$9, _el$10);
44225
44714
  setProp(_el$9, "style", {
44226
44715
  flexDirection: "row"
44227
44716
  });
@@ -44233,17 +44722,21 @@ function Composer() {
44233
44722
  composer.focus();
44234
44723
  });
44235
44724
  setProp(_el$0, "selectable", false);
44236
- insert(_el$0, () => ` ${command()}`);
44725
+ insert(_el$0, () => active() ? "\u203A " : " ");
44237
44726
  setProp(_el$1, "selectable", false);
44238
- insert(_el$1, desc);
44727
+ insert(_el$1, command);
44728
+ setProp(_el$10, "selectable", false);
44729
+ insert(_el$10, desc);
44239
44730
  effect((_p$) => {
44240
- var _v$0 = active() ? COLOR.accent : COLOR.text, _v$1 = COLOR.dim;
44731
+ var _v$0 = active() ? COLOR.accent : COLOR.dim, _v$1 = active() ? COLOR.accent : COLOR.text, _v$10 = COLOR.dim;
44241
44732
  _v$0 !== _p$.e && (_p$.e = setProp(_el$0, "fg", _v$0, _p$.e));
44242
44733
  _v$1 !== _p$.t && (_p$.t = setProp(_el$1, "fg", _v$1, _p$.t));
44734
+ _v$10 !== _p$.a && (_p$.a = setProp(_el$10, "fg", _v$10, _p$.a));
44243
44735
  return _p$;
44244
44736
  }, {
44245
44737
  e: undefined,
44246
- t: undefined
44738
+ t: undefined,
44739
+ a: undefined
44247
44740
  });
44248
44741
  return _el$9;
44249
44742
  })();
@@ -44300,6 +44793,7 @@ var init_composer2 = __esm(() => {
44300
44793
  init_solid2();
44301
44794
  init_solid2();
44302
44795
  init_solid2();
44796
+ init_solid2();
44303
44797
  init_solid();
44304
44798
  init_solid2();
44305
44799
  init_store4();
@@ -44687,6 +45181,8 @@ var init_footer = __esm(() => {
44687
45181
  // src/agent-tui/bottom-pane/pending-input-preview.tsx
44688
45182
  function PendingInputPreview() {
44689
45183
  const tui = useTuiStore();
45184
+ const dims = useTerminalDimensions();
45185
+ const contentWidth = () => Math.max(1, dims().width - 4);
44690
45186
  return createComponent2(Show, {
44691
45187
  get when() {
44692
45188
  return tui.store.snapshot.pendingSteers.length > 0 || tui.store.snapshot.queuedPrompts.length > 0;
@@ -44703,7 +45199,10 @@ function PendingInputPreview() {
44703
45199
  get children() {
44704
45200
  return [(() => {
44705
45201
  var _el$2 = createElement("text");
44706
- insertNode(_el$2, createTextNode(`\u2022 steering at the next safe boundary`));
45202
+ insert(_el$2, (() => {
45203
+ var _c$ = memo2(() => dims().width >= 42);
45204
+ return () => _c$() ? "\u2022 steering at the next safe boundary" : `\u2022 ${tui.store.snapshot.pendingSteers.length} steering`;
45205
+ })());
44707
45206
  effect((_$p) => setProp(_el$2, "fg", COLOR.dim, _$p));
44708
45207
  return _el$2;
44709
45208
  })(), createComponent2(For, {
@@ -44711,20 +45210,20 @@ function PendingInputPreview() {
44711
45210
  return tui.store.snapshot.pendingSteers.slice(0, 3);
44712
45211
  },
44713
45212
  children: (item) => (() => {
44714
- var _el$8 = createElement("text");
44715
- insert(_el$8, () => ` \u21B3 ${truncateLine2(item.text.replace(/\s+/g, " "), 110)}`);
44716
- effect((_$p) => setProp(_el$8, "fg", COLOR.dim, _$p));
44717
- return _el$8;
45213
+ var _el$6 = createElement("text");
45214
+ insert(_el$6, () => ` \u21B3 ${truncateLine2(item.text.replace(/\s+/g, " "), contentWidth())}`);
45215
+ effect((_$p) => setProp(_el$6, "fg", COLOR.dim, _$p));
45216
+ return _el$6;
44718
45217
  })()
44719
45218
  }), createComponent2(Show, {
44720
45219
  get when() {
44721
45220
  return tui.store.snapshot.pendingSteers.length > 3;
44722
45221
  },
44723
45222
  get children() {
44724
- var _el$4 = createElement("text");
44725
- insert(_el$4, () => ` \u2026 ${tui.store.snapshot.pendingSteers.length - 3} more`);
44726
- effect((_$p) => setProp(_el$4, "fg", COLOR.dim, _$p));
44727
- return _el$4;
45223
+ var _el$3 = createElement("text");
45224
+ insert(_el$3, () => ` \u2026 ${tui.store.snapshot.pendingSteers.length - 3} more`);
45225
+ effect((_$p) => setProp(_el$3, "fg", COLOR.dim, _$p));
45226
+ return _el$3;
44728
45227
  }
44729
45228
  })];
44730
45229
  }
@@ -44735,29 +45234,32 @@ function PendingInputPreview() {
44735
45234
  },
44736
45235
  get children() {
44737
45236
  return [(() => {
44738
- var _el$5 = createElement("text");
44739
- insertNode(_el$5, createTextNode(`\u2022 queued follow-ups \xB7 \u2191 edit latest`));
44740
- effect((_$p) => setProp(_el$5, "fg", COLOR.dim, _$p));
44741
- return _el$5;
45237
+ var _el$4 = createElement("text");
45238
+ insert(_el$4, (() => {
45239
+ var _c$2 = memo2(() => dims().width >= 42);
45240
+ return () => _c$2() ? "\u2022 queued follow-ups \xB7 \u2191 edit latest" : `\u2022 ${tui.store.snapshot.queuedPrompts.length} queued \xB7 \u2191 edit`;
45241
+ })());
45242
+ effect((_$p) => setProp(_el$4, "fg", COLOR.dim, _$p));
45243
+ return _el$4;
44742
45244
  })(), createComponent2(For, {
44743
45245
  get each() {
44744
45246
  return tui.store.snapshot.queuedPrompts.slice(0, 3);
44745
45247
  },
44746
45248
  children: (item, index) => (() => {
44747
- var _el$9 = createElement("text");
44748
- insert(_el$9, () => ` ${index() + 1}. ${truncateLine2(item.text.replace(/\s+/g, " "), 110)}`);
44749
- effect((_$p) => setProp(_el$9, "fg", COLOR.dim, _$p));
44750
- return _el$9;
45249
+ var _el$7 = createElement("text");
45250
+ insert(_el$7, () => ` ${index() + 1}. ${truncateLine2(item.text.replace(/\s+/g, " "), contentWidth())}`);
45251
+ effect((_$p) => setProp(_el$7, "fg", COLOR.dim, _$p));
45252
+ return _el$7;
44751
45253
  })()
44752
45254
  }), createComponent2(Show, {
44753
45255
  get when() {
44754
45256
  return tui.store.snapshot.queuedPrompts.length > 3;
44755
45257
  },
44756
45258
  get children() {
44757
- var _el$7 = createElement("text");
44758
- insert(_el$7, () => ` \u2026 ${tui.store.snapshot.queuedPrompts.length - 3} more`);
44759
- effect((_$p) => setProp(_el$7, "fg", COLOR.dim, _$p));
44760
- return _el$7;
45259
+ var _el$5 = createElement("text");
45260
+ insert(_el$5, () => ` \u2026 ${tui.store.snapshot.queuedPrompts.length - 3} more`);
45261
+ effect((_$p) => setProp(_el$5, "fg", COLOR.dim, _$p));
45262
+ return _el$5;
44761
45263
  }
44762
45264
  })];
44763
45265
  }
@@ -44774,7 +45276,6 @@ var init_pending_input_preview = __esm(() => {
44774
45276
  init_solid2();
44775
45277
  init_solid2();
44776
45278
  init_solid2();
44777
- init_solid2();
44778
45279
  init_solid();
44779
45280
  init_store4();
44780
45281
  init_renderers2();
@@ -44784,15 +45285,18 @@ var init_pending_input_preview = __esm(() => {
44784
45285
  // src/agent-tui/bottom-pane/status-indicator.tsx
44785
45286
  function StatusIndicator(props) {
44786
45287
  const tui = useTuiStore();
45288
+ const dims = useTerminalDimensions();
44787
45289
  const detail = () => {
44788
45290
  const value = tui.store.ui.statusDetail;
44789
45291
  return value && value !== "working" && !isFooterStatusDetail(value) ? ` \u2022 ${value}` : "";
44790
45292
  };
44791
45293
  const text = () => {
44792
- if (props.activity)
44793
- return `\u2022 ${props.activity} (${fmtElapsed(props.elapsed)}${detail()} \u2022 esc to interrupt)`.toLowerCase();
45294
+ if (props.activity) {
45295
+ const value2 = dims().width >= 56 ? `\u2022 ${props.activity} (${fmtElapsed(props.elapsed)}${detail()} \u2022 esc to interrupt)` : `\u2022 ${props.activity} ${fmtElapsed(props.elapsed)} \xB7 esc interrupt`;
45296
+ return truncateLine2(value2.toLowerCase(), Math.max(1, dims().width));
45297
+ }
44794
45298
  const value = tui.store.ui.statusDetail;
44795
- return (value && value !== "working" && !isFooterStatusDetail(value) ? `\u2022 ${value}` : "").toLowerCase();
45299
+ return truncateLine2((value && value !== "working" && !isFooterStatusDetail(value) ? `\u2022 ${value}` : "").toLowerCase(), Math.max(1, dims().width));
44796
45300
  };
44797
45301
  return (() => {
44798
45302
  var _el$ = createElement("box"), _el$2 = createElement("text");
@@ -44812,7 +45316,9 @@ var init_status_indicator = __esm(() => {
44812
45316
  init_solid2();
44813
45317
  init_solid2();
44814
45318
  init_solid2();
45319
+ init_solid2();
44815
45320
  init_store4();
45321
+ init_renderers2();
44816
45322
  init_theme();
44817
45323
  init_footer_state();
44818
45324
  });
@@ -44846,13 +45352,14 @@ function displayRows(matches, selectedId) {
44846
45352
 
44847
45353
  // src/agent-tui/overlays/selection-row.tsx
44848
45354
  function SelectionMenuHint(props) {
45355
+ const dims = useTerminalDimensions();
44849
45356
  return (() => {
44850
45357
  var _el$ = createElement("box"), _el$2 = createElement("text");
44851
45358
  insertNode(_el$, _el$2);
44852
45359
  setProp(_el$, "style", {
44853
45360
  marginTop: 1
44854
45361
  });
44855
- insert(_el$2, () => ` ${props.text}`);
45362
+ insert(_el$2, () => ` ${truncateLine2(props.text, Math.max(1, dims().width - 2))}`);
44856
45363
  effect((_$p) => setProp(_el$2, "fg", COLOR.dim, _$p));
44857
45364
  return _el$;
44858
45365
  })();
@@ -44917,6 +45424,7 @@ var init_selection_row = __esm(() => {
44917
45424
  init_solid2();
44918
45425
  init_solid2();
44919
45426
  init_solid();
45427
+ init_solid2();
44920
45428
  init_mouse();
44921
45429
  init_renderers2();
44922
45430
  init_theme();
@@ -45419,9 +45927,7 @@ function AgentsOverlay(props) {
45419
45927
  const status2 = () => agentStatusLine(item(), current(), now());
45420
45928
  const titleWidth = () => Math.max(8, props.width - terminalWidth(status2()) - 10);
45421
45929
  const metadata = () => item().role === "main" ? ["main thread", item().model].filter(Boolean).join(" \xB7 ") : [`${" ".repeat(Math.max(0, item().depth - 1))}${item().lane ?? "general"}`, item().mode === "detached" ? "background" : "attached", item().model].filter(Boolean).join(" \xB7 ");
45422
- const select = (event) => {
45423
- if (!isPrimaryClick(event))
45424
- return;
45930
+ const select = () => {
45425
45931
  const enabled = props.matches.filter((match) => !match.option.disabled);
45426
45932
  const index = enabled.findIndex((match) => match.option.id === row.option.id);
45427
45933
  if (props.frame.expandedId === row.option.id) {
@@ -45431,11 +45937,22 @@ function AgentsOverlay(props) {
45431
45937
  tui.actions.overlaySetIndex(index, enabled.length);
45432
45938
  tui.actions.agentDetailToggle(row.option.id);
45433
45939
  };
45940
+ const selectClick = createPrimaryClickGesture(select);
45434
45941
  return (() => {
45435
45942
  var _el$32 = createElement("box"), _el$33 = createElement("box"), _el$34 = createElement("text"), _el$35 = createElement("text"), _el$36 = createElement("text"), _el$37 = createElement("text"), _el$38 = createElement("text");
45436
45943
  insertNode(_el$32, _el$33);
45437
45944
  insertNode(_el$32, _el$38);
45438
- setProp(_el$32, "onMouseUp", select);
45945
+ spread(_el$32, mergeProps3({
45946
+ get style() {
45947
+ return {
45948
+ width: "100%",
45949
+ flexDirection: "column",
45950
+ paddingLeft: 1,
45951
+ paddingRight: 1,
45952
+ backgroundColor: row.selected ? COLOR.panelActive : COLOR.panel
45953
+ };
45954
+ }
45955
+ }, selectClick), true);
45439
45956
  insertNode(_el$33, _el$34);
45440
45957
  insertNode(_el$33, _el$35);
45441
45958
  insertNode(_el$33, _el$36);
@@ -45481,27 +45998,19 @@ function AgentsOverlay(props) {
45481
45998
  }
45482
45999
  }), null);
45483
46000
  effect((_p$) => {
45484
- var _v$13 = {
45485
- width: "100%",
45486
- flexDirection: "column",
45487
- paddingLeft: 1,
45488
- paddingRight: 1,
45489
- backgroundColor: row.selected ? COLOR.panelActive : COLOR.panel
45490
- }, _v$14 = row.selected ? COLOR.accent : COLOR.dim, _v$15 = agentColor(item()), _v$16 = COLOR.text, _v$17 = COLOR.dim, _v$18 = COLOR.dim;
45491
- _v$13 !== _p$.e && (_p$.e = setProp(_el$32, "style", _v$13, _p$.e));
45492
- _v$14 !== _p$.t && (_p$.t = setProp(_el$34, "fg", _v$14, _p$.t));
45493
- _v$15 !== _p$.a && (_p$.a = setProp(_el$35, "fg", _v$15, _p$.a));
45494
- _v$16 !== _p$.o && (_p$.o = setProp(_el$36, "fg", _v$16, _p$.o));
45495
- _v$17 !== _p$.i && (_p$.i = setProp(_el$37, "fg", _v$17, _p$.i));
45496
- _v$18 !== _p$.n && (_p$.n = setProp(_el$38, "fg", _v$18, _p$.n));
46001
+ var _v$13 = row.selected ? COLOR.accent : COLOR.dim, _v$14 = agentColor(item()), _v$15 = COLOR.text, _v$16 = COLOR.dim, _v$17 = COLOR.dim;
46002
+ _v$13 !== _p$.e && (_p$.e = setProp(_el$34, "fg", _v$13, _p$.e));
46003
+ _v$14 !== _p$.t && (_p$.t = setProp(_el$35, "fg", _v$14, _p$.t));
46004
+ _v$15 !== _p$.a && (_p$.a = setProp(_el$36, "fg", _v$15, _p$.a));
46005
+ _v$16 !== _p$.o && (_p$.o = setProp(_el$37, "fg", _v$16, _p$.o));
46006
+ _v$17 !== _p$.i && (_p$.i = setProp(_el$38, "fg", _v$17, _p$.i));
45497
46007
  return _p$;
45498
46008
  }, {
45499
46009
  e: undefined,
45500
46010
  t: undefined,
45501
46011
  a: undefined,
45502
46012
  o: undefined,
45503
- i: undefined,
45504
- n: undefined
46013
+ i: undefined
45505
46014
  });
45506
46015
  return _el$32;
45507
46016
  })();
@@ -45679,6 +46188,7 @@ var init_list_overlay = __esm(() => {
45679
46188
  init_solid2();
45680
46189
  init_solid2();
45681
46190
  init_solid2();
46191
+ init_solid2();
45682
46192
  init_solid();
45683
46193
  init_solid2();
45684
46194
  init_overlay_options();
@@ -46242,32 +46752,42 @@ function ModelProviderWizard() {
46242
46752
  children: (row) => {
46243
46753
  const selected = () => wizard().protocol === row[0];
46244
46754
  return (() => {
46245
- var _el$19 = createElement("box"), _el$20 = createElement("text"), _el$21 = createElement("text"), _el$22 = createElement("text");
46755
+ var _el$19 = createElement("box"), _el$20 = createElement("text"), _el$21 = createElement("text");
46246
46756
  insertNode(_el$19, _el$20);
46247
46757
  insertNode(_el$19, _el$21);
46248
- insertNode(_el$19, _el$22);
46249
46758
  setProp(_el$19, "style", {
46250
46759
  flexDirection: "row"
46251
46760
  });
46252
- setProp(_el$19, "onMouseUp", () => tui.actions.modelProviderWizardPatch({
46253
- protocol: row[0]
46254
- }));
46761
+ setProp(_el$19, "onMouseUp", (event) => {
46762
+ if (isPrimaryClick(event))
46763
+ tui.actions.modelProviderWizardPatch({
46764
+ protocol: row[0]
46765
+ });
46766
+ });
46255
46767
  setProp(_el$20, "selectable", false);
46256
46768
  insert(_el$20, () => selected() ? "\u203A " : " ");
46257
46769
  setProp(_el$21, "selectable", false);
46258
46770
  insert(_el$21, () => row[1]);
46259
- setProp(_el$22, "selectable", false);
46260
- insert(_el$22, () => ` ${row[2]}`);
46771
+ insert(_el$19, createComponent2(Show, {
46772
+ get when() {
46773
+ return dims().width >= 56;
46774
+ },
46775
+ get children() {
46776
+ var _el$22 = createElement("text");
46777
+ setProp(_el$22, "selectable", false);
46778
+ insert(_el$22, () => ` ${row[2]}`);
46779
+ effect((_$p) => setProp(_el$22, "fg", COLOR.dim, _$p));
46780
+ return _el$22;
46781
+ }
46782
+ }), null);
46261
46783
  effect((_p$) => {
46262
- var _v$18 = selected() ? COLOR.accent : COLOR.dim, _v$19 = COLOR.text, _v$20 = COLOR.dim;
46784
+ var _v$18 = selected() ? COLOR.accent : COLOR.dim, _v$19 = COLOR.text;
46263
46785
  _v$18 !== _p$.e && (_p$.e = setProp(_el$20, "fg", _v$18, _p$.e));
46264
46786
  _v$19 !== _p$.t && (_p$.t = setProp(_el$21, "fg", _v$19, _p$.t));
46265
- _v$20 !== _p$.a && (_p$.a = setProp(_el$22, "fg", _v$20, _p$.a));
46266
46787
  return _p$;
46267
46788
  }, {
46268
46789
  e: undefined,
46269
- t: undefined,
46270
- a: undefined
46790
+ t: undefined
46271
46791
  });
46272
46792
  return _el$19;
46273
46793
  })();
@@ -46295,7 +46815,7 @@ function ModelProviderWizard() {
46295
46815
  setProp(_el$8, "style", {
46296
46816
  marginTop: 1
46297
46817
  });
46298
- insert(_el$9, () => ` ${wizardHint(wizard().field, wizard().busy)}`);
46818
+ insert(_el$9, () => ` ${truncateLine2(wizardHint(wizard().field, wizard().busy), Math.max(1, dims().width - 2))}`);
46299
46819
  effect((_p$) => {
46300
46820
  var _v$ = COLOR.text, _v$2 = COLOR.dim, _v$3 = COLOR.dim;
46301
46821
  _v$ !== _p$.e && (_p$.e = setProp(_el$3, "fg", _v$, _p$.e));
@@ -46312,7 +46832,9 @@ function ModelProviderWizard() {
46312
46832
  }
46313
46833
  function ProviderReview() {
46314
46834
  const tui = useTuiStore();
46835
+ const dims = useTerminalDimensions();
46315
46836
  const wizard = () => tui.store.ui.modelProviderWizard;
46837
+ const width = () => Math.max(1, dims().width - 2);
46316
46838
  return (() => {
46317
46839
  var _el$23 = createElement("box"), _el$24 = createElement("text"), _el$25 = createElement("text"), _el$26 = createElement("text"), _el$27 = createElement("text");
46318
46840
  insertNode(_el$23, _el$24);
@@ -46324,23 +46846,17 @@ function ProviderReview() {
46324
46846
  marginTop: 1,
46325
46847
  paddingLeft: 2
46326
46848
  });
46327
- insert(_el$24, () => wizard().id || "unnamed provider");
46328
- insert(_el$25, () => wizard().baseUrl || "base url missing");
46329
- insert(_el$26, () => `${modelProviderProtocolLabel(wizard().protocol)} \xB7 ${wizard().model || "discover models automatically"}`);
46330
- insert(_el$27, (() => {
46331
- var _c$ = memo2(() => !!wizard().apiKey);
46332
- return () => _c$() ? "new api key will be stored securely" : memo2(() => !!wizard().removeCredential)() ? "stored api key will be removed" : wizard().credentialStored ? "stored api key will be retained" : "no api key";
46333
- })());
46849
+ insert(_el$24, () => truncateLine2(wizard().id || "unnamed provider", width()));
46850
+ insert(_el$25, () => truncateLine2(wizard().baseUrl || "base url missing", width()));
46851
+ insert(_el$26, () => truncateLine2(`${modelProviderProtocolLabel(wizard().protocol)} \xB7 ${wizard().model || "discover models automatically"}`, width()));
46852
+ insert(_el$27, () => truncateLine2(wizard().apiKey ? "new api key will be stored securely" : wizard().removeCredential ? "stored api key will be removed" : wizard().credentialStored ? "stored api key will be retained" : "no api key", width()));
46334
46853
  insert(_el$23, createComponent2(Show, {
46335
46854
  get when() {
46336
46855
  return wizard().probe;
46337
46856
  },
46338
46857
  get children() {
46339
46858
  var _el$28 = createElement("text");
46340
- insert(_el$28, (() => {
46341
- var _c$2 = memo2(() => !!wizard().probe?.ok);
46342
- return () => _c$2() ? `probe ready \xB7 ${wizard().probe?.models.length} models \xB7 ${wizard().probe?.latencyMs}ms` : `probe failed \xB7 ${wizard().probe?.error ?? "unknown error"}`;
46343
- })());
46859
+ insert(_el$28, () => truncateLine2(wizard().probe?.ok ? `probe ready \xB7 ${wizard().probe?.models.length} models \xB7 ${wizard().probe?.latencyMs}ms` : `probe failed \xB7 ${wizard().probe?.error ?? "unknown error"}`, width()));
46344
46860
  effect((_$p) => setProp(_el$28, "fg", wizard().probe?.ok ? COLOR.success : COLOR.error, _$p));
46345
46861
  return _el$28;
46346
46862
  }
@@ -46357,11 +46873,11 @@ function ProviderReview() {
46357
46873
  }
46358
46874
  }), null);
46359
46875
  effect((_p$) => {
46360
- var _v$21 = COLOR.text, _v$22 = COLOR.dim, _v$23 = COLOR.dim, _v$24 = COLOR.dim;
46361
- _v$21 !== _p$.e && (_p$.e = setProp(_el$24, "fg", _v$21, _p$.e));
46362
- _v$22 !== _p$.t && (_p$.t = setProp(_el$25, "fg", _v$22, _p$.t));
46363
- _v$23 !== _p$.a && (_p$.a = setProp(_el$26, "fg", _v$23, _p$.a));
46364
- _v$24 !== _p$.o && (_p$.o = setProp(_el$27, "fg", _v$24, _p$.o));
46876
+ var _v$20 = COLOR.text, _v$21 = COLOR.dim, _v$22 = COLOR.dim, _v$23 = COLOR.dim;
46877
+ _v$20 !== _p$.e && (_p$.e = setProp(_el$24, "fg", _v$20, _p$.e));
46878
+ _v$21 !== _p$.t && (_p$.t = setProp(_el$25, "fg", _v$21, _p$.t));
46879
+ _v$22 !== _p$.a && (_p$.a = setProp(_el$26, "fg", _v$22, _p$.a));
46880
+ _v$23 !== _p$.o && (_p$.o = setProp(_el$27, "fg", _v$23, _p$.o));
46365
46881
  return _p$;
46366
46882
  }, {
46367
46883
  e: undefined,
@@ -46425,6 +46941,7 @@ var init_model_provider_wizard = __esm(() => {
46425
46941
  init_model_provider_state();
46426
46942
  init_theme();
46427
46943
  init_renderers2();
46944
+ init_mouse();
46428
46945
  });
46429
46946
 
46430
46947
  // src/agent-tui/bottom-pane/model-provider-removal.tsx
@@ -46514,6 +47031,7 @@ function BottomPane() {
46514
47031
  const tui = useTuiStore();
46515
47032
  const exit = useExit();
46516
47033
  const composer = useComposerControl();
47034
+ const dims = useTerminalDimensions();
46517
47035
  const [elapsed, setElapsed] = createSignal(0);
46518
47036
  let tick;
46519
47037
  const frame = () => tui.store.ui.overlayStack.at(-1);
@@ -46613,10 +47131,10 @@ function BottomPane() {
46613
47131
  return tui.store.ui.lastError;
46614
47132
  },
46615
47133
  children: (error) => (() => {
46616
- var _el$4 = createElement("text");
46617
- insert(_el$4, () => `\u2022 error \xB7 ${truncateLine2(error(), 160)}`);
46618
- effect((_$p) => setProp(_el$4, "fg", COLOR.error, _$p));
46619
- return _el$4;
47134
+ var _el$3 = createElement("text");
47135
+ insert(_el$3, () => `\u2022 error \xB7 ${truncateLine2(error(), Math.max(1, dims().width - 10))}`);
47136
+ effect((_$p) => setProp(_el$3, "fg", COLOR.error, _$p));
47137
+ return _el$3;
46620
47138
  })()
46621
47139
  }), null);
46622
47140
  insert(_el$, createComponent2(Show, {
@@ -46633,7 +47151,7 @@ function BottomPane() {
46633
47151
  },
46634
47152
  get children() {
46635
47153
  var _el$2 = createElement("text");
46636
- insertNode(_el$2, createTextNode(` question pending \xB7 ctrl+q answer \xB7 chat input remains available`));
47154
+ insert(_el$2, () => dims().width >= 64 ? " question pending \xB7 ctrl+q answer \xB7 chat input remains available" : " question pending \xB7 ctrl+q answer");
46637
47155
  effect((_$p) => setProp(_el$2, "fg", COLOR.warning, _$p));
46638
47156
  return _el$2;
46639
47157
  }
@@ -46726,57 +47244,92 @@ function BottomPane() {
46726
47244
  }
46727
47245
  function ProxyTabFooter() {
46728
47246
  const tui = useTuiStore();
47247
+ const dims = useTerminalDimensions();
47248
+ const layout = () => proxyTabFooterLayout(dims().width, tui.store.ui.proxyFilter);
46729
47249
  return (() => {
46730
- var _el$5 = createElement("box"), _el$6 = createElement("text"), _el$8 = createElement("text");
46731
- insertNode(_el$5, _el$6);
46732
- insertNode(_el$5, _el$8);
46733
- setProp(_el$5, "style", {
47250
+ var _el$4 = createElement("box"), _el$5 = createElement("text"), _el$6 = createElement("text");
47251
+ insertNode(_el$4, _el$5);
47252
+ insertNode(_el$4, _el$6);
47253
+ setProp(_el$4, "style", {
46734
47254
  height: 1,
46735
47255
  flexDirection: "row",
46736
47256
  justifyContent: "space-between",
46737
47257
  paddingLeft: 1,
46738
47258
  paddingRight: 1
46739
47259
  });
46740
- insertNode(_el$6, createTextNode(`\u2191\u2193 flow \xB7 tab detail \xB7 p/n ws msg \xB7 \u2190\u2192 filter \xB7 a/h/w tabs \xB7 ctrl+1 chat`));
46741
- insert(_el$8, () => `proxy \xB7 ${tui.store.ui.proxyFilter}`);
47260
+ insert(_el$5, () => layout().left);
47261
+ insert(_el$6, () => layout().right);
46742
47262
  effect((_p$) => {
46743
47263
  var _v$ = COLOR.dim, _v$2 = COLOR.dim;
46744
- _v$ !== _p$.e && (_p$.e = setProp(_el$6, "fg", _v$, _p$.e));
46745
- _v$2 !== _p$.t && (_p$.t = setProp(_el$8, "fg", _v$2, _p$.t));
47264
+ _v$ !== _p$.e && (_p$.e = setProp(_el$5, "fg", _v$, _p$.e));
47265
+ _v$2 !== _p$.t && (_p$.t = setProp(_el$6, "fg", _v$2, _p$.t));
46746
47266
  return _p$;
46747
47267
  }, {
46748
47268
  e: undefined,
46749
47269
  t: undefined
46750
47270
  });
46751
- return _el$5;
47271
+ return _el$4;
46752
47272
  })();
46753
47273
  }
46754
47274
  function CenterSurfaceFooter(props) {
47275
+ const dims = useTerminalDimensions();
47276
+ const layout = () => centerSurfaceFooterLayout(props.frame, dims().width);
46755
47277
  return (() => {
46756
- var _el$9 = createElement("box"), _el$0 = createElement("text"), _el$1 = createElement("text");
46757
- insertNode(_el$9, _el$0);
46758
- insertNode(_el$9, _el$1);
46759
- setProp(_el$9, "style", {
47278
+ var _el$7 = createElement("box"), _el$8 = createElement("text"), _el$9 = createElement("text");
47279
+ insertNode(_el$7, _el$8);
47280
+ insertNode(_el$7, _el$9);
47281
+ setProp(_el$7, "style", {
46760
47282
  height: 1,
46761
47283
  flexDirection: "row",
46762
47284
  justifyContent: "space-between",
46763
47285
  paddingLeft: 1,
46764
47286
  paddingRight: 1
46765
47287
  });
46766
- insert(_el$0, () => centerSurfaceFooter(props.frame).toLowerCase());
46767
- insert(_el$1, () => props.frame.kind.toLowerCase());
47288
+ insert(_el$8, () => layout().left);
47289
+ insert(_el$9, () => layout().right);
46768
47290
  effect((_p$) => {
46769
47291
  var _v$3 = COLOR.dim, _v$4 = COLOR.dim;
46770
- _v$3 !== _p$.e && (_p$.e = setProp(_el$0, "fg", _v$3, _p$.e));
46771
- _v$4 !== _p$.t && (_p$.t = setProp(_el$1, "fg", _v$4, _p$.t));
47292
+ _v$3 !== _p$.e && (_p$.e = setProp(_el$8, "fg", _v$3, _p$.e));
47293
+ _v$4 !== _p$.t && (_p$.t = setProp(_el$9, "fg", _v$4, _p$.t));
46772
47294
  return _p$;
46773
47295
  }, {
46774
47296
  e: undefined,
46775
47297
  t: undefined
46776
47298
  });
46777
- return _el$9;
47299
+ return _el$7;
46778
47300
  })();
46779
47301
  }
47302
+ function proxyTabFooterLayout(width, filter) {
47303
+ const hint = width >= 88 ? "\u2191\u2193 flow \xB7 tab detail \xB7 p/n ws msg \xB7 \u2190\u2192 filter \xB7 a/h/w tabs \xB7 alt+1 chat" : width >= 56 ? "alt+1 chat \xB7 \u2191\u2193 flow \xB7 tab detail \xB7 \u2190\u2192 filter" : width >= 32 ? "alt+1 chat \xB7 \u2191\u2193 flow" : "alt+1 chat";
47304
+ return fitFooterLine(hint, [{
47305
+ id: "proxy",
47306
+ kind: "message",
47307
+ text: `proxy \xB7 ${filter}`
47308
+ }], Math.max(0, width - 2));
47309
+ }
47310
+ function centerSurfaceFooterLayout(frame, width) {
47311
+ const hint = width >= 64 ? centerSurfaceFooter(frame).toLowerCase() : compactCenterSurfaceFooter(frame);
47312
+ return fitFooterLine(hint, [{
47313
+ id: "surface",
47314
+ kind: "message",
47315
+ text: frame.kind.toLowerCase()
47316
+ }], Math.max(0, width - 2));
47317
+ }
47318
+ function compactCenterSurfaceFooter(frame) {
47319
+ switch (frame.kind) {
47320
+ case "report":
47321
+ return "esc back \xB7 s save";
47322
+ case "container":
47323
+ return "esc back \xB7 t toggle \xB7 r refresh";
47324
+ case "confirm":
47325
+ return "esc cancel \xB7 enter confirm";
47326
+ case "proxy_flow":
47327
+ return "esc back \xB7 tab pane";
47328
+ case "alert":
47329
+ case "detail":
47330
+ return "esc back";
47331
+ }
47332
+ }
46780
47333
  var init_bottom_pane = __esm(() => {
46781
47334
  init_solid2();
46782
47335
  init_solid2();
@@ -46863,6 +47416,9 @@ ${note.text}`).join(`
46863
47416
  return [createComponent2(KeyboardController, {}), (() => {
46864
47417
  var _el$ = createElement("box"), _el$2 = createElement("box");
46865
47418
  insertNode(_el$, _el$2);
47419
+ setProp(_el$, "minHeight", 0);
47420
+ setProp(_el$, "overflow", "hidden");
47421
+ setProp(_el$, "flexDirection", "column");
46866
47422
  insert(_el$, createComponent2(MainTabs, {}), _el$2);
46867
47423
  setProp(_el$2, "id", "main-surface-viewport");
46868
47424
  setProp(_el$2, "style", {
@@ -46896,13 +47452,17 @@ ${note.text}`).join(`
46896
47452
  })
46897
47453
  }));
46898
47454
  insert(_el$, createComponent2(BottomPane, {}), null);
46899
- effect((_$p) => setProp(_el$, "style", {
46900
- width: dims().width,
46901
- height: dims().height,
46902
- minHeight: 0,
46903
- overflow: "hidden",
46904
- flexDirection: "column"
46905
- }, _$p));
47455
+ effect((_p$) => {
47456
+ var _v$ = dims().width, _v$2 = dims().height, _v$3 = COLOR.bg;
47457
+ _v$ !== _p$.e && (_p$.e = setProp(_el$, "width", _v$, _p$.e));
47458
+ _v$2 !== _p$.t && (_p$.t = setProp(_el$, "height", _v$2, _p$.t));
47459
+ _v$3 !== _p$.a && (_p$.a = setProp(_el$, "backgroundColor", _v$3, _p$.a));
47460
+ return _p$;
47461
+ }, {
47462
+ e: undefined,
47463
+ t: undefined,
47464
+ a: undefined
47465
+ });
46906
47466
  return _el$;
46907
47467
  })()];
46908
47468
  }
@@ -46945,10 +47505,10 @@ function MainTabs() {
46945
47505
  });
46946
47506
  insert(_el$8, () => `[2] proxy${proxyCount() ? ` (${proxyCount()})` : ""}`);
46947
47507
  effect((_p$) => {
46948
- var _v$ = active() === "chat" ? COLOR.accent : COLOR.dim, _v$2 = COLOR.dim, _v$3 = active() === "proxy" ? COLOR.accent : COLOR.dim;
46949
- _v$ !== _p$.e && (_p$.e = setProp(_el$4, "fg", _v$, _p$.e));
46950
- _v$2 !== _p$.t && (_p$.t = setProp(_el$6, "fg", _v$2, _p$.t));
46951
- _v$3 !== _p$.a && (_p$.a = setProp(_el$8, "fg", _v$3, _p$.a));
47508
+ var _v$4 = active() === "chat" ? COLOR.accent : COLOR.dim, _v$5 = COLOR.dim, _v$6 = active() === "proxy" ? COLOR.accent : COLOR.dim;
47509
+ _v$4 !== _p$.e && (_p$.e = setProp(_el$4, "fg", _v$4, _p$.e));
47510
+ _v$5 !== _p$.t && (_p$.t = setProp(_el$6, "fg", _v$5, _p$.t));
47511
+ _v$6 !== _p$.a && (_p$.a = setProp(_el$8, "fg", _v$6, _p$.a));
46952
47512
  return _p$;
46953
47513
  }, {
46954
47514
  e: undefined,
@@ -47186,9 +47746,37 @@ __export(exports_agent_tui, {
47186
47746
  formatResumeHint: () => formatResumeHint,
47187
47747
  ensureSession: () => ensureSession,
47188
47748
  createRuntimePort: () => createRuntimePort,
47749
+ createDeferredResizeHandler: () => createDeferredResizeHandler,
47189
47750
  SessionResolutionError: () => SessionResolutionError
47190
47751
  });
47191
- import { createCliRenderer as createCliRenderer2 } from "@opentui/core";
47752
+ import { createCliRenderer as createCliRenderer2, RGBA } from "@opentui/core";
47753
+ function createDeferredResizeHandler(resize, readSize, schedule = (callback) => setTimeout(callback, 0), cancel = clearTimeout) {
47754
+ let timer;
47755
+ let disposed = false;
47756
+ const onResize2 = () => {
47757
+ if (disposed)
47758
+ return;
47759
+ if (timer !== undefined)
47760
+ cancel(timer);
47761
+ timer = schedule(() => {
47762
+ timer = undefined;
47763
+ if (disposed)
47764
+ return;
47765
+ const size = readSize();
47766
+ if (size)
47767
+ resize(size.width, size.height);
47768
+ });
47769
+ };
47770
+ return {
47771
+ onResize: onResize2,
47772
+ dispose: () => {
47773
+ disposed = true;
47774
+ if (timer !== undefined)
47775
+ cancel(timer);
47776
+ timer = undefined;
47777
+ }
47778
+ };
47779
+ }
47192
47780
  async function runOpenTui(input) {
47193
47781
  const capabilities = input.capabilities ?? {
47194
47782
  compact: true,
@@ -47293,29 +47881,24 @@ async function destroyRenderer(renderer) {
47293
47881
  } catch {}
47294
47882
  }
47295
47883
  async function createManagedRenderer(onDestroy) {
47296
- const existingListeners = new Set(process.listeners("SIGWINCH"));
47297
47884
  const renderer = await createCliRenderer2({
47298
47885
  autoFocus: false,
47886
+ backgroundColor: COLOR.bg,
47299
47887
  exitOnCtrlC: false,
47300
47888
  onDestroy
47301
47889
  });
47302
- const rendererListeners = process.listeners("SIGWINCH").filter((listener) => !existingListeners.has(listener));
47303
- for (const listener of rendererListeners)
47304
- process.off("SIGWINCH", listener);
47305
- if (rendererListeners.length === 0)
47306
- return {
47307
- renderer,
47308
- disposeResize: () => {}
47309
- };
47310
- const onResize2 = () => {
47311
- const size = validTerminalSize(process.stdout.columns, process.stdout.rows);
47312
- if (size)
47313
- renderer.resize(size.width, size.height);
47314
- };
47315
- process.on("SIGWINCH", onResize2);
47890
+ const resize = createDeferredResizeHandler((width, height) => {
47891
+ renderer.resize(width, height);
47892
+ renderer.currentRenderBuffer.clear(RGBA.fromInts(1, 1, 1, 255));
47893
+ renderer.requestRender();
47894
+ }, () => validTerminalSize(process.stdout.columns, process.stdout.rows));
47895
+ process.on("SIGWINCH", resize.onResize);
47316
47896
  return {
47317
47897
  renderer,
47318
- disposeResize: () => process.off("SIGWINCH", onResize2)
47898
+ disposeResize: () => {
47899
+ process.off("SIGWINCH", resize.onResize);
47900
+ resize.dispose();
47901
+ }
47319
47902
  };
47320
47903
  }
47321
47904
  function validTerminalSize(columns, rows) {
@@ -47387,6 +47970,7 @@ var init_agent_tui = __esm(() => {
47387
47970
  init_session_title();
47388
47971
  init_session_catalog();
47389
47972
  init_update_check();
47973
+ init_theme();
47390
47974
  SessionResolutionError = class SessionResolutionError extends Error {
47391
47975
  constructor(query, workspace, sessions2) {
47392
47976
  const recent = sessions2.slice(0, 5).map((session) => ` ${session.id} ${session.title?.trim() || DEFAULT_SESSION_TITLE}`).join(`
@@ -49967,5 +50551,5 @@ Examples:
49967
50551
  `);
49968
50552
  }
49969
50553
 
49970
- //# debugId=231A9E4A58F7AFCB64756E2164756E21
50554
+ //# debugId=B089044398C9A98564756E2164756E21
49971
50555
  //# sourceMappingURL=index.js.map