@sagmans/dsh-tui 0.1.2 → 0.3.0

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.
Files changed (158) hide show
  1. package/README.md +196 -17
  2. package/cordis.patch.yml +4 -2
  3. package/lib/agent/host.d.ts +14 -0
  4. package/lib/agent/host.d.ts.map +1 -1
  5. package/lib/agent/host.js +20 -4
  6. package/lib/agent/host.js.map +1 -1
  7. package/lib/agent/model.d.ts +50 -0
  8. package/lib/agent/model.d.ts.map +1 -1
  9. package/lib/agent/model.js +87 -1
  10. package/lib/agent/model.js.map +1 -1
  11. package/lib/agent/present.d.ts +7 -1
  12. package/lib/agent/present.d.ts.map +1 -1
  13. package/lib/agent/present.js +33 -4
  14. package/lib/agent/present.js.map +1 -1
  15. package/lib/agent/presets.d.ts +7 -1
  16. package/lib/agent/presets.d.ts.map +1 -1
  17. package/lib/agent/presets.js +7 -3
  18. package/lib/agent/presets.js.map +1 -1
  19. package/lib/agent/status.d.ts +10 -0
  20. package/lib/agent/status.d.ts.map +1 -1
  21. package/lib/agent/status.js +2 -0
  22. package/lib/agent/status.js.map +1 -1
  23. package/lib/cards.d.ts +127 -7
  24. package/lib/cards.d.ts.map +1 -1
  25. package/lib/cards.js +381 -52
  26. package/lib/cards.js.map +1 -1
  27. package/lib/export.d.ts +5 -4
  28. package/lib/export.d.ts.map +1 -1
  29. package/lib/export.js +62 -13
  30. package/lib/export.js.map +1 -1
  31. package/lib/fold-cursor.d.ts +23 -0
  32. package/lib/fold-cursor.d.ts.map +1 -0
  33. package/lib/fold-cursor.js +31 -0
  34. package/lib/fold-cursor.js.map +1 -0
  35. package/lib/gates.d.ts +145 -2
  36. package/lib/gates.d.ts.map +1 -1
  37. package/lib/gates.js +335 -40
  38. package/lib/gates.js.map +1 -1
  39. package/lib/index.d.ts +7 -1
  40. package/lib/index.d.ts.map +1 -1
  41. package/lib/index.js +651 -92
  42. package/lib/index.js.map +1 -1
  43. package/lib/input/actions.d.ts +136 -0
  44. package/lib/input/actions.d.ts.map +1 -0
  45. package/lib/input/actions.js +740 -0
  46. package/lib/input/actions.js.map +1 -0
  47. package/lib/input/keymap-settings.d.ts +21 -0
  48. package/lib/input/keymap-settings.d.ts.map +1 -0
  49. package/lib/input/keymap-settings.js +28 -0
  50. package/lib/input/keymap-settings.js.map +1 -0
  51. package/lib/input/keymap.d.ts +91 -0
  52. package/lib/input/keymap.d.ts.map +1 -0
  53. package/lib/input/keymap.js +170 -0
  54. package/lib/input/keymap.js.map +1 -0
  55. package/lib/input/match.d.ts +10 -0
  56. package/lib/input/match.d.ts.map +1 -0
  57. package/lib/input/match.js +83 -0
  58. package/lib/input/match.js.map +1 -0
  59. package/lib/input/submission.d.ts +8 -1
  60. package/lib/input/submission.d.ts.map +1 -1
  61. package/lib/input/submission.js +9 -2
  62. package/lib/input/submission.js.map +1 -1
  63. package/lib/input.d.ts +17 -0
  64. package/lib/input.d.ts.map +1 -0
  65. package/lib/input.js +27 -0
  66. package/lib/input.js.map +1 -0
  67. package/lib/keys-command.d.ts +16 -0
  68. package/lib/keys-command.d.ts.map +1 -0
  69. package/lib/keys-command.js +60 -0
  70. package/lib/keys-command.js.map +1 -0
  71. package/lib/queue.d.ts +6 -0
  72. package/lib/queue.d.ts.map +1 -0
  73. package/lib/queue.js +68 -0
  74. package/lib/queue.js.map +1 -0
  75. package/lib/settings-notice.d.ts +19 -0
  76. package/lib/settings-notice.d.ts.map +1 -0
  77. package/lib/settings-notice.js +30 -0
  78. package/lib/settings-notice.js.map +1 -0
  79. package/lib/terminal/warning-screen.d.ts +8 -0
  80. package/lib/terminal/warning-screen.d.ts.map +1 -0
  81. package/lib/terminal/warning-screen.js +66 -0
  82. package/lib/terminal/warning-screen.js.map +1 -0
  83. package/lib/theme-capability.d.ts +36 -0
  84. package/lib/theme-capability.d.ts.map +1 -0
  85. package/lib/theme-capability.js +190 -0
  86. package/lib/theme-capability.js.map +1 -0
  87. package/lib/theme-command.d.ts +10 -0
  88. package/lib/theme-command.d.ts.map +1 -0
  89. package/lib/theme-command.js +61 -0
  90. package/lib/theme-command.js.map +1 -0
  91. package/lib/theme-settings.d.ts +196 -0
  92. package/lib/theme-settings.d.ts.map +1 -0
  93. package/lib/theme-settings.js +229 -0
  94. package/lib/theme-settings.js.map +1 -0
  95. package/lib/theme-tokens.d.ts +110 -0
  96. package/lib/theme-tokens.d.ts.map +1 -0
  97. package/lib/theme-tokens.js +427 -0
  98. package/lib/theme-tokens.js.map +1 -0
  99. package/lib/theme.d.ts +32 -35
  100. package/lib/theme.d.ts.map +1 -1
  101. package/lib/theme.js +112 -63
  102. package/lib/theme.js.map +1 -1
  103. package/lib/tokens.d.ts +15 -0
  104. package/lib/tokens.d.ts.map +1 -0
  105. package/lib/tokens.js +29 -0
  106. package/lib/tokens.js.map +1 -0
  107. package/lib/transcript.d.ts +26 -1
  108. package/lib/transcript.d.ts.map +1 -1
  109. package/lib/transcript.js +153 -25
  110. package/lib/transcript.js.map +1 -1
  111. package/lib/ui/dock.d.ts.map +1 -1
  112. package/lib/ui/dock.js +67 -28
  113. package/lib/ui/dock.js.map +1 -1
  114. package/lib/ui/editor.d.ts +51 -0
  115. package/lib/ui/editor.d.ts.map +1 -0
  116. package/lib/ui/editor.js +159 -0
  117. package/lib/ui/editor.js.map +1 -0
  118. package/lib/ui/frame.d.ts +54 -0
  119. package/lib/ui/frame.d.ts.map +1 -0
  120. package/lib/ui/frame.js +79 -0
  121. package/lib/ui/frame.js.map +1 -0
  122. package/lib/ui/gate-input.d.ts +20 -0
  123. package/lib/ui/gate-input.d.ts.map +1 -0
  124. package/lib/ui/gate-input.js +96 -0
  125. package/lib/ui/gate-input.js.map +1 -0
  126. package/lib/ui/markdown.d.ts +19 -2
  127. package/lib/ui/markdown.d.ts.map +1 -1
  128. package/lib/ui/markdown.js +37 -6
  129. package/lib/ui/markdown.js.map +1 -1
  130. package/lib/ui/mermaid.d.ts +44 -0
  131. package/lib/ui/mermaid.d.ts.map +1 -0
  132. package/lib/ui/mermaid.js +178 -0
  133. package/lib/ui/mermaid.js.map +1 -0
  134. package/lib/ui/picker.d.ts +66 -7
  135. package/lib/ui/picker.d.ts.map +1 -1
  136. package/lib/ui/picker.js +112 -19
  137. package/lib/ui/picker.js.map +1 -1
  138. package/lib/ui/prompt.d.ts +30 -0
  139. package/lib/ui/prompt.d.ts.map +1 -0
  140. package/lib/ui/prompt.js +45 -0
  141. package/lib/ui/prompt.js.map +1 -0
  142. package/lib/ui/queue.d.ts +24 -0
  143. package/lib/ui/queue.d.ts.map +1 -0
  144. package/lib/ui/queue.js +57 -0
  145. package/lib/ui/queue.js.map +1 -0
  146. package/lib/ui/status.d.ts +7 -1
  147. package/lib/ui/status.d.ts.map +1 -1
  148. package/lib/ui/status.js +84 -24
  149. package/lib/ui/status.js.map +1 -1
  150. package/lib/ui/view.d.ts +65 -2
  151. package/lib/ui/view.d.ts.map +1 -1
  152. package/lib/ui/view.js +319 -59
  153. package/lib/ui/view.js.map +1 -1
  154. package/lib/work.d.ts +48 -0
  155. package/lib/work.d.ts.map +1 -1
  156. package/lib/work.js +44 -0
  157. package/lib/work.js.map +1 -1
  158. package/package.json +5 -2
@@ -0,0 +1,24 @@
1
+ import type { Component } from '@earendil-works/pi-tui';
2
+ import type { TuiTheme } from '../theme.ts';
3
+ /** Queued prompts the bar draws; everything older becomes one count above them. */
4
+ export declare const QUEUE_LIMIT = 3;
5
+ /** Text rows one queued prompt keeps before its own count takes over. */
6
+ export declare const QUEUE_TEXT_ROWS = 3;
7
+ /**
8
+ * The prompts the agent has not taken yet, drawn above the editor.
9
+ *
10
+ * The rows take the editor's own frame because that is what they are: input the
11
+ * reader already submitted, waiting for the agent to reach it. Only the face
12
+ * differs — faint and italic — so a reader can tell at a glance that the text is
13
+ * waiting rather than being typed.
14
+ */
15
+ export declare class QueueBar implements Component {
16
+ private readonly prompts;
17
+ private readonly theme;
18
+ constructor(prompts: () => readonly string[], theme: TuiTheme);
19
+ invalidate(): void;
20
+ /** One queued prompt as the editor bar's own box, drawn in the queued face. */
21
+ private box;
22
+ render(width: number): string[];
23
+ }
24
+ //# sourceMappingURL=queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/ui/queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAG3C,mFAAmF;AACnF,eAAO,MAAM,WAAW,IAAI,CAAA;AAC5B,yEAAyE;AACzE,eAAO,MAAM,eAAe,IAAI,CAAA;AAEhC;;;;;;;GAOG;AACH,qBAAa,QAAS,YAAW,SAAS;IAEtC,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,KAAK;gBADL,OAAO,EAAE,MAAM,SAAS,MAAM,EAAE,EAChC,KAAK,EAAE,QAAQ;IAGlC,UAAU,IAAI,IAAI;IAIlB,+EAA+E;IAC/E,OAAO,CAAC,GAAG;IAUX,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;CAkBhC"}
@@ -0,0 +1,57 @@
1
+ import { canFrame, frameText } from "./frame.js";
2
+ /** Queued prompts the bar draws; everything older becomes one count above them. */
3
+ export const QUEUE_LIMIT = 3;
4
+ /** Text rows one queued prompt keeps before its own count takes over. */
5
+ export const QUEUE_TEXT_ROWS = 3;
6
+ /**
7
+ * The prompts the agent has not taken yet, drawn above the editor.
8
+ *
9
+ * The rows take the editor's own frame because that is what they are: input the
10
+ * reader already submitted, waiting for the agent to reach it. Only the face
11
+ * differs — faint and italic — so a reader can tell at a glance that the text is
12
+ * waiting rather than being typed.
13
+ */
14
+ export class QueueBar {
15
+ prompts;
16
+ theme;
17
+ constructor(prompts, theme) {
18
+ this.prompts = prompts;
19
+ this.theme = theme;
20
+ }
21
+ invalidate() {
22
+ // Nothing is cached: the prompts are read fresh on every frame.
23
+ }
24
+ /** One queued prompt as the editor bar's own box, drawn in the queued face. */
25
+ box(text, width, framed) {
26
+ // A prompt can be longer than the screen; the reader needs to see that it is
27
+ // waiting, not to re-read all of it, so the first rows stand for the whole.
28
+ return frameText(text, width, {
29
+ text: line => this.theme.style('editor.queued', line),
30
+ border: rule => this.theme.editor.borderColor(rule),
31
+ framed,
32
+ }, QUEUE_TEXT_ROWS);
33
+ }
34
+ render(width) {
35
+ if (width <= 0)
36
+ return [];
37
+ const prompts = this.prompts();
38
+ if (prompts.length === 0)
39
+ return [];
40
+ // Hiding the face hides the rows: a frame around text the reader cannot read
41
+ // would look like an empty prompt waiting to be typed into.
42
+ if (!this.theme.visible('editor.queued'))
43
+ return [];
44
+ const framed = canFrame(width, this.theme.visible('editor.border'));
45
+ const shown = prompts.slice(-QUEUE_LIMIT);
46
+ const lines = [];
47
+ // The reader typed the newest prompt last, so that is the row that must stay
48
+ // on screen; the ones dropped here are the ones a claim is about to take.
49
+ if (shown.length < prompts.length) {
50
+ lines.push(this.theme.style('editor.queued.more', this.theme.cut(`… ${prompts.length - shown.length} queued earlier`, width, '…')));
51
+ }
52
+ for (const prompt of shown)
53
+ lines.push(...this.box(prompt, width, framed));
54
+ return lines;
55
+ }
56
+ }
57
+ //# sourceMappingURL=queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/ui/queue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEhD,mFAAmF;AACnF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAA;AAC5B,yEAAyE;AACzE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAA;AAEhC;;;;;;;GAOG;AACH,MAAM,OAAO,QAAQ;IAEA;IACA;IAFnB,YACmB,OAAgC,EAChC,KAAe;QADf,YAAO,GAAP,OAAO,CAAyB;QAChC,UAAK,GAAL,KAAK,CAAU;IAC/B,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,CAAC,MAAM,iBAAiB,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,CAAA;QACrI,CAAC;QACD,KAAK,MAAM,MAAM,IAAI,KAAK;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;QAC1E,OAAO,KAAK,CAAA;IACd,CAAC;CACF"}
@@ -2,6 +2,10 @@ import { type Component } from '@earendil-works/pi-tui';
2
2
  import type { TuiTheme } from '../theme.ts';
3
3
  /** Everything the footer states, gathered by the surface around it. */
4
4
  export interface StatusFacts {
5
+ /** The chord waiting for its second key, when one is armed. */
6
+ readonly chord: string | undefined;
7
+ /** How the reader returns to the session this terminal drives, when another is on screen. */
8
+ readonly back: string | undefined;
5
9
  readonly activity: 'idle' | 'working';
6
10
  /** How long the running turn has been running, when one is. */
7
11
  readonly elapsedMs: number | undefined;
@@ -24,7 +28,6 @@ export interface StatusFacts {
24
28
  readonly home: string | undefined;
25
29
  }
26
30
  /** Compact a token count, because the exact number changes nothing a reader decides. */
27
- export declare function formatTokens(count: number): string;
28
31
  /**
29
32
  * Shorten an absolute path for the footer: the reader's own home becomes `~`,
30
33
  * and only a path from outside it is cut down to its tail.
@@ -36,6 +39,9 @@ export declare function shortPath(path: string, home: string | undefined): strin
36
39
  /**
37
40
  * One line of state, ordered by what a reader asks first: is it working, what is
38
41
  * it, how full is the context, and where am I.
42
+ *
43
+ * Each segment is its own element, so a reader can quiet the path without
44
+ * losing the model, and the separator is one too.
39
45
  */
40
46
  export declare function formatStatus(facts: StatusFacts, width: number, theme: TuiTheme): string;
41
47
  /** A one-row view of the state around the transcript. */
@@ -1 +1 @@
1
- {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/ui/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAmB,MAAM,wBAAwB,CAAA;AAExE,OAAO,KAAK,EAAE,QAAQ,EAAE,M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AAS,EAAE,MAAM,GAAG,SAAS,CAAA;IACtC,4EAA4E;IAC5E,QAAQ,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAA;IAChD,yEAAyE;IACzE,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;IACzC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;CAClC;AAsBD,wFAAwF;AAExF;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAQxE;AAOD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,MAAM,CA4CvF;AAsCD,yDAAyD;AACzD,qBAAa,SAAU,YAAW,SAAS;IAEvC,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,KAAK;gBADL,KAAK,EAAE,MAAM,WAAW,EACxB,KAAK,EAAE,QAAQ;IAGlC,UAAU,IAAI,IAAI;IAIlB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;CAGhC"}
package/lib/ui/status.js CHANGED
@@ -1,23 +1,18 @@
1
- import { truncateToWidth } from '@earendil-works/pi-tui';
1
+ import { visibleWidth } from '@earendil-works/pi-tui';
2
2
  import { displayText } from "../text.js";
3
- const THOUSAND = 1000;
4
- const HUNDRED_THOUSAND = 100 * THOUSAND;
5
- const MILLION = 1_000_000;
3
+ import { formatTokens } from "../tokens.js";
6
4
  const SECOND_MS = 1000;
7
5
  const MINUTE_MS = 60 * SECOND_MS;
8
6
  /** Path segments kept for a directory outside the home; a terminal row is not a file browser. */
9
7
  const PATH_SEGMENTS = 2;
8
+ /** What sits between two facts that do not qualify each other. */
9
+ const SEPARATOR_TEXT = ' · ';
10
+ /** Marks the point where a row was cut; the reader must know something is missing. */
11
+ const ELLIPSIS = '…';
12
+ /** The mark that says which of the two activities the session is in. */
13
+ const WORKING_MARK = '▶';
14
+ const READY_MARK = '●';
10
15
  /** Compact a token count, because the exact number changes nothing a reader decides. */
11
- export function formatTokens(count) {
12
- if (count >= MILLION)
13
- return `${(count / MILLION).toFixed(1)}M`;
14
- // A decimal on a five-digit count is noise: 128.0k reads worse than 128k.
15
- if (count >= HUNDRED_THOUSAND)
16
- return `${Math.round(count / THOUSAND)}k`;
17
- if (count >= THOUSAND)
18
- return `${(count / THOUSAND).toFixed(1)}k`;
19
- return String(count);
20
- }
21
16
  /**
22
17
  * Shorten an absolute path for the footer: the reader's own home becomes `~`,
23
18
  * and only a path from outside it is cut down to its tail.
@@ -43,34 +38,99 @@ function elapsed(ms) {
43
38
  /**
44
39
  * One line of state, ordered by what a reader asks first: is it working, what is
45
40
  * it, how full is the context, and where am I.
41
+ *
42
+ * Each segment is its own element, so a reader can quiet the path without
43
+ * losing the model, and the separator is one too.
46
44
  */
47
45
  export function formatStatus(facts, width, theme) {
48
- const parts = [];
46
+ const segments = [];
47
+ /**
48
+ * Content is escaped as it is collected, and styling is applied only after the
49
+ * row has been cut to width. Styling earlier would put generated control
50
+ * characters in reach of `displayText`, which exists to make control
51
+ * characters visible, so a segment would print its own colour as text.
52
+ */
53
+ const push = (token, text, join = false) => {
54
+ if (!theme.visible(token))
55
+ return;
56
+ segments.push({ token, text: displayText(text), join });
57
+ };
58
+ // An armed chord is transient and needs the reader's eye now, so it leads the
59
+ // row: a row cut to width loses its tail, never what is about to happen.
60
+ if (facts.chord !== undefined && facts.chord !== '')
61
+ push('status.prefix', facts.chord);
62
+ // The way back is the other thing the reader may need at once: a transcript of
63
+ // a session they are not driving is exactly when they need it.
64
+ if (facts.back !== undefined && facts.back !== '')
65
+ push('status.back', facts.back);
49
66
  if (facts.activity === 'working') {
50
- parts.push(facts.elapsedMs === undefined ? '▶ working' : `▶ working ${elapsed(facts.elapsedMs)}`);
67
+ push('status.activity.working', `${WORKING_MARK} working`);
68
+ // Elapsed carries its own token so it can be toned apart from the activity,
69
+ // but it qualifies that activity, so it attaches rather than standing alone.
70
+ if (facts.elapsedMs !== undefined)
71
+ push('status.elapsed', ` ${elapsed(facts.elapsedMs)}`, true);
51
72
  }
52
73
  else {
53
- parts.push('● ready');
74
+ push('status.activity.ready', `${READY_MARK} ready`);
54
75
  }
55
76
  // The mode comes first: it decides which tools exist at all, so a reader who
56
77
  // saw a tool disappear needs it before the model that ran it.
57
78
  if (facts.agentPreset !== undefined && facts.agentPreset !== '')
58
- parts.push(facts.agentPreset);
79
+ push('status.agentPreset', facts.agentPreset);
59
80
  if (facts.model !== undefined && facts.model !== '') {
60
81
  const route = facts.provider === undefined || facts.provider === '' ? facts.model : `${facts.provider}/${facts.model}`;
61
- parts.push(facts.effort === undefined || facts.effort === '' ? route : `${route} (${facts.effort})`);
82
+ push('status.model', route);
83
+ // The effort qualifies the model, so it reads as part of it.
84
+ if (facts.effort !== undefined && facts.effort !== '')
85
+ push('status.effort', ` (${facts.effort})`, true);
62
86
  }
63
87
  if (facts.preset !== undefined && facts.preset !== '')
64
- parts.push(facts.preset);
88
+ push('status.permission', facts.preset);
65
89
  if (facts.contextTokens !== undefined) {
66
- parts.push(facts.contextWindow === undefined
90
+ push('status.context', facts.contextWindow === undefined
67
91
  ? `ctx ${formatTokens(facts.contextTokens)}`
68
92
  : `ctx ${formatTokens(facts.contextTokens)}/${formatTokens(facts.contextWindow)}`);
69
93
  }
70
94
  if (facts.cacheRate !== undefined)
71
- parts.push(`cache ${Math.round(facts.cacheRate * 100)}%`);
72
- parts.push(shortPath(facts.cwd, facts.home));
73
- return theme.dim(truncateToWidth(displayText(parts.join(' · ')), width, '…'));
95
+ push('status.cache', `cache ${Math.round(facts.cacheRate * 100)}%`);
96
+ push('status.cwd', shortPath(facts.cwd, facts.home));
97
+ return renderSegments(segments, width, theme);
98
+ }
99
+ /**
100
+ * Join styled segments into one row, cutting it to width first.
101
+ *
102
+ * The cut runs on unstyled text so it can never land inside a style and leave
103
+ * one open, and each segment is trimmed to the room left rather than dropped:
104
+ * a reader loses the tail of the last fact, not the fact, and the ellipsis
105
+ * still says that something was left out.
106
+ */
107
+ function renderSegments(segments, width, theme) {
108
+ // Hiding the separator means drawing no separator, not drawing a plain one:
109
+ // "hidden" is the one promise the reader cannot see half-kept.
110
+ const showSeparator = theme.visible('status.separator');
111
+ const separator = showSeparator ? theme.style('status.separator', SEPARATOR_TEXT) : '';
112
+ const ellipsisWidth = visibleWidth(ELLIPSIS);
113
+ let out = '';
114
+ let budget = width;
115
+ for (const [index, segment] of segments.entries()) {
116
+ const joining = index === 0 || segment.join;
117
+ const lead = joining || !showSeparator ? 0 : visibleWidth(SEPARATOR_TEXT);
118
+ // A separator is drawn only alongside text, so there must be room for the
119
+ // separator and at least the mark that something was cut.
120
+ if (budget - lead < ellipsisWidth)
121
+ break;
122
+ const room = budget - lead;
123
+ const textWidth = visibleWidth(segment.text);
124
+ if (textWidth > room) {
125
+ // Not the last segment: the rest is omitted, so the row must show it.
126
+ const cut = theme.cut(segment.text, room, ELLIPSIS);
127
+ out += `${lead > 0 ? separator : ''}${theme.style(segment.token, cut)}`;
128
+ return out;
129
+ }
130
+ out += `${lead > 0 ? separator : ''}${theme.style(segment.token, segment.text)}`;
131
+ budget -= lead + textWidth;
132
+ }
133
+ return out === '' ? theme.cut('', Math.max(0, width), ELLIPSIS) : out;
74
134
  }
75
135
  /** A one-row view of the state around the transcript. */
76
136
  export class StatusBar {
@@ -1 +1 @@
1
- {"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/ui/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AA2BxC,MAAM,QAAQ,GAAG,IAAI,CAAA;AACrB,MAAM,gBAAgB,GAAG,GAAG,GAAG,QAAQ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Z,CAAC;QACD,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;QAChF,MAAM,IAAI,IAAI,GAAG,SAAS,CAAA;IAC5B,CAAC;IACD,OAAO,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;AACvE,CAAC;AAED,yDAAyD;AACzD,MAAM,OAAO,SAAS;IAED;IACA;IAFnB,YACmB,KAAwB,EACxB,KAAe;QADf,UAAK,GAAL,KAAK,CAAmB;QACxB,UAAK,GAAL,KAAK,CAAU;IAC/B,CAAC;IAEJ,UAAU;QACR,yDAAyD;IAC3D,CAAC;IAED,MAAM,CAAC,KAAa;QAClB,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IAC1E,CAAC;CACF"}
package/lib/ui/view.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { type Component } from '@earendil-works/pi-tui';
2
- import type { GateCard } from '../gates.ts';
2
+ import { type Keymap } from '../input/actions.ts';
3
+ import { type GateCard } from '../gates.ts';
3
4
  import type { TranscriptEntry, TranscriptModel } from '../transcript.ts';
4
5
  import type { TuiTheme } from '../theme.ts';
5
6
  import type { MarkdownRenderer } from './markdown.ts';
@@ -9,7 +10,18 @@ import { RowCache } from './rows.ts';
9
10
  export interface ViewState {
10
11
  readonly expandCards: boolean;
11
12
  readonly expandReasoning: boolean;
13
+ /** Whether the calls a PTC program dispatched draw under the card that made them. */
14
+ readonly expandSubCalls: boolean;
12
15
  }
16
+ /**
17
+ * The state a reader gets before opening anything, and the view's own fallback.
18
+ *
19
+ * Cards and thoughts start folded because either can be long enough to push the
20
+ * answer off the screen. A program's calls are the opposite case: one clipped
21
+ * line each, under a header that already names them, so folding them costs a
22
+ * reader the very thing the card stands for.
23
+ */
24
+ export declare const DEFAULT_VIEW_STATE: ViewState;
13
25
  /**
14
26
  * Renders the transcript rows and any pending gate as terminal lines.
15
27
  *
@@ -25,6 +37,14 @@ export interface TranscriptViewOptions {
25
37
  readonly picker?: () => PickerCard | undefined;
26
38
  /** Injectable so a test can see that a repaint reused the rows it had. */
27
39
  readonly rows?: RowCache<TranscriptEntry>;
40
+ /**
41
+ * The keys in force, read live.
42
+ *
43
+ * A hint that names a key is a promise about what a press does, so it has to
44
+ * be drawn from the same table the press is matched against — including after
45
+ * a settings edit moved the key.
46
+ */
47
+ readonly keys?: () => Keymap;
28
48
  }
29
49
  export declare class TranscriptView implements Component {
30
50
  private readonly model;
@@ -43,14 +63,57 @@ export declare class TranscriptView implements Component {
43
63
  invalidate(): void;
44
64
  /** Wrap one text block under a prefix, keeping the prefix's column budget. */
45
65
  private pushWrapped;
66
+ /**
67
+ * Wrap one already-styled block under a prefix.
68
+ *
69
+ * A card header mixes tokens — title, argument, stats — in a single string, so
70
+ * it cannot go through {@link pushWrapped}, which escapes and restyles plain
71
+ * text. Its width still has to fold at the screen edge rather than be cut,
72
+ * because the argument is the part a reader scans for and a silently dropped
73
+ * command is worse than a taller card.
74
+ */
75
+ private pushStyledWrapped;
46
76
  /** Render assistant text as markdown: the model writes structure, the reader reads it. */
47
77
  private pushMarkdown;
78
+ /** The live map, or the shipped one for a caller that did not lend one. */
79
+ private keymap;
80
+ private reasoningFoldHint;
48
81
  private pushReasoning;
49
82
  private pushCard;
83
+ /**
84
+ * The calls one card dispatched, one entry each.
85
+ *
86
+ * A nested call is a signpost rather than a card of its own, so it keeps one
87
+ * entry per call; a long argument still wraps under that entry rather than
88
+ * being cut, because the argument is the part a reader scans for and a
89
+ * silently shortened path reads as the one that ran.
90
+ */
91
+ private pushSubCalls;
92
+ /**
93
+ * A card's header: its label, its argument, and its measured facts.
94
+ *
95
+ * The glyph is returned apart from the body so a wrapped continuation can
96
+ * align under the label rather than under the mark. A terminal's argument is
97
+ * left out because it needs a row of its own — it is the one argument that can
98
+ * be a whole command rather than a word.
99
+ */
100
+ private renderHead;
101
+ /** The measured facts, each in its own colour, or nothing when none is visible. */
102
+ private renderStats;
50
103
  private pushPicker;
51
104
  private pushGate;
52
- /** The rows one transcript entry becomes. */
105
+ /**
106
+ * One row a reader can choose: the cursor, the box, the number, the label.
107
+ *
108
+ * The row wraps under the label it belongs to rather than at the screen edge,
109
+ * because the label and its description together are what tells two rows
110
+ * apart, and a mark on a continuation line reads as another row.
111
+ */
112
+ private pushGateRow;
113
+ /** The rows one transcript entry becomes; `live` marks the entry the turn is still writing. */
53
114
  private renderEntry;
115
+ /** The mark and the space that introduce an element, empty when it has none. */
116
+ private elementLead;
54
117
  render(width: number): string[];
55
118
  }
56
119
  //# sourceMappingURL=view.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/ui/view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAmD,MAAM,wBAAwB,CAAA;AAExG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACxE,OAAO,KAAK,EAAoB,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAKpC,iFAAiF;AACjF,MAAM,WAAW,SAAS;I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