minicode-ai 0.11.0 → 0.11.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.11.1] - 2026-09-24
6
+
7
+ ### Fixed — TUI runtime feedback
8
+
9
+ - TUI fullscreen sekarang menampilkan `Working` dan elapsed secara clock-driven saat provider Diam, tanpa menunggu event output.
10
+ - `Thinking` hanya muncul untuk reasoning nyata; reasoning delta pada Responses API dipetakan ke lifecycle reasoning.
11
+ - Tool running dari presentation snapshot tampil di footer; `MINICODE_MOTION=0` tetap mempertahankan status textual yang dapat dibedakan dari idle.
12
+ - Esc/Ctrl+C menampilkan acknowledgement `Stopping`, dan tekanan kedua atau `SIGINT` menjalankan jalur keluar yang sama.
13
+
5
14
  ## [0.11.0] - 2026-09-24
6
15
 
7
16
  ### Added — Agent Presentation V2.1
@@ -464,7 +464,7 @@ footer.site .spacer { flex: 1; }
464
464
  <span class="mi">search</span><span>Cari modul, simbol, env…</span><kbd>Ctrl K</kbd>
465
465
  </div>
466
466
  <div class="top-actions">
467
- <span class="vpill hide-m">v0.11.0 · Bun-only · 0 deps</span>
467
+ <span class="vpill hide-m">v0.11.1 · Bun-only · 0 deps</span>
468
468
  <button class="iconbtn" id="themeBtn" aria-label="Ganti tema terang/gelap" title="Ganti tema"><span class="mi">dark_mode</span></button>
469
469
  </div>
470
470
  </header>
@@ -1009,7 +1009,7 @@ bun run bench # benchmark loop agen</pre></div>
1009
1009
  <div class="uxgrid">
1010
1010
  <div class="uxcard"><h4>1 · Prompt</h4><p><code>minicode &lt;mode&gt; ›</code> — baris input interaktif + dropdown slash; satu-satunya elemen “hidup” saat idle.</p></div>
1011
1011
  <div class="uxcard"><h4>2 · Pesan model</h4><p>Streaming ke <b>stdout</b>, di-sanitasi, dibungkus per baris mengikuti kolom terminal; fence markdown indent 2 spasi.</p></div>
1012
- <div class="uxcard"><h4>3 · Aktivitas</h4><p>Garis transient di <b>stderr</b> (TTY saja): <code>✦···</code> kelip putih↔abu saat thinking, atau <code>frame label···</code> selama tool berjalan. Hilang saat teks mengalir.</p></div>
1012
+ <div class="uxcard"><h4>3 · Aktivitas</h4><p>Status bar fullscreen memiliki clock sendiri: <code>Working</code> selama turn hidup, <code>Thinking</code> hanya saat reasoning nyata, dan <code>Running tool target</code> selama tool. Elapsed dan pulse menjadi milik App, bukan event provider; <code>MINICODE_MOTION=0</code> mematikan pulse tetapi mempertahankan teks status.</p></div>
1013
1013
  <div class="uxcard"><h4>4 · Hasil tool</h4><p>Ledger stderr, compact: <code>› nama target</code> satu baris (hijau; tanpa bocor isi file); error <code>› nama: pesan</code> (merah). Section besar default minimize (<code>+ label</code>); expanded/verbose menampilkan isi.</p></div>
1014
1014
  <div class="uxcard"><h4>5 · Error</h4><p><code>✗ pesan actionable</code> — sekali per kegagalan via <code>takePendingError()</code>; tidak pernah dump JSON/stack ke user.</p></div>
1015
1015
  <div class="uxcard"><h4>Stream contract</h4><p>stdout = output program (teks model, receipt). stderr = progress/diagnostik. Non-TTY: 0 ANSI, 0 spinner, 0 cursor control.</p></div>
@@ -1017,9 +1017,9 @@ bun run bench # benchmark loop agen</pre></div>
1017
1017
 
1018
1018
  <p class="lede" style="margin-top:22px">Transient rendering memiliki <b>satu ownership mechanism</b> (<code>src/ui/runtime/statusline.ts</code>):</p>
1019
1019
  <div class="uxgrid">
1020
- <div class="uxcard"><h4>Ownership</h4><p>Painter garis turn (<code>turn</code>) dan wizard spinner (<code>spinner</code>) klaim via <code>acquireTransientPaint(kind)</code>; semua tulis painter lewat <code>paintWrite</code>.</p></div>
1020
+ <div class="uxcard"><h4>Ownership</h4><p>Painter garis turn (<code>turn</code>) dipakai pada shell/linier; TUI fullscreen status-nya dimiliki <code>TuiApp</code> dan clock-nya berjalan independen dari event. Wizard spinner tetap lewat <code>acquireTransientPaint(kind)</code>.</p></div>
1021
1021
  <div class="uxcard"><h4>Foreign writers</h4><p>Diagnostik non-UI (router/providers/tool warnings) boleh menulis mentah ke stderr — arbitrator mengkomitnya sebagai baris permanen saat painter aktif.</p></div>
1022
- <div class="uxcard"><h4>Lifecycle tertutup</h4><p>Garis tidak pernah stale: <code>endTurn()</code> dipanggil driver setelah setiap <code>session.run</code> settle (kernel hanya emit <code>turn:completed</code> di jalur sukses).</p></div>
1022
+ <div class="uxcard"><h4>Lifecycle tertutup</h4><p>Status TUI memiliki status <code>Working</code>/<code>Thinking</code>/<code>Running</code> dan konfirmasi <code>Stopping</code>; cleanup terjadi pada sukses, kegagalan, pembatalan, serta double-abort.</p></div>
1023
1023
  <div class="uxcard"><h4>Mutual exclusion</h4><p>Painter vs spinner secara desain disjoint; overlap memicu signal <code>[transient-paint] …</code> sekali per pasangan (bukan crash).</p></div>
1024
1024
  </div>
1025
1025
 
@@ -1065,7 +1065,7 @@ bun run bench # benchmark loop agen</pre></div>
1065
1065
  <footer class="site">
1066
1066
  <span>Minicode · Peta struktur hidup — terminal contract FROZEN (<a href="TERMINAL_CONTRACT.md">docs/TERMINAL_CONTRACT.md</a>)</span>
1067
1067
  <span class="spacer"></span>
1068
- <span>v0.11.0 · diperbarui 2026-09-24</span>
1068
+ <span>v0.11.1 · diperbarui 2026-09-24</span>
1069
1069
  </footer>
1070
1070
 
1071
1071
  </div>
@@ -146,11 +146,14 @@ Non-TTY (pipe/redirect/CI/file): **0 cursor control, 0 alternate screen,
146
146
  `… N baris awal di luar viewport — riwayat penuh di model` yang melacak
147
147
  jumlah baris yang di-evict; `total()` tetap monotonik.
148
148
 
149
- 13. Status bar: 1 baris dasar (`✦ mode • model • cwd … ctx`) dari sumber yang
150
- sama dengan angka sesi; spark pulse saat busy; `MINICODE_MOTION=0`
151
- mematikan pulse (spark statis redup — status busy tak bergantung animasi;
152
- aksesibilitas/SSH lambat/rekaman; temuan audit TUI-006), dibaca saat
153
- dipakai (bukan beku saat import).
149
+ 13. Status bar: 1 baris dasar (`✦ [status] mode • model • cwd … ctx`) dari
150
+ sumber yang sama dengan angka sesi. Saat turn aktif, status teks dan
151
+ elapsed selalu tampil tanpa bergantung pada event provider; `Working`
152
+ berarti turn hidup, `Thinking` hanya untuk reasoning nyata, dan tool
153
+ running memakai label/tool target. Spark pulse saat busy;
154
+ `MINICODE_MOTION=0` mematikan pulse (status textual tetap tampil dan
155
+ tidak boleh identik dengan idle; aksesibilitas/SSH lambat/rekaman; temuan
156
+ audit TUI-006), dibaca saat dipakai (bukan beku saat import).
154
157
  14. Binding TUI: PgUp/PgDn scroll; **Shift+PgUp/PgDn (ESC[5;2~/6;2,
155
158
  modifier 2) = setengah halaman; Home/End saat prompt KOSONG = lompat
156
159
  baris-teratas/ekor transkrip (baris berisi = editing awal/akhir baris;
@@ -159,7 +162,8 @@ Non-TTY (pipe/redirect/CI/file): **0 cursor control, 0 alternate screen,
159
162
  batal input / abort turn (busy: SEMUA input dibekukan kecuali abort dan
160
163
  scroll — Enter pun sunyi; berlaku juga saat layar MENCIUT: abort+scroll
161
164
  selalu lolos agar turn bisa dibatalkan tanpa kill -9; abort pertama
162
- menampilkan hint keluar sekali). Baris kosong menampilkan placeholder +
165
+ menampilkan status `Stopping` + hint keluar sekali, abort kedua dalam
166
+ 1,5 detik menutup sesi). Baris kosong menampilkan placeholder +
163
167
  cara keluar; scroll ke atas + stream masuk = indikator `↓ N baris baru`.
164
168
  15. (Dihapus bersama jendela info — nomor dipertahankan.)
165
169
  16. Popup komposit: region tanpa clear + union-clear anti-hantu + clearRegion
@@ -167,7 +171,8 @@ Non-TTY (pipe/redirect/CI/file): **0 cursor control, 0 alternate screen,
167
171
  + batal.
168
172
  17. Transkrip append-only di memori (cap 5000), viewport ikut ekor otomatis;
169
173
  ketikan baru kembali ke ekor; stream turn TIDAK merampas posisi baca;
170
- repaint live coalesce 30ms (layar tak buta saat turn). Proyeksi
174
+ repaint live coalesce 30ms dan clock activity 200ms (layar tak buta
175
+ saat turn). Proyeksi
171
176
  presentasi: baris running di-pin dari snapshot, elapsed tampil setelah
172
177
  ≥2s, status tool final memakai glyph + kata
173
178
  (`completed`/`failed`/`denied`/`cancelled`/`interrupted`), retry dan
@@ -36,9 +36,11 @@ scrollback, tanpa alternate screen. `provider:text` → `sanitizeAnsi` PER CHUNK
36
36
  (buffer 1MB + marker, dibuka via `/expand`).
37
37
 
38
38
  Tahap E — garis status transient `src/ui/assistant/turn-status.ts`: satu baris
39
- `stderr`, hidup hanya di fase sunyi (latch `turnOn && !textOn`), hilang saat
40
- teks mengalir, hidup lagi saat tool berikut. `endTurn()` deterministik dari
41
- driver `finally` (kernel tak emit `completed` saat gagal/abort).
39
+ `stderr` untuk shell/linier, hidup hanya di fase sunyi (latch
40
+ `turnOn && !textOn`), hilang saat teks mengalir, hidup lagi saat tool
41
+ berikut. `endTurn()` deterministik dari driver `finally` (kernel tak emit
42
+ `completed` saat gagal/abort). TUI fullscreen tidak memakai painter transient
43
+ ini karena alternate screen dimiliki `TuiApp`.
42
44
 
43
45
  Tahap F — arbitrator `src/ui/runtime/statusline.ts`: satu pemilik transient
44
46
  (`turn` vs `spinner`); tulis asing saat painter aktif dikomit
@@ -46,10 +48,12 @@ Tahap F — arbitrator `src/ui/runtime/statusline.ts`: satu pemilik transient
46
48
  bukan crash. `paintWrite` tak pernah melempar (fail-closed Bun Windows).
47
49
 
48
50
  Tahap G — status bar `src/ui/footer.ts` dirender `src/ui/tui/app.ts` sebagai
49
- baris dasar frame fullscreen. Footer/chrome lama (`src/ui/runtime/chrome.ts`,
50
- DECSTBM scroll-region, `MINICODE_FOOTER`) DIHAPUS bersama lapisan TUI lama —
51
- alternate screen menggantikannya; nol byte di non-TTY. Footer baca
52
- `session.contextTokens` kernel (bukan spend kumulatif).
51
+ baris dasar frame fullscreen. `TuiApp` memiliki clock activity 200ms,
52
+ `Working`/`Thinking`/tool status, elapsed, dan konfirmasi `Stopping`
53
+ tanpa menunggu event provider. Footer/chrome lama
54
+ (`src/ui/runtime/chrome.ts`, DECSTBM scroll-region, `MINICODE_FOOTER`) DIHAPUS
55
+ bersama lapisan TUI lama — alternate screen menggantikannya; nol byte di
56
+ non-TTY. Footer baca `session.contextTokens` kernel (bukan spend kumulatif).
53
57
 
54
58
  Tahap H — primitif render `src/ui/render/`: `sanitize.ts` (hanya SGR lolos),
55
59
  `markdown.ts` + `highlight.ts` (fence-state per baris, konten utuh),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minicode-ai",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "Coding agent CLI built on the frozen MiniCore runtime — tools, MCP, LSP, sandbox, shadow-git checkpoints",
5
5
  "type": "module",
6
6
  "private": false,
@@ -263,6 +263,15 @@ export function createResponsesProvider(config: ResponsesConfig): ModelProvider
263
263
  }
264
264
  }
265
265
  }
266
+ const reasoningText =
267
+ (dtype === "response.reasoning_summary_text.delta" ||
268
+ dtype === "response.reasoning_text.delta") &&
269
+ typeof data.delta === "string"
270
+ ? data.delta
271
+ : ""
272
+ if (reasoningText) {
273
+ yield { type: "extension", kind: "reasoning", data: { text: reasoningText } }
274
+ }
266
275
  const rawDelta: unknown = (data.delta as unknown) ?? data
267
276
  const drec = (
268
277
  typeof rawDelta === "object" && rawDelta !== null
@@ -328,11 +337,12 @@ export function createResponsesProvider(config: ResponsesConfig): ModelProvider
328
337
  typeof data.arguments === "string" ? data.arguments : "",
329
338
  )
330
339
  }
331
- const text =
332
- (typeof rawDelta === "string" ? rawDelta : undefined) ??
333
- drec.text ??
334
- drec.content ??
335
- drec.output_text
340
+ const text = reasoningText
341
+ ? undefined
342
+ : ((typeof rawDelta === "string" ? rawDelta : undefined) ??
343
+ drec.text ??
344
+ drec.content ??
345
+ drec.output_text)
336
346
  if (typeof text === "string" && text) yield { type: "text", text }
337
347
  const finish =
338
348
  (data as { finish_reason?: string }).finish_reason ??
package/src/ui/footer.ts CHANGED
@@ -27,6 +27,7 @@ export interface FooterStatus {
27
27
  * memetakan frame → glyph berwarna.
28
28
  */
29
29
  sparkFrame?: number
30
+ activity?: string
30
31
  }
31
32
 
32
33
  /** Lebar tetap kolom mode — `allowlist`/`allow-all` (9) adalah yang terpanjang. */
@@ -84,6 +85,8 @@ export function renderFooter(s: FooterStatus, columns: number): string[] {
84
85
  const cols = Math.max(10, Math.floor(columns) || 80)
85
86
 
86
87
  const spark = sparkGlyph(s.sparkFrame ?? 0)
88
+ const activity = s.activity ? ` ${c.info(sanitizeAnsiLine(s.activity))}` : ""
89
+ const lead = `${spark}${activity} `
87
90
  const mode = paintFooterMode(s.mode)
88
91
  const dot = c.gray("•")
89
92
  const sep = ` ${dot} `
@@ -94,10 +97,10 @@ export function renderFooter(s: FooterStatus, columns: number): string[] {
94
97
  const cwdTxt = c.gray(sanitizeAnsiLine(s.cwd))
95
98
  const shortCwdTxt = c.gray(sanitizeAnsiLine(shortenPath(s.cwd)))
96
99
 
97
- const full = `${spark} ${mode}${sep}${model}${sep}${cwdTxt}`
98
- const shortened = `${spark} ${mode}${sep}${model}${sep}${shortCwdTxt}`
99
- const mid = `${spark} ${mode}${sep}${model}`
100
- const lean = `${spark} ${mode}`
100
+ const full = `${lead}${mode}${sep}${model}${sep}${cwdTxt}`
101
+ const shortened = `${lead}${mode}${sep}${model}${sep}${shortCwdTxt}`
102
+ const mid = `${lead}${mode}${sep}${model}`
103
+ const lean = `${lead}${mode}`
101
104
 
102
105
  const target = Math.max(4, cols - 1)
103
106
  const ctx = s.context ? sanitizeAnsiLine(s.context) : ""
package/src/ui/i18n/en.ts CHANGED
@@ -7,6 +7,10 @@ export const en = {
7
7
  "app.moreLines": " … {n} more",
8
8
  "app.newBelow": "↓ {n} new lines below · PgDn to bottom",
9
9
  "app.abortHint": "abort sent — press Esc/Ctrl+C again to quit",
10
+ "app.working": "Working",
11
+ "app.thinking": "Thinking",
12
+ "app.running": "Running",
13
+ "app.stopping": "Stopping",
10
14
  "form.idleWarning": "idle — canceling in {s}s (press any key to keep editing)",
11
15
  "appr.title": "Approval required",
12
16
  "appr.tool": "Tool:",
package/src/ui/i18n/id.ts CHANGED
@@ -8,6 +8,10 @@ export const id: Record<MsgKey, string> = {
8
8
  "app.moreLines": " … {n} lagi",
9
9
  "app.newBelow": "↓ {n} baris baru di bawah · PgDn ke ekor",
10
10
  "app.abortHint": "abort terkirim — tekan Esc/Ctrl+C sekali lagi untuk keluar",
11
+ "app.working": "Bekerja",
12
+ "app.thinking": "Berpikir",
13
+ "app.running": "Menjalankan",
14
+ "app.stopping": "Menghentikan",
11
15
  "form.idleWarning": "diam — dibatalkan dalam {s} dtk (tekan sembarang tombol untuk lanjut)",
12
16
  "appr.title": "Perlu persetujuan",
13
17
  "appr.tool": "Alat:",
package/src/ui/tui/app.ts CHANGED
@@ -77,6 +77,15 @@ const MIN_COLS = 20
77
77
 
78
78
  const PROMPT_FIRST = "minicode › "
79
79
  const PROMPT_CONT = " · "
80
+ type ActivityKind = "working" | "thinking" | "tool" | "stopping"
81
+
82
+ function formatElapsed(ms: number): string {
83
+ const seconds = Math.max(0, Math.floor(ms / 1000))
84
+ if (seconds < 60) return `${seconds}s`
85
+ const minutes = Math.floor(seconds / 60)
86
+ if (minutes < 60) return `${minutes}m${String(seconds % 60).padStart(2, "0")}s`
87
+ return `${Math.floor(minutes / 60)}h${String(minutes % 60).padStart(2, "0")}m`
88
+ }
80
89
 
81
90
  interface RawStdin {
82
91
  setRawMode(v: boolean): void
@@ -95,6 +104,10 @@ export class TuiApp {
95
104
  private draft = ""
96
105
  private busy = false
97
106
  private tick = 0
107
+ private turnStartedAt = 0
108
+ private activityKind: ActivityKind = "working"
109
+ private textSeen = false
110
+ private activityTimer: ReturnType<typeof setTimeout> | undefined
98
111
  /** Timestamp abort terakhir (ms) — deteksi double-tap Esc/Ctrl+C = quit. */
99
112
  private lastAbortAt = 0
100
113
  /** Hint "tekan lagi untuk keluar" tampil sekali setelah abort pertama. */
@@ -113,6 +126,7 @@ export class TuiApp {
113
126
  */
114
127
  private onSignalTerm: (() => void) | null = null
115
128
  private onSignalHup: (() => void) | null = null
129
+ private onSignalInt: (() => void) | null = null
116
130
 
117
131
  private wasRaw = false
118
132
  /**
@@ -223,13 +237,22 @@ export class TuiApp {
223
237
  }
224
238
  this.onSignalTerm = () => restoreAndExit(143)
225
239
  this.onSignalHup = () => restoreAndExit(129)
240
+ this.onSignalInt = () => this.requestAbort()
226
241
  try {
227
242
  process.on("SIGTERM", this.onSignalTerm)
228
- process.on("SIGHUP", this.onSignalHup)
229
243
  } catch {
230
244
  this.onSignalTerm = null
245
+ }
246
+ try {
247
+ process.on("SIGHUP", this.onSignalHup)
248
+ } catch {
231
249
  this.onSignalHup = null
232
250
  }
251
+ try {
252
+ process.on("SIGINT", this.onSignalInt)
253
+ } catch {
254
+ this.onSignalInt = null
255
+ }
233
256
  // Repaint live mengikuti event bus (stream teks, ledger, thinking).
234
257
  // Suspend menahan repaint (popup melukis sendiri); quit menahan semua.
235
258
  const requestPaint = () => {
@@ -243,16 +266,41 @@ export class TuiApp {
243
266
  ;(this.repaintTimer as unknown as { unref?: () => void }).unref?.()
244
267
  } catch {}
245
268
  }
246
- const sub = (type: Parameters<UiBus["on"]>[0]) => {
269
+ const sub = (type: Parameters<UiBus["on"]>[0], handler?: (event: any) => void) => {
247
270
  try {
248
- this.busUnsubs.push(this.host.bus.on(type, requestPaint))
271
+ this.busUnsubs.push(
272
+ this.host.bus.on(type, (event: any) => {
273
+ try {
274
+ handler?.(event)
275
+ } finally {
276
+ requestPaint()
277
+ }
278
+ }),
279
+ )
249
280
  } catch {}
250
281
  }
251
- sub("provider:text")
252
- sub("provider:extension")
253
- sub("execution:started")
254
- sub("execution:completed")
255
- sub("turn:started")
282
+ sub("turn:started", () => {
283
+ this.turnStartedAt = Date.now()
284
+ if (this.activityKind !== "stopping") this.activityKind = "working"
285
+ this.textSeen = false
286
+ })
287
+ sub("provider:extension", (event: { kind?: string }) => {
288
+ if (event?.kind === "reasoning" && !this.textSeen && this.activityKind !== "stopping") {
289
+ this.activityKind = "thinking"
290
+ }
291
+ })
292
+ sub("provider:text", () => {
293
+ if (this.activityKind !== "stopping") this.activityKind = "working"
294
+ this.textSeen = true
295
+ })
296
+ sub("execution:started", () => {
297
+ if (this.activityKind !== "stopping") this.activityKind = "tool"
298
+ this.textSeen = false
299
+ })
300
+ sub("execution:completed", () => {
301
+ if (this.activityKind !== "stopping") this.activityKind = "working"
302
+ this.textSeen = false
303
+ })
256
304
  sub("turn:completed")
257
305
  sub("context:compacted")
258
306
  this.tailSize = this.transcript.total()
@@ -267,6 +315,7 @@ export class TuiApp {
267
315
  clearTimeout(this.repaintTimer)
268
316
  this.repaintTimer = undefined
269
317
  }
318
+ this.stopActivityClock()
270
319
  for (const u of this.busUnsubs) {
271
320
  try {
272
321
  u()
@@ -287,6 +336,12 @@ export class TuiApp {
287
336
  } catch {}
288
337
  this.onSignalHup = null
289
338
  }
339
+ if (this.onSignalInt) {
340
+ try {
341
+ process.off("SIGINT", this.onSignalInt)
342
+ } catch {}
343
+ this.onSignalInt = null
344
+ }
290
345
  this.stdin = null
291
346
  this.pump.dispose()
292
347
  this.pump = null
@@ -308,6 +363,23 @@ export class TuiApp {
308
363
 
309
364
  // ── Penanganan key ──
310
365
 
366
+ private requestAbort(): void {
367
+ if (!this.busy) return
368
+ try {
369
+ this.host.abort()
370
+ } catch {}
371
+ const now = Date.now()
372
+ const doubleTap = now - this.lastAbortAt < 1500
373
+ if (!doubleTap) {
374
+ this.activityKind = "stopping"
375
+ this.abortHintOn = true
376
+ this.startActivityClock()
377
+ }
378
+ this.lastAbortAt = now
379
+ if (doubleTap) this.quit()
380
+ else this.paintCurrent()
381
+ }
382
+
311
383
  private handleKeys(keys: { key: PromptKey }[]): boolean {
312
384
  // Garda suspend: timer flush lone-ESC yang dipersenjatai SEBELUM suspend
313
385
  // tetap menembak setelah popup terbuka (listener dilepas, timer tidak).
@@ -361,19 +433,7 @@ export class TuiApp {
361
433
  // = abort + quit. Tanpa ini sesi hanya bisa dibunuh kill -9 (kontrak I14).
362
434
  if (key.type === "esc" || key.type === "ctrl-c") {
363
435
  if (this.busy) {
364
- try {
365
- this.host.abort()
366
- } catch {}
367
- const now = Date.now()
368
- const doubleTap = now - this.lastAbortAt < 1500
369
- // Hint "tekan lagi untuk keluar" SEKALI setelah abort pertama (temuan
370
- // audit TUI-005): tanpa ini user yang menekan Esc dua kali untuk
371
- // "memastikan" justru keluar sesi tanpa sengaja — transkrip TUI hilang.
372
- // Hanya saat TIDAK double-tap; saat menciut indikator tak dilukis.
373
- if (!doubleTap) this.abortHintOn = true
374
- this.lastAbortAt = now
375
- if (doubleTap) this.quit()
376
- else this.paintCurrent()
436
+ this.requestAbort()
377
437
  return
378
438
  }
379
439
  if (this.tooSmall()) return
@@ -500,7 +560,11 @@ export class TuiApp {
500
560
  this.rememberHistory(line)
501
561
  this.transcript.pushUser(rawLine)
502
562
  this.busy = true
563
+ this.turnStartedAt = Date.now()
564
+ this.activityKind = "working"
565
+ this.textSeen = false
503
566
  this.lastAbortAt = 0
567
+ this.startActivityClock()
504
568
  this.paintCurrent()
505
569
  try {
506
570
  const res = await this.host.submit(line)
@@ -509,12 +573,20 @@ export class TuiApp {
509
573
  this.transcript.pushError(e instanceof Error ? e.message : String(e))
510
574
  } finally {
511
575
  this.busy = false
576
+ this.activityKind = "working"
577
+ this.turnStartedAt = 0
578
+ this.textSeen = false
579
+ this.stopActivityClock()
512
580
  if (!this.quitRequested) this.paintCurrent()
513
581
  }
514
582
  }
515
583
 
516
584
  private quit(): void {
517
585
  if (this.quitRequested) return
586
+ try {
587
+ this.host.abort()
588
+ } catch {}
589
+ this.stopActivityClock()
518
590
  this.quitRequested = true
519
591
  this.finish?.()
520
592
  }
@@ -556,6 +628,7 @@ export class TuiApp {
556
628
  try {
557
629
  if (this.onData) this.stdin?.on("data", this.onData)
558
630
  } catch {}
631
+ if (this.busy) this.startActivityClock()
559
632
  this.paintCurrent()
560
633
  }
561
634
 
@@ -567,6 +640,7 @@ export class TuiApp {
567
640
  * setelah anak keluar.
568
641
  */
569
642
  releaseTerminal(): void {
643
+ this.stopActivityClock()
570
644
  try {
571
645
  if (this.onData) this.stdin?.removeListener("data", this.onData)
572
646
  } catch {}
@@ -596,6 +670,7 @@ export class TuiApp {
596
670
  try {
597
671
  this.stdin?.setRawMode(true)
598
672
  } catch {}
673
+ if (this.busy) this.startActivityClock()
599
674
  this.paintCurrent()
600
675
  return true
601
676
  }
@@ -627,7 +702,16 @@ export class TuiApp {
627
702
  const cols = screen.cols
628
703
  const rows = screen.rows
629
704
  const snap = this.host.getStatus()
630
- const statusLine = renderFooter({ ...snap.footer, sparkFrame: 0 }, cols)[0] ?? ""
705
+ const busy = this.busy || snap.busy
706
+ const statusLine =
707
+ renderFooter(
708
+ {
709
+ ...snap.footer,
710
+ activity: this.activityText(snap),
711
+ sparkFrame: busy && !motionReduced() ? this.tick : 0,
712
+ },
713
+ cols,
714
+ )[0] ?? ""
631
715
  const menu = this.menuRows(rows, cols)
632
716
  const inputAll = this.inputRows(cols)
633
717
  const inputH = Math.min(MAX_INPUT_ROWS, Math.max(1, inputAll.length))
@@ -752,6 +836,44 @@ export class TuiApp {
752
836
  this.paintCurrent()
753
837
  }
754
838
 
839
+ private startActivityClock(): void {
840
+ if (this.activityTimer || this.quitRequested) return
841
+ const tick = () => {
842
+ this.activityTimer = undefined
843
+ if (!this.busy || this.quitRequested) return
844
+ if (this.suspended === 0 && !this.released) this.paintCurrent()
845
+ this.startActivityClock()
846
+ }
847
+ this.activityTimer = setTimeout(tick, 200)
848
+ try {
849
+ ;(this.activityTimer as unknown as { unref?: () => void }).unref?.()
850
+ } catch {}
851
+ }
852
+
853
+ private stopActivityClock(): void {
854
+ if (this.activityTimer !== undefined) {
855
+ clearTimeout(this.activityTimer)
856
+ this.activityTimer = undefined
857
+ }
858
+ }
859
+
860
+ private activityText(snap: TuiStatusSnapshot): string | undefined {
861
+ if (!this.busy && !snap.busy) return undefined
862
+ const elapsedStart = this.turnStartedAt || Date.now()
863
+ if (this.activityKind === "stopping") {
864
+ return `${t("app.stopping")} ${formatElapsed(Date.now() - elapsedStart)}`
865
+ }
866
+ const activity = snap.pinnedActivity
867
+ if (activity) {
868
+ const name = sanitizeAnsiLine(activity.name || "tool")
869
+ const target = activity.target ? ` ${sanitizeAnsiLine(activity.target)}` : ""
870
+ const activityStart = Number.isFinite(activity.tsStart) ? activity.tsStart : elapsedStart
871
+ return `${t("app.running")} ${name}${target} ${formatElapsed(Date.now() - activityStart)}`
872
+ }
873
+ const label = this.activityKind === "thinking" ? t("app.thinking") : t("app.working")
874
+ return `${label} ${formatElapsed(Date.now() - elapsedStart)}`
875
+ }
876
+
755
877
  // ── Paint ──
756
878
 
757
879
  private currentScreen: AltScreen | null = null
@@ -848,12 +970,17 @@ export class TuiApp {
848
970
  return
849
971
  }
850
972
  const snap = this.host.getStatus()
973
+ const busy = this.busy || snap.busy
851
974
  // MINICODE_MOTION=0 (temuan audit TUI-006): spark statis redup — status
852
975
  // busy tak boleh bergantung pada animasi (aksesibilitas / rec / SSH lambat).
853
- this.tick = snap.busy ? this.tick + 1 : 0
976
+ this.tick = busy ? this.tick + 1 : 0
854
977
  const statusLine =
855
978
  renderFooter(
856
- { ...snap.footer, sparkFrame: snap.busy && !motionReduced() ? this.tick : 0 },
979
+ {
980
+ ...snap.footer,
981
+ activity: this.activityText(snap),
982
+ sparkFrame: busy && !motionReduced() ? this.tick : 0,
983
+ },
857
984
  cols,
858
985
  )[0] ?? ""
859
986
  const menu = this.menuRows(rows, cols)
@@ -866,8 +993,8 @@ export class TuiApp {
866
993
  // Indikator + hint abort saling eksklusif (satu slot): scroll memakai slot
867
994
  // untuk "baris baru"; abort memakainya untuk petunjuk keluar.
868
995
  const indicator: string[] = []
869
- if (newCount > 0) indicator.push(c.muted(t("app.newBelow", { n: newCount })))
870
- else if (this.busy && this.abortHintOn) indicator.push(c.warning(t("app.abortHint")))
996
+ if (this.busy && this.abortHintOn) indicator.push(c.warning(t("app.abortHint")))
997
+ else if (newCount > 0) indicator.push(c.muted(t("app.newBelow", { n: newCount })))
871
998
  const viewH = Math.max(1, rows - 1 - inputH - menu.length - indicator.length)
872
999
  // Kunci posisi baca: stream yang menambah baris saat user scroll ke atas
873
1000
  // ikut menggeser scrollBack agar jendela menunjuk baris absolut yang sama