minicode-ai 0.28.0 → 0.30.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/README.md +1 -1
- package/cli/args.ts +93 -70
- package/cli/bootstrap/presentation-bridge.ts +383 -0
- package/cli/commands/acp.ts +7 -1
- package/cli/commands/doctor.ts +7 -3
- package/cli/commands/exec.ts +6 -16
- package/cli/index.ts +3 -2
- package/cli/setup.ts +13 -380
- package/cli/tui.ts +3 -4
- package/docs/TERMINAL_CONTRACT.md +28 -21
- package/docs/UI_RENDER_PIPELINE.md +3 -3
- package/docs/architecture.md +14 -29
- package/docs/environment.md +1 -1
- package/package.json +1 -1
- package/src/app/session.ts +201 -53
- package/src/app/tool-layer.ts +27 -0
- package/src/lib/atomic-write.ts +31 -59
- package/src/policy/jail.ts +6 -8
- package/src/providers/anthropic.ts +16 -5
- package/src/providers/responses.ts +37 -7
- package/src/providers/sse-bounds.ts +6 -4
- package/src/session/db/runs.ts +397 -0
- package/src/session/db/schema.ts +358 -0
- package/src/session/persistence.ts +64 -955
- package/src/task/db/schema.ts +325 -0
- package/src/task/db/types.ts +269 -0
- package/src/task/store.ts +74 -986
- package/src/ui/assistant/simple.ts +25 -19
- package/src/ui/i18n/en.ts +0 -3
- package/src/ui/i18n/id.ts +0 -3
- package/src/ui/render/logo.ts +15 -18
- package/src/ui/render/markdown-layout.ts +293 -0
- package/src/ui/render/markdown.ts +36 -44
- package/src/ui/render/session-summary.ts +1 -1
- package/src/ui/render/table-grid.ts +16 -7
- package/src/ui/render/width.ts +71 -18
- package/src/ui/render/wrap.ts +39 -22
- package/src/ui/session-state.ts +4 -4
- package/src/ui/tui/app.ts +15 -36
- package/src/ui/tui/transcript.ts +111 -50
- package/vendor/minicore/src/providers/openai-compat.ts +7 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { effectiveAssistantMargin } from "./markdown-layout.ts"
|
|
1
2
|
import type { MarkdownTable, PipeTableAlignment } from "./markdown-table.ts"
|
|
2
3
|
import { cleanUntrusted, sanitizeAnsiLine, stripSgr } from "./sanitize.ts"
|
|
3
4
|
import { c, getTerminalWidth, glyphs, supportsUtf8 } from "./theme.ts"
|
|
@@ -42,8 +43,6 @@ export interface GridRenderOptions {
|
|
|
42
43
|
|
|
43
44
|
const DEFAULT_MAX_CELL_WIDTH = 50
|
|
44
45
|
const MIN_CONTENT_WIDTH = 3
|
|
45
|
-
/** Margin kiri kotak tabel — biar tidak menempel ke tepi terminal. */
|
|
46
|
-
const BOX_MARGIN = 1
|
|
47
46
|
|
|
48
47
|
function cleanCell(value: unknown): string {
|
|
49
48
|
return cleanUntrusted(
|
|
@@ -212,6 +211,7 @@ function renderBorderedGrid(
|
|
|
212
211
|
aligns: readonly PipeTableAlignment[],
|
|
213
212
|
styleHeader: boolean,
|
|
214
213
|
options: GridRenderOptions,
|
|
214
|
+
margin: number,
|
|
215
215
|
): string {
|
|
216
216
|
const g = supportsUtf8()
|
|
217
217
|
? {
|
|
@@ -290,7 +290,8 @@ function renderBorderedGrid(
|
|
|
290
290
|
for (let li = 0; li < height; li++) out.push(rowLine(cols, li))
|
|
291
291
|
}
|
|
292
292
|
out.push(horiz(g.bl, g.bm, g.br))
|
|
293
|
-
|
|
293
|
+
const pad = margin > 0 ? " ".repeat(margin) : ""
|
|
294
|
+
return pad ? out.map((line) => pad + line).join("\n") : out.join("\n")
|
|
294
295
|
}
|
|
295
296
|
|
|
296
297
|
export function renderGridTable(table: GridTable, options: GridRenderOptions = {}): string {
|
|
@@ -311,9 +312,10 @@ export function renderGridTable(table: GridTable, options: GridRenderOptions = {
|
|
|
311
312
|
: MIN_CONTENT_WIDTH
|
|
312
313
|
// Overhead batas: format kotak `│ c │` memakan 2 kolom lebih banyak per baris
|
|
313
314
|
// (baris batas `│` + padding) daripada format separator lama ` c ` + spasi.
|
|
314
|
-
//
|
|
315
|
+
// Margin kiri kotak tabel diselaraskan dengan margin area teks asisten.
|
|
316
|
+
const boxMargin = options.box ? effectiveAssistantMargin(width) : 0
|
|
315
317
|
const overhead = options.box
|
|
316
|
-
? table.headers.length * 3 + 1 +
|
|
318
|
+
? table.headers.length * 3 + 1 + boxMargin
|
|
317
319
|
: table.headers.length * 3 - 1
|
|
318
320
|
const budget = width - overhead
|
|
319
321
|
const natural = naturalWidths(table, maxCellWidth)
|
|
@@ -330,12 +332,19 @@ export function renderGridTable(table: GridTable, options: GridRenderOptions = {
|
|
|
330
332
|
budget < minimums.reduce((sum, value) => sum + value, 0)
|
|
331
333
|
? null
|
|
332
334
|
: fitWidths(natural, budget, minimums)
|
|
333
|
-
if (!widths)
|
|
335
|
+
if (!widths) {
|
|
336
|
+
const vMargin = options.box ? effectiveAssistantMargin(width) : 0
|
|
337
|
+
const lines = renderVertical(table, Math.max(1, width - vMargin), ellipsis)
|
|
338
|
+
.join("\n")
|
|
339
|
+
.split("\n")
|
|
340
|
+
const pad = vMargin > 0 ? " ".repeat(vMargin) : ""
|
|
341
|
+
return (pad ? lines.map((l) => (l ? pad + l : l)) : lines).join("\n")
|
|
342
|
+
}
|
|
334
343
|
|
|
335
344
|
const aligns = table.aligns ?? table.headers.map(() => "left" as const)
|
|
336
345
|
const styleHeader = options.styleHeader !== false
|
|
337
346
|
|
|
338
|
-
if (options.box) return renderBorderedGrid(table, widths, aligns, styleHeader, options)
|
|
347
|
+
if (options.box) return renderBorderedGrid(table, widths, aligns, styleHeader, options, boxMargin)
|
|
339
348
|
|
|
340
349
|
const separator = c.dim(widths.map((value) => glyphs.hLine.repeat(value + 2)).join(" "))
|
|
341
350
|
|
package/src/ui/render/width.ts
CHANGED
|
@@ -349,13 +349,8 @@ export function padToWidth(s: string, width: number, align: "left" | "right" = "
|
|
|
349
349
|
return align === "right" ? pad + s : s + pad
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
* Dipakai untuk teks tanpa spasi (CJK, URL panjang, hash) yang tidak bisa
|
|
355
|
-
* dipecah di batas kata.
|
|
356
|
-
*/
|
|
357
|
-
export function chunkByWidth(s: string, width: number): string[] {
|
|
358
|
-
if (width <= 0) return [""]
|
|
352
|
+
function chunkByWidthCore(s: string, firstWidth: number, contWidth: number): string[] {
|
|
353
|
+
if (firstWidth <= 0 || contWidth <= 0) return [""]
|
|
359
354
|
const out: string[] = []
|
|
360
355
|
let cur = ""
|
|
361
356
|
let w = 0
|
|
@@ -389,7 +384,8 @@ export function chunkByWidth(s: string, width: number): string[] {
|
|
|
389
384
|
cur += seq
|
|
390
385
|
continue
|
|
391
386
|
}
|
|
392
|
-
|
|
387
|
+
const limit = out.length === 0 ? firstWidth : contWidth
|
|
388
|
+
if (w + token.width > limit && cur !== "") {
|
|
393
389
|
pushChunk()
|
|
394
390
|
}
|
|
395
391
|
cur += token.text
|
|
@@ -399,6 +395,28 @@ export function chunkByWidth(s: string, width: number): string[] {
|
|
|
399
395
|
return out.length ? out : [""]
|
|
400
396
|
}
|
|
401
397
|
|
|
398
|
+
/**
|
|
399
|
+
* Pecah string menjadi potongan per-kolom, dengan anggaran baris pertama dan
|
|
400
|
+
* baris lanjutan terpisah (dipakai word-wrap ber-indentasi gantung).
|
|
401
|
+
*/
|
|
402
|
+
export function chunkByWidthSplit(s: string, firstWidth: number, contWidth: number): string[] {
|
|
403
|
+
return chunkByWidthCore(s, firstWidth, contWidth)
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Pecah string menjadi potongan yang masing-masing <= `width` kolom.
|
|
408
|
+
* Dipakai untuk teks tanpa spasi (CJK, URL panjang, hash) yang tidak bisa
|
|
409
|
+
* dipecah di batas kata.
|
|
410
|
+
*/
|
|
411
|
+
export function chunkByWidth(s: string, width: number): string[] {
|
|
412
|
+
return chunkByWidthCore(s, width, width)
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
export interface WrapByWidthOptions {
|
|
416
|
+
/** Indentasi gantung (kolom spasi) yang disisipkan di awal setiap baris lanjutan. */
|
|
417
|
+
hangingIndent?: string
|
|
418
|
+
}
|
|
419
|
+
|
|
402
420
|
/**
|
|
403
421
|
* Pecah string ke potongan <= `width` kolom, TAPI word-aware: lebih suka
|
|
404
422
|
* memutus di batas kata (spasi) daripada membelah kata di tengah. Token tanpa
|
|
@@ -409,12 +427,22 @@ export function chunkByWidth(s: string, width: number): string[] {
|
|
|
409
427
|
* Spasi yang tepat TIDAK muat menjadi titik putus; spasi itu (dan spasi-trailing
|
|
410
428
|
* yang tak terlihat) dibuang, bukan dipindah ke baris berikutnya.
|
|
411
429
|
*/
|
|
412
|
-
export function wrapByWidth(s: string, width: number): string[] {
|
|
430
|
+
export function wrapByWidth(s: string, width: number, options?: WrapByWidthOptions): string[] {
|
|
413
431
|
if (width <= 0) return [""]
|
|
432
|
+
const rawHang = options?.hangingIndent ?? ""
|
|
433
|
+
const rawHangWidth = rawHang ? displayWidth(rawHang) : 0
|
|
434
|
+
// Jangan biarkan indentasi gantung menutup seluruh lebar baris — minimal 1 kolom isi.
|
|
435
|
+
const effectiveHang = rawHangWidth > 0 && rawHangWidth < width ? rawHang : ""
|
|
436
|
+
const effectiveHangWidth = effectiveHang ? rawHangWidth : 0
|
|
437
|
+
const contBudget = Math.max(1, width - effectiveHangWidth)
|
|
438
|
+
|
|
414
439
|
const out: string[] = []
|
|
415
440
|
let line = ""
|
|
416
441
|
let lineWidth = 0
|
|
442
|
+
let plainIndent = ""
|
|
443
|
+
let lineHasWord = false
|
|
417
444
|
let openSgr: string[] = []
|
|
445
|
+
let openSgrBeforeWord: string[] = []
|
|
418
446
|
let word = ""
|
|
419
447
|
let wordWidth = 0
|
|
420
448
|
|
|
@@ -430,36 +458,56 @@ export function wrapByWidth(s: string, width: number): string[] {
|
|
|
430
458
|
|
|
431
459
|
const flush = (): void => {
|
|
432
460
|
if (line !== "") out.push(openSgr.length > 0 ? `${line}\x1b[0m` : line)
|
|
433
|
-
|
|
434
|
-
|
|
461
|
+
// Indentasi gantung diletakkan SEBELUM SGR terbuka agar spasi margin/indentasi
|
|
462
|
+
// tidak ikut mendapat gaya warna/latar teks di baris lanjutan.
|
|
463
|
+
line = effectiveHang + openSgr.join("")
|
|
464
|
+
lineWidth = effectiveHangWidth
|
|
465
|
+
plainIndent = effectiveHang
|
|
466
|
+
lineHasWord = false
|
|
435
467
|
}
|
|
436
468
|
|
|
437
469
|
const placeWord = (): void => {
|
|
438
470
|
if (wordWidth === 0) {
|
|
471
|
+
if (word) line += word
|
|
439
472
|
word = ""
|
|
473
|
+
openSgrBeforeWord = [...openSgr]
|
|
440
474
|
return
|
|
441
475
|
}
|
|
442
476
|
if (lineWidth + wordWidth <= width) {
|
|
443
477
|
line += word
|
|
444
478
|
lineWidth += wordWidth
|
|
445
|
-
|
|
479
|
+
lineHasWord = true
|
|
480
|
+
} else if (wordWidth <= contBudget) {
|
|
446
481
|
// Kata utuh pindah ke baris berikutnya (bukan dibelah di tengah).
|
|
447
482
|
flush()
|
|
448
483
|
line += word
|
|
449
484
|
lineWidth += wordWidth
|
|
485
|
+
lineHasWord = true
|
|
450
486
|
} else {
|
|
451
|
-
// Token tanpa spasi >
|
|
452
|
-
if (
|
|
453
|
-
const
|
|
487
|
+
// Token tanpa spasi > sisa anggaran: potong per kolom (chunkByWidthCore, sgr-safe).
|
|
488
|
+
if (lineHasWord) flush()
|
|
489
|
+
const firstBudget = Math.max(1, width - lineWidth)
|
|
490
|
+
const pieces = chunkByWidthCore(openSgrBeforeWord.join("") + word, firstBudget, contBudget)
|
|
454
491
|
for (let i = 0; i < pieces.length - 1; i++) {
|
|
492
|
+
const prefix = i === 0 ? plainIndent : effectiveHang
|
|
455
493
|
const piece = pieces[i]!
|
|
456
|
-
out.push(
|
|
494
|
+
out.push(prefix + piece)
|
|
457
495
|
}
|
|
458
|
-
|
|
496
|
+
let lastPiece = pieces[pieces.length - 1] ?? ""
|
|
497
|
+
// Jika masih ada SGR terbuka setelah kata ini, lepas `\x1b[0m` penutup
|
|
498
|
+
// sementara dari chunkByWidthCore agar kata berikutnya di baris yang sama
|
|
499
|
+
// tetap mewarisi gaya aslinya.
|
|
500
|
+
if (openSgr.length > 0 && lastPiece.endsWith("\x1b[0m")) {
|
|
501
|
+
lastPiece = lastPiece.slice(0, -4)
|
|
502
|
+
}
|
|
503
|
+
const lastPrefix = pieces.length === 1 ? plainIndent : effectiveHang
|
|
504
|
+
line = lastPrefix + lastPiece
|
|
459
505
|
lineWidth = displayWidth(line)
|
|
506
|
+
lineHasWord = true
|
|
460
507
|
}
|
|
461
508
|
word = ""
|
|
462
509
|
wordWidth = 0
|
|
510
|
+
openSgrBeforeWord = [...openSgr]
|
|
463
511
|
}
|
|
464
512
|
|
|
465
513
|
for (const token of displayTokens(s)) {
|
|
@@ -475,6 +523,7 @@ export function wrapByWidth(s: string, width: number): string[] {
|
|
|
475
523
|
if (lineWidth + 1 <= width) {
|
|
476
524
|
line += " "
|
|
477
525
|
lineWidth += 1
|
|
526
|
+
if (!lineHasWord) plainIndent += " "
|
|
478
527
|
}
|
|
479
528
|
continue
|
|
480
529
|
}
|
|
@@ -482,6 +531,10 @@ export function wrapByWidth(s: string, width: number): string[] {
|
|
|
482
531
|
wordWidth += token.width
|
|
483
532
|
}
|
|
484
533
|
placeWord()
|
|
485
|
-
if (
|
|
534
|
+
if (out.length === 0 || lineHasWord || lineWidth > effectiveHangWidth) {
|
|
535
|
+
if (line !== "" || out.length === 0) {
|
|
536
|
+
out.push(openSgr.length > 0 ? `${line}\x1b[0m` : line)
|
|
537
|
+
}
|
|
538
|
+
}
|
|
486
539
|
return out.length ? out : [""]
|
|
487
540
|
}
|
package/src/ui/render/wrap.ts
CHANGED
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
// yang di sini tidak ikut diperbaiki saat pola ANSI diperluas untuk sekuens
|
|
9
9
|
// private-mode (ESC[?25l dsb.).
|
|
10
10
|
|
|
11
|
+
import { computeHangingIndent } from "./markdown-layout.ts"
|
|
11
12
|
import { stripAnsi } from "./theme.ts"
|
|
12
|
-
import {
|
|
13
|
+
import { chunkByWidthSplit, displayWidth } from "./width.ts"
|
|
13
14
|
|
|
14
15
|
export { stripAnsi }
|
|
15
16
|
|
|
@@ -34,13 +35,20 @@ export function wordWrap(text: string, width: number): string {
|
|
|
34
35
|
out.push(line)
|
|
35
36
|
continue
|
|
36
37
|
}
|
|
38
|
+
const hang = computeHangingIndent(line, width)
|
|
39
|
+
const hangWidth = hang ? displayWidth(hang) : 0
|
|
37
40
|
let current = ""
|
|
41
|
+
let lineIndex = 0
|
|
42
|
+
const emitLine = (textOut: string) => {
|
|
43
|
+
out.push(textOut)
|
|
44
|
+
lineIndex++
|
|
45
|
+
}
|
|
38
46
|
const flush = () => {
|
|
39
|
-
if (current !== "") {
|
|
47
|
+
if (current !== "" && (lineIndex === 0 || current.trim() !== "")) {
|
|
40
48
|
// Spasi pemisah di ujung tidak ikut tampil.
|
|
41
|
-
|
|
42
|
-
current = ""
|
|
49
|
+
emitLine(current.trimEnd())
|
|
43
50
|
}
|
|
51
|
+
current = ""
|
|
44
52
|
}
|
|
45
53
|
// Pisah dengan pemisah tertangkap agar spasi ganda (ASCII art/tabel)
|
|
46
54
|
// tetap utuh — run whitespace menempel ke kata berikut, wrap hanya putus
|
|
@@ -56,25 +64,35 @@ export function wordWrap(text: string, width: number): string {
|
|
|
56
64
|
continue
|
|
57
65
|
}
|
|
58
66
|
const word = tok
|
|
59
|
-
|
|
60
|
-
|
|
67
|
+
const contBudget = Math.max(1, width - hangWidth)
|
|
68
|
+
// Kata tunggal lebih lebar dari sisa lebar baris lanjutan: pecah paksa per kolom.
|
|
69
|
+
if (
|
|
70
|
+
displayWidth(word) > contBudget &&
|
|
71
|
+
(displayWidth(word) > width || current.trim() !== "")
|
|
72
|
+
) {
|
|
61
73
|
// Indentasi (bila ada) menempel ke potongan PERTAMA dan menyusutkan
|
|
62
74
|
// lebar potongan itu — tanpa ini indentasi hilang atau baris meluap.
|
|
63
75
|
const lead = current.trim() === "" ? current : ""
|
|
64
76
|
// Teks yang sudah terkumpul (bila ada) ditutup dulu; hanya indentasi
|
|
65
77
|
// murni yang ikut menempel ke potongan pertama.
|
|
66
|
-
if (current.trim() !== "")
|
|
78
|
+
if (current.trim() !== "") emitLine(current.trimEnd())
|
|
67
79
|
current = ""
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
const firstPrefix = lineIndex === 0 ? lead : hang
|
|
81
|
+
const firstPrefixWidth = displayWidth(firstPrefix)
|
|
82
|
+
const availFirst = Math.max(1, width - firstPrefixWidth)
|
|
83
|
+
if (displayWidth(word) <= availFirst) {
|
|
84
|
+
current = firstPrefix + word
|
|
85
|
+
continue
|
|
86
|
+
}
|
|
87
|
+
// Potong bagian pertama sepas `availFirst`, sisanya mengikuti `contBudget`
|
|
88
|
+
// (SGR-safe via chunkByWidthSplit agar warna tetap terbawa utuh).
|
|
89
|
+
const pieces = chunkByWidthSplit(word, availFirst, contBudget)
|
|
90
|
+
if (pieces.length > 0) {
|
|
91
|
+
emitLine(firstPrefix + (pieces[0] ?? ""))
|
|
92
|
+
for (let i = 1; i < pieces.length - 1; i++) {
|
|
93
|
+
emitLine(hang + pieces[i]!)
|
|
94
|
+
}
|
|
95
|
+
current = pieces.length > 1 ? hang + (pieces[pieces.length - 1] ?? "") : ""
|
|
78
96
|
}
|
|
79
97
|
continue
|
|
80
98
|
}
|
|
@@ -82,12 +100,11 @@ export function wordWrap(text: string, width: number): string {
|
|
|
82
100
|
// hanya bila tidak ada pemisah di antara dua kata.
|
|
83
101
|
const glued = !current || /\s$/.test(current) ? `${current}${word}` : `${current} ${word}`
|
|
84
102
|
if (displayWidth(glued) > width && current.trim() !== "") {
|
|
85
|
-
|
|
86
|
-
current = word
|
|
103
|
+
emitLine(current.trimEnd())
|
|
104
|
+
current = hang && displayWidth(hang) + displayWidth(word) <= width ? hang + word : word
|
|
87
105
|
} else if (displayWidth(glued) > width) {
|
|
88
|
-
// Indentasi + kata tak muat bersama: indentasi
|
|
89
|
-
|
|
90
|
-
current = word
|
|
106
|
+
// Indentasi + kata tak muat bersama: lepas indentasi berlebih atau pakai hang.
|
|
107
|
+
current = hang && displayWidth(hang) + displayWidth(word) <= width ? hang + word : word
|
|
91
108
|
} else {
|
|
92
109
|
current = glued
|
|
93
110
|
}
|
package/src/ui/session-state.ts
CHANGED
|
@@ -72,10 +72,10 @@ export class UiSessionState {
|
|
|
72
72
|
this.#minimizeAnswer = opts.minimizeAnswer ?? process.env.MINICODE_MINIMIZE_ANSWER === "1"
|
|
73
73
|
this.#minimizeTool = opts.minimizeTool ?? process.env.MINICODE_MINIMIZE_TOOL === "1"
|
|
74
74
|
this.#compact = opts.compact ?? process.env.MINICODE_COMPACT === "1"
|
|
75
|
-
// Thinking/teks berpikir
|
|
76
|
-
//
|
|
77
|
-
//
|
|
78
|
-
this.#reasoningVisible = opts.reasoningVisible ?? process.env.MINICODE_SHOW_THINKING
|
|
75
|
+
// Thinking/teks berpikir TERSEMBUNYI secara default agar transkrip bersih;
|
|
76
|
+
// user tetap bisa membukanya lewat `/thinking`, `Ctrl+T`, `--verbose`, atau
|
|
77
|
+
// `MINICODE_SHOW_THINKING=1` (indikator dots di composer tetap hidup).
|
|
78
|
+
this.#reasoningVisible = opts.reasoningVisible ?? process.env.MINICODE_SHOW_THINKING === "1"
|
|
79
79
|
// Lipat aktivitas tool per turn (opencode-like): baris ledger per-tool
|
|
80
80
|
// ditahan, diganti satu ringkasan turn. Opt-in (`MINICODE_MINIMIZE_ACTIVITY=1`),
|
|
81
81
|
// default transparan sesuai filosofi "agentic Unix shell".
|
package/src/ui/tui/app.ts
CHANGED
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
import { appendWrapped, shaveWrapped } from "../render/composer-wrap.ts"
|
|
27
27
|
import { formatError } from "../render/errors.ts"
|
|
28
28
|
import { listRow } from "../render/list.ts"
|
|
29
|
+
import { LOGO_WIDTH, renderLogoRows } from "../render/logo.ts"
|
|
29
30
|
import { sanitizeAnsi, sanitizeAnsiLine, stripSgr } from "../render/sanitize.ts"
|
|
30
31
|
import { c, glyphs, scrimMode, scrimSgr } from "../render/theme.ts"
|
|
31
32
|
import { chunkByWidth, displayWidth, escapeLength, truncateToWidth } from "../render/width.ts"
|
|
@@ -257,7 +258,7 @@ export class TuiApp {
|
|
|
257
258
|
private lastAbortAt = 0
|
|
258
259
|
/** Hint "tekan lagi untuk keluar" tampil sekali setelah abort pertama. */
|
|
259
260
|
private abortHintOn = false
|
|
260
|
-
/** Micro-toast 2 detik di slot footer saat mengganti
|
|
261
|
+
/** Micro-toast 2 detik di slot footer saat mengganti bahasa/salin. */
|
|
261
262
|
private statusToast = ""
|
|
262
263
|
private toastTimer: ReturnType<typeof setTimeout> | undefined
|
|
263
264
|
private frames = 0
|
|
@@ -784,21 +785,15 @@ export class TuiApp {
|
|
|
784
785
|
return
|
|
785
786
|
}
|
|
786
787
|
this.host.cycleWorkMode(1)
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
this.showToast(t("tui.workModeLine", { m: label }))
|
|
791
|
-
} else {
|
|
792
|
-
this.paintCurrent()
|
|
793
|
-
}
|
|
788
|
+
// Pembaruan WorkMode langsung mengubah label di bar footer tanpa
|
|
789
|
+
// menutup footer dengan toast sementara.
|
|
790
|
+
this.paintCurrent()
|
|
794
791
|
return
|
|
795
792
|
}
|
|
796
793
|
if (key.type === "shift-tab") {
|
|
797
794
|
this.host.togglePermissionMode()
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
if (label) this.showToast(t("tui.modeLine", { m: label }))
|
|
801
|
-
else this.paintCurrent()
|
|
795
|
+
// Pembaruan PermissionMode langsung mengubah label di bar footer.
|
|
796
|
+
this.paintCurrent()
|
|
802
797
|
return
|
|
803
798
|
}
|
|
804
799
|
if (key.type === "ctrl-o") {
|
|
@@ -1919,30 +1914,14 @@ export class TuiApp {
|
|
|
1919
1914
|
const selected = this.selectedRange(row)
|
|
1920
1915
|
return selected ? highlightColumns(row.text, selected.start, selected.end) : row.text
|
|
1921
1916
|
})
|
|
1922
|
-
// Zero-state
|
|
1923
|
-
//
|
|
1924
|
-
if (
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
width >= 24
|
|
1931
|
-
) {
|
|
1932
|
-
const dot = glyphs.dot
|
|
1933
|
-
const innerMax = Math.max(8, width - 4)
|
|
1934
|
-
const model = sanitizeAnsiLine(snap.footer.model || t("tui.noModel"))
|
|
1935
|
-
const cwdText = sanitizeAnsiLine(snap.footer.cwd || "")
|
|
1936
|
-
const welcome = [
|
|
1937
|
-
c.bold(c.accent(truncateToWidth(t("app.welcomeTitle", { dot, model }), innerMax))),
|
|
1938
|
-
...(cwdText
|
|
1939
|
-
? [c.dim(truncateToWidth(t("app.welcomeCwd", { cwd: cwdText }), innerMax))]
|
|
1940
|
-
: []),
|
|
1941
|
-
c.muted(truncateToWidth(t("app.welcomeHints", { dot }), innerMax)),
|
|
1942
|
-
]
|
|
1943
|
-
const startRow = Math.max(0, Math.floor((body.length - welcome.length) / 2))
|
|
1944
|
-
for (let wi = 0; wi < welcome.length && startRow + wi < body.length; wi++) {
|
|
1945
|
-
body[startRow + wi] = ` ${welcome[wi]!}`
|
|
1917
|
+
// Zero-state boot: tampilkan hanya logo kecil minicode di pojok kiri atas
|
|
1918
|
+
// tanpa blok identitas/hint di atas prompt & footer agar tampilan awal clean.
|
|
1919
|
+
if (this.transcript.total() === 0 && !busy && menu.length === 0 && !this.state.line) {
|
|
1920
|
+
const logoRows = renderLogoRows()
|
|
1921
|
+
if (viewH >= logoRows.length && width >= LOGO_WIDTH + 2) {
|
|
1922
|
+
for (let wi = 0; wi < logoRows.length; wi++) {
|
|
1923
|
+
body[wi] = ` ${c.accent(logoRows[wi]!)}`
|
|
1924
|
+
}
|
|
1946
1925
|
}
|
|
1947
1926
|
}
|
|
1948
1927
|
|