@groeponline/pi-wishcraft 1.17.0 → 1.23.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.
- package/AGENTS.md +42 -22
- package/CHANGELOG.md +58 -0
- package/CONTRIBUTING.md +12 -1
- package/RELEASE.md +142 -49
- package/bash-mode/completion.ts +2 -2
- package/build-stamp.json +1 -1
- package/docs/configuration.md +6 -1
- package/docs/design/regression-testing.md +1 -1
- package/docs/testing.md +81 -0
- package/package.json +17 -10
- package/src/config/settings-registry.ts +2 -1
- package/src/config/structural-preset-table.ts +0 -1
- package/src/extension/commands/commands.ts +0 -1
- package/src/extension/core/peer-guard.ts +5 -0
- package/src/extension/core/segment-context.ts +139 -44
- package/src/extension/core/state.ts +1 -0
- package/src/extension/core/types.ts +5 -0
- package/src/extension/queue/queue-integration.ts +20 -2
- package/src/extension/session/session-lifecycle.ts +24 -3
- package/src/extension/skills/inline-invocation.ts +1 -1
- package/src/extension/ui/custom-editor.ts +1 -5
- package/src/extension/ui/deck/config-diagnostic-lines.ts +0 -6
- package/src/extension/ui/ports-panel.ts +0 -1
- package/src/extension/ui/token-overlays.ts +1 -1
- package/src/extension/welcome/welcome-integration.ts +65 -5
- package/src/i18n/nl.ts +3 -0
- package/src/segments/core.ts +0 -1
- package/src/segments/system.ts +12 -3
- package/src/studio/component.ts +0 -1
- package/src/theme/theme.ts +1 -1
- package/src/tools/graph.ts +0 -3
- package/src/usage/tps-ring.ts +172 -32
- package/src/welcome/banner.ts +14 -0
- package/src/welcome/overlay.ts +139 -7
- package/src/welcome/quick-launch.ts +44 -0
- package/src/welcome/types.ts +13 -0
- package/src/welcome/widgets/sessions-widget.ts +13 -9
- package/src/welcome/widgets/shortcuts-widget.ts +13 -5
- package/src/welcome/widgets/whats-new-widget.ts +16 -3
- package/src/working-vibes/frames.ts +81 -5
- package/src/working-vibes/index.ts +6 -1
- package/src/working-vibes/native-indicator.ts +71 -0
- package/src/working-vibes/storage.ts +5 -3
package/src/segments/core.ts
CHANGED
package/src/segments/system.ts
CHANGED
|
@@ -226,17 +226,26 @@ export const tpsSegment: StatusLineSegment = {
|
|
|
226
226
|
};
|
|
227
227
|
}
|
|
228
228
|
const windowMs = ctx.options.tps?.windowMs ?? 1000;
|
|
229
|
-
const { output, input } = ctx.usageStats ?? {
|
|
229
|
+
const { output, input, cacheRead } = ctx.usageStats ?? {
|
|
230
|
+
output: 0,
|
|
231
|
+
input: 0,
|
|
232
|
+
cacheRead: 0,
|
|
233
|
+
};
|
|
230
234
|
const now = Date.now();
|
|
231
235
|
pushTpsSample(
|
|
232
236
|
tpsSamples,
|
|
233
|
-
{
|
|
237
|
+
{
|
|
238
|
+
at: now,
|
|
239
|
+
output,
|
|
240
|
+
input,
|
|
241
|
+
uncachedInput: Math.max(0, input - cacheRead),
|
|
242
|
+
},
|
|
234
243
|
ringMsForWindow(windowMs),
|
|
235
244
|
);
|
|
236
245
|
const { inRate, outRate } = ratesFromRing(
|
|
237
246
|
tpsSamples,
|
|
238
247
|
now,
|
|
239
|
-
{ input, output },
|
|
248
|
+
{ input, output, cacheRead },
|
|
240
249
|
windowMs,
|
|
241
250
|
);
|
|
242
251
|
const icons = getIcons();
|
package/src/studio/component.ts
CHANGED
|
@@ -126,7 +126,6 @@ function renderList(
|
|
|
126
126
|
|
|
127
127
|
function renderDetail(theme: Theme, width: number, entry: SkillEntry | null, usage: ReadonlyMap<string, SkillUsage>): string[] {
|
|
128
128
|
if (!entry) return [theme.fg("accent", "DETAIL"), theme.fg("dim", "Select a skill from the list")];
|
|
129
|
-
const body = readSkillBody(entry.filePath);
|
|
130
129
|
const refs = safeReadReferences(entry);
|
|
131
130
|
const use = usage.get(entry.name);
|
|
132
131
|
const health = entry.warning ? theme.fg("warning", "warn") : theme.fg("success", "ok");
|
package/src/theme/theme.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ThemeColor } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
3
3
|
import { join, dirname } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
package/src/tools/graph.ts
CHANGED
package/src/usage/tps-ring.ts
CHANGED
|
@@ -1,17 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shared TPS ring math.
|
|
3
|
-
* read the same ring.
|
|
2
|
+
* Shared TPS ring math. Stream events (`message_update`) and the segment both
|
|
3
|
+
* write samples; `/tps` and Status → TPS read the same ring.
|
|
4
|
+
*
|
|
5
|
+
* Three things the plain delta maths got wrong:
|
|
6
|
+
* - prompt tokens arrive once per turn, so a window delta reports the cache
|
|
7
|
+
* read (or nothing at all) instead of the rate the prompt was processed at;
|
|
8
|
+
* - output arrives in chunks, so a single 1s window is noisy;
|
|
9
|
+
* - a burst that lands right after a repaint looks like thousands of tokens/s.
|
|
10
|
+
* The ring therefore carries the turn start and the uncached input count on a
|
|
11
|
+
* sample, derives TTFT from them, and smooths output with an EMA. All of it
|
|
12
|
+
* lives on the ring: nothing here keeps state beyond the samples themselves.
|
|
4
13
|
*/
|
|
5
14
|
|
|
6
15
|
export interface TpsSample {
|
|
7
16
|
at: number;
|
|
8
17
|
output: number;
|
|
9
18
|
input: number;
|
|
19
|
+
/** Prompt tokens excluding `cacheRead`; falls back to `input`. */
|
|
20
|
+
uncachedInput?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Timestamp (ms) the turn began (`agent_start`). Set on the first sample of
|
|
23
|
+
* a turn only, so the marker identifies where that turn starts in the ring.
|
|
24
|
+
*/
|
|
25
|
+
turnStartAt?: number;
|
|
10
26
|
}
|
|
11
27
|
|
|
12
28
|
export interface TpsRates {
|
|
29
|
+
/** Uncached prompt tokens per second; TTFT-based while a turn is active. */
|
|
13
30
|
inRate: number;
|
|
14
31
|
outRate: number;
|
|
32
|
+
/** EMA over the pairwise output rates — the steady-state estimate. */
|
|
33
|
+
emaOutRate?: number;
|
|
34
|
+
/** Time to first token of the current turn; null when no turn is measured. */
|
|
35
|
+
ttftMs?: number | null;
|
|
15
36
|
}
|
|
16
37
|
|
|
17
38
|
export interface TpsSummary extends TpsRates {
|
|
@@ -26,14 +47,29 @@ export interface TpsSummary extends TpsRates {
|
|
|
26
47
|
|
|
27
48
|
export const TPS_MIN_RING_MS = 5000;
|
|
28
49
|
export const TPS_MAX_SAMPLES = 480;
|
|
50
|
+
/**
|
|
51
|
+
* Pairwise buckets shorter than this are coalesced into the next sample. Two
|
|
52
|
+
* repaints a couple of ms apart that straddle one token burst would otherwise
|
|
53
|
+
* report that burst as thousands of tokens per second.
|
|
54
|
+
*/
|
|
55
|
+
export const TPS_MIN_PAIRWISE_DT_MS = 80;
|
|
56
|
+
/** Samples with identical counts closer together than this carry no signal. */
|
|
57
|
+
const TPS_DEDUPE_MS = 40;
|
|
58
|
+
/** Smoothing factor for the output EMA (0..1; higher = more reactive). */
|
|
59
|
+
export const TPS_EMA_ALPHA = 0.32;
|
|
29
60
|
|
|
30
|
-
/** Live ring filled by the tps segment renderer. */
|
|
61
|
+
/** Live ring filled by stream events and the tps segment renderer. */
|
|
31
62
|
export const tpsSamples: TpsSample[] = [];
|
|
32
63
|
|
|
33
64
|
export function ringMsForWindow(windowMs: number): number {
|
|
34
65
|
return Math.max(TPS_MIN_RING_MS, windowMs * 2);
|
|
35
66
|
}
|
|
36
67
|
|
|
68
|
+
/** Prompt tokens that actually had to be processed for this sample. */
|
|
69
|
+
function uncachedOf(sample: TpsSample): number {
|
|
70
|
+
return sample.uncachedInput ?? sample.input;
|
|
71
|
+
}
|
|
72
|
+
|
|
37
73
|
export function pruneTpsRing(
|
|
38
74
|
samples: TpsSample[],
|
|
39
75
|
now: number,
|
|
@@ -50,14 +86,103 @@ export function pushTpsSample(
|
|
|
50
86
|
sample: TpsSample,
|
|
51
87
|
ringMs: number,
|
|
52
88
|
): void {
|
|
89
|
+
const tail = samples[samples.length - 1];
|
|
90
|
+
if (
|
|
91
|
+
tail &&
|
|
92
|
+
tail.output === sample.output &&
|
|
93
|
+
tail.input === sample.input &&
|
|
94
|
+
sample.at - tail.at < TPS_DEDUPE_MS
|
|
95
|
+
) {
|
|
96
|
+
pruneTpsRing(samples, sample.at, ringMs);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
53
99
|
samples.push(sample);
|
|
54
100
|
pruneTpsRing(samples, sample.at, ringMs);
|
|
55
101
|
}
|
|
56
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Locate the current turn in the ring and the first sample that produced
|
|
105
|
+
* tokens for it. Returns null when no turn marker is present, which is the
|
|
106
|
+
* normal case for a preset that never streams (`/tps` alone, replay, tests).
|
|
107
|
+
*/
|
|
108
|
+
function measureTurn(samples: readonly TpsSample[]): {
|
|
109
|
+
turnStartAt: number;
|
|
110
|
+
firstTokenAt: number;
|
|
111
|
+
baseInput: number;
|
|
112
|
+
baseOutput: number;
|
|
113
|
+
} | null {
|
|
114
|
+
let marker = -1;
|
|
115
|
+
for (let i = samples.length - 1; i >= 0; i--) {
|
|
116
|
+
if (samples[i]!.turnStartAt !== undefined) {
|
|
117
|
+
marker = i;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (marker < 0) return null;
|
|
122
|
+
|
|
123
|
+
const start = samples[marker]!.turnStartAt!;
|
|
124
|
+
const before = samples[marker - 1];
|
|
125
|
+
const baseInput = before ? uncachedOf(before) : 0;
|
|
126
|
+
const baseOutput = before ? before.output : 0;
|
|
127
|
+
|
|
128
|
+
for (let i = marker; i < samples.length; i++) {
|
|
129
|
+
const cur = samples[i]!;
|
|
130
|
+
if (cur.output > baseOutput || uncachedOf(cur) > baseInput) {
|
|
131
|
+
return {
|
|
132
|
+
turnStartAt: start,
|
|
133
|
+
firstTokenAt: cur.at,
|
|
134
|
+
baseInput,
|
|
135
|
+
baseOutput,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Pairwise buckets for peak/average reporting. */
|
|
143
|
+
function pairwiseRates(samples: readonly TpsSample[]): {
|
|
144
|
+
ins: number[];
|
|
145
|
+
outs: number[];
|
|
146
|
+
} {
|
|
147
|
+
const ins: number[] = [];
|
|
148
|
+
const outs: number[] = [];
|
|
149
|
+
if (samples.length < 2) return { ins, outs };
|
|
150
|
+
let anchor = samples[0]!;
|
|
151
|
+
for (let i = 1; i < samples.length; i++) {
|
|
152
|
+
const cur = samples[i]!;
|
|
153
|
+
const dtMs = cur.at - anchor.at;
|
|
154
|
+
if (dtMs < TPS_MIN_PAIRWISE_DT_MS) continue;
|
|
155
|
+
const dtSec = dtMs / 1000;
|
|
156
|
+
const dOut = cur.output - anchor.output;
|
|
157
|
+
const dIn = uncachedOf(cur) - uncachedOf(anchor);
|
|
158
|
+
if (dOut > 0) outs.push(dOut / dtSec);
|
|
159
|
+
if (dIn > 0) ins.push(dIn / dtSec);
|
|
160
|
+
anchor = cur;
|
|
161
|
+
}
|
|
162
|
+
return { ins, outs };
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** EMA over the pairwise output rates; undefined when nothing was generated. */
|
|
166
|
+
function emaOf(values: readonly number[]): number | undefined {
|
|
167
|
+
if (values.length === 0) return undefined;
|
|
168
|
+
let ema = values[0]!;
|
|
169
|
+
for (let i = 1; i < values.length; i++) {
|
|
170
|
+
ema = TPS_EMA_ALPHA * values[i]! + (1 - TPS_EMA_ALPHA) * ema;
|
|
171
|
+
}
|
|
172
|
+
return ema;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export interface TpsUsage {
|
|
176
|
+
input: number;
|
|
177
|
+
output: number;
|
|
178
|
+
/** Cached prompt tokens to exclude from the processed-input rate. */
|
|
179
|
+
cacheRead?: number;
|
|
180
|
+
}
|
|
181
|
+
|
|
57
182
|
export function ratesFromRing(
|
|
58
183
|
samples: readonly TpsSample[],
|
|
59
184
|
now: number,
|
|
60
|
-
usage:
|
|
185
|
+
usage: TpsUsage,
|
|
61
186
|
windowMs: number,
|
|
62
187
|
): TpsRates {
|
|
63
188
|
let ref: TpsSample | null = null;
|
|
@@ -72,35 +197,40 @@ export function ratesFromRing(
|
|
|
72
197
|
ref = s;
|
|
73
198
|
}
|
|
74
199
|
}
|
|
200
|
+
|
|
75
201
|
let outRate = 0;
|
|
76
|
-
let
|
|
202
|
+
let windowInRate = 0;
|
|
77
203
|
if (ref) {
|
|
78
204
|
const dt = (now - ref.at) / 1000;
|
|
79
205
|
const dOut = usage.output - ref.output;
|
|
80
206
|
const dIn = usage.input - ref.input;
|
|
81
|
-
if (dt > 0 && dOut
|
|
82
|
-
if (dt > 0 && dIn
|
|
207
|
+
if (dt > 0 && dOut > 0) outRate = dOut / dt;
|
|
208
|
+
if (dt > 0 && dIn > 0) windowInRate = dIn / dt;
|
|
83
209
|
}
|
|
84
|
-
return { inRate, outRate };
|
|
85
|
-
}
|
|
86
210
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (dIn >= 0) ins.push(dIn / dt);
|
|
211
|
+
const turn = measureTurn(samples);
|
|
212
|
+
let ttftMs: number | null = null;
|
|
213
|
+
let inRate = windowInRate;
|
|
214
|
+
if (turn) {
|
|
215
|
+
// Prompt processing happens once, up front: its rate is the uncached
|
|
216
|
+
// token count over the time it took to produce the first token. Dividing
|
|
217
|
+
// it by the 1s window (and counting cacheRead) is what produced the
|
|
218
|
+
// nonsense input rates this replaces.
|
|
219
|
+
ttftMs = Math.max(1, turn.firstTokenAt - turn.turnStartAt);
|
|
220
|
+
const processed = Math.max(
|
|
221
|
+
0,
|
|
222
|
+
usage.input - (usage.cacheRead ?? 0) - turn.baseInput,
|
|
223
|
+
);
|
|
224
|
+
inRate = processed > 0 ? processed / (ttftMs / 1000) : 0;
|
|
102
225
|
}
|
|
103
|
-
|
|
226
|
+
|
|
227
|
+
const { outs } = pairwiseRates(samples);
|
|
228
|
+
return {
|
|
229
|
+
inRate,
|
|
230
|
+
outRate,
|
|
231
|
+
emaOutRate: emaOf(outs),
|
|
232
|
+
ttftMs,
|
|
233
|
+
};
|
|
104
234
|
}
|
|
105
235
|
|
|
106
236
|
function avg(values: readonly number[]): number {
|
|
@@ -111,18 +241,20 @@ function avg(values: readonly number[]): number {
|
|
|
111
241
|
export function summarizeTpsRing(
|
|
112
242
|
samples: readonly TpsSample[],
|
|
113
243
|
now: number,
|
|
114
|
-
usage:
|
|
244
|
+
usage: TpsUsage,
|
|
115
245
|
options: { windowMs?: number; override?: string | null } = {},
|
|
116
246
|
): TpsSummary {
|
|
117
247
|
const windowMs = options.windowMs ?? 1000;
|
|
118
248
|
const override = options.override?.trim() || null;
|
|
119
|
-
const
|
|
249
|
+
const rates = ratesFromRing(samples, now, usage, windowMs);
|
|
120
250
|
const { ins, outs } = pairwiseRates(samples);
|
|
121
251
|
return {
|
|
122
252
|
override,
|
|
123
253
|
windowMs,
|
|
124
|
-
inRate,
|
|
125
|
-
outRate,
|
|
254
|
+
inRate: rates.inRate,
|
|
255
|
+
outRate: rates.outRate,
|
|
256
|
+
emaOutRate: rates.emaOutRate,
|
|
257
|
+
ttftMs: rates.ttftMs,
|
|
126
258
|
peakIn: ins.length ? Math.max(...ins) : 0,
|
|
127
259
|
peakOut: outs.length ? Math.max(...outs) : 0,
|
|
128
260
|
avgIn: avg(ins),
|
|
@@ -142,10 +274,18 @@ export function tpsOverlayLines(summary: TpsSummary): string[] {
|
|
|
142
274
|
"clear with Configure or /tps (empty to show live)",
|
|
143
275
|
];
|
|
144
276
|
}
|
|
145
|
-
|
|
277
|
+
const lines = [
|
|
146
278
|
`window ${summary.windowMs}ms over ${TPS_MIN_RING_MS}ms ring`,
|
|
147
|
-
`out ${formatTpsRate(summary.outRate)} peak ${formatTpsRate(summary.peakOut)} avg ${formatTpsRate(summary.avgOut)}
|
|
279
|
+
`out ${formatTpsRate(summary.outRate)} peak ${formatTpsRate(summary.peakOut)} avg ${formatTpsRate(summary.avgOut)}${
|
|
280
|
+
summary.emaOutRate === undefined
|
|
281
|
+
? ""
|
|
282
|
+
: ` ema ${formatTpsRate(summary.emaOutRate)}`
|
|
283
|
+
}`,
|
|
148
284
|
`in ${formatTpsRate(summary.inRate)} peak ${formatTpsRate(summary.peakIn)} avg ${formatTpsRate(summary.avgIn)}`,
|
|
149
|
-
`samples ${summary.samples}`,
|
|
150
285
|
];
|
|
286
|
+
if (summary.ttftMs !== null && summary.ttftMs !== undefined) {
|
|
287
|
+
lines.push(`ttft ${Math.round(summary.ttftMs)}ms`);
|
|
288
|
+
}
|
|
289
|
+
lines.push(`samples ${summary.samples}`);
|
|
290
|
+
return lines;
|
|
151
291
|
}
|
package/src/welcome/banner.ts
CHANGED
|
@@ -70,6 +70,20 @@ export function bootRevealActive(startedAt: number, now: number): boolean {
|
|
|
70
70
|
return now - startedAt < BOOT_REVEAL_MS;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Reveal time to hand the art renderer, or `undefined` when the steady layout
|
|
75
|
+
* should take over. After the reveal window an animated lantern keeps its own
|
|
76
|
+
* override (elapsed 0 = no fade, live frames) so the flame never freezes on
|
|
77
|
+
* the first paint; a still lantern falls back to the plain box art.
|
|
78
|
+
*/
|
|
79
|
+
export function revealElapsedForArt(
|
|
80
|
+
elapsedMs: number,
|
|
81
|
+
animate: boolean,
|
|
82
|
+
): number | undefined {
|
|
83
|
+
if (elapsedMs < BOOT_REVEAL_MS) return elapsedMs;
|
|
84
|
+
return animate ? 0 : undefined;
|
|
85
|
+
}
|
|
86
|
+
|
|
73
87
|
/**
|
|
74
88
|
* Welcome header - same layout as overlay but persistent (no countdown).
|
|
75
89
|
* Used when quietStartup: true. The first ~1.5s after mount fades the art
|
package/src/welcome/overlay.ts
CHANGED
|
@@ -5,9 +5,14 @@ import { dim, renderWelcomeBox } from "./renderer.ts";
|
|
|
5
5
|
import { fgOnly } from "../theme/colors.ts";
|
|
6
6
|
import type { WelcomeData } from "./types.ts";
|
|
7
7
|
import type { LoadedCounts, RecentSession } from "./types.ts";
|
|
8
|
-
import { renderWelcomeArtWithReveal, BOOT_REVEAL_MS } from "./banner.ts";
|
|
8
|
+
import { renderWelcomeArtWithReveal, BOOT_REVEAL_MS, revealElapsedForArt } from "./banner.ts";
|
|
9
9
|
import { tr } from "../i18n/index.ts";
|
|
10
10
|
import type { WelcomeArtTheme } from "./welcome-art.ts";
|
|
11
|
+
import { quickLaunchItems } from "./quick-launch.ts";
|
|
12
|
+
import type { WelcomeFocus, WelcomeSection } from "./types.ts";
|
|
13
|
+
|
|
14
|
+
/** Tab order of the cockpit sections. */
|
|
15
|
+
const SECTIONS: readonly WelcomeSection[] = ["news", "sessions", "shortcuts"];
|
|
11
16
|
|
|
12
17
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
13
18
|
// Welcome Components
|
|
@@ -21,6 +26,11 @@ export class WelcomeComponent implements Component {
|
|
|
21
26
|
private data: WelcomeData;
|
|
22
27
|
private countdown: number = 30;
|
|
23
28
|
private mountedAt = 0;
|
|
29
|
+
private timerPaused = false;
|
|
30
|
+
private selectedWhatsNew: number | null = null;
|
|
31
|
+
private focus: WelcomeFocus = { section: "news", index: 0 };
|
|
32
|
+
/** True once a navigation key has been seen; keeps the default render calm. */
|
|
33
|
+
private focusEngaged = false;
|
|
24
34
|
|
|
25
35
|
constructor(
|
|
26
36
|
modelName: string,
|
|
@@ -55,6 +65,99 @@ export class WelcomeComponent implements Component {
|
|
|
55
65
|
this.countdown = seconds;
|
|
56
66
|
}
|
|
57
67
|
|
|
68
|
+
isTimerPaused(): boolean {
|
|
69
|
+
return this.timerPaused;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Step through the `What's new` bullets so truncated entries can be read in
|
|
74
|
+
* full. Interacting pauses the auto-dismiss countdown; only non-printable
|
|
75
|
+
* navigation keys call this, so typing a prompt still just dismisses.
|
|
76
|
+
*/
|
|
77
|
+
moveSelection(delta: -1 | 1): void {
|
|
78
|
+
const count = this.data.whatsNew?.length ?? 0;
|
|
79
|
+
if (count === 0) return;
|
|
80
|
+
this.timerPaused = true;
|
|
81
|
+
this.selectedWhatsNew =
|
|
82
|
+
this.selectedWhatsNew === null
|
|
83
|
+
? delta > 0
|
|
84
|
+
? 0
|
|
85
|
+
: count - 1
|
|
86
|
+
: (this.selectedWhatsNew + delta + count) % count;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
getSelectedWhatsNew(): number | null {
|
|
90
|
+
return this.selectedWhatsNew;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** How many rows a section can highlight (0 = section is skipped). */
|
|
94
|
+
private rowsFor(section: WelcomeSection): number {
|
|
95
|
+
switch (section) {
|
|
96
|
+
case "news":
|
|
97
|
+
return this.data.whatsNew?.length ?? 0;
|
|
98
|
+
case "sessions":
|
|
99
|
+
return Math.min(3, this.data.recentSessions.length);
|
|
100
|
+
case "shortcuts":
|
|
101
|
+
return quickLaunchItems().length;
|
|
102
|
+
default:
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Move inside the focused section. The news section keeps its wrapping
|
|
109
|
+
* expanded-bullet behaviour; other sections clamp at the ends.
|
|
110
|
+
*/
|
|
111
|
+
moveFocus(delta: -1 | 1): void {
|
|
112
|
+
if (this.focus.section === "news") {
|
|
113
|
+
this.moveSelection(delta);
|
|
114
|
+
if (this.selectedWhatsNew !== null) {
|
|
115
|
+
this.focusEngaged = true;
|
|
116
|
+
this.focus = { section: "news", index: this.selectedWhatsNew };
|
|
117
|
+
}
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const rows = this.rowsFor(this.focus.section);
|
|
121
|
+
if (rows === 0) return;
|
|
122
|
+
this.timerPaused = true;
|
|
123
|
+
this.focusEngaged = true;
|
|
124
|
+
this.focus = {
|
|
125
|
+
section: this.focus.section,
|
|
126
|
+
index: Math.max(0, Math.min(rows - 1, this.focus.index + delta)),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Tab / Shift+Tab: step to the next non-empty section. */
|
|
131
|
+
cycleSection(delta: -1 | 1): void {
|
|
132
|
+
const start = SECTIONS.indexOf(this.focus.section);
|
|
133
|
+
for (let step = 1; step <= SECTIONS.length; step++) {
|
|
134
|
+
const next = (((start + delta * step) % SECTIONS.length) + SECTIONS.length) % SECTIONS.length;
|
|
135
|
+
const section = SECTIONS[next];
|
|
136
|
+
if (this.rowsFor(section) === 0) continue;
|
|
137
|
+
this.timerPaused = true;
|
|
138
|
+
this.focusEngaged = true;
|
|
139
|
+
this.focus = {
|
|
140
|
+
section,
|
|
141
|
+
index: section === "news" ? (this.selectedWhatsNew ?? 0) : 0,
|
|
142
|
+
};
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
getFocus(): WelcomeFocus | null {
|
|
148
|
+
return this.focusEngaged ? { ...this.focus } : null;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Enter on the focused row. Only meaningful once navigation paused the
|
|
153
|
+
* countdown, and only quick-launch rows carry text for the editor.
|
|
154
|
+
*/
|
|
155
|
+
activate(): string | null {
|
|
156
|
+
if (!this.timerPaused || this.focus.section !== "shortcuts") return null;
|
|
157
|
+
const item = quickLaunchItems()[this.focus.index];
|
|
158
|
+
return item?.insert ?? null;
|
|
159
|
+
}
|
|
160
|
+
|
|
58
161
|
setArt(art: WelcomeArtTheme, animate: boolean): void {
|
|
59
162
|
this.data.art = art;
|
|
60
163
|
this.data.animateArt = animate;
|
|
@@ -88,7 +191,9 @@ export class WelcomeComponent implements Component {
|
|
|
88
191
|
);
|
|
89
192
|
|
|
90
193
|
// Bottom line with countdown
|
|
91
|
-
const countdownText =
|
|
194
|
+
const countdownText = this.timerPaused
|
|
195
|
+
? ` ${this.pausedHint()} `
|
|
196
|
+
: ` ${tr("welcome.countdown", "Press any key to continue ({n}s)", { n: this.countdown })} `;
|
|
92
197
|
const countdownStyled = dim(countdownText);
|
|
93
198
|
const bottomContentWidth = boxWidth - 2;
|
|
94
199
|
const countdownVisLen = visibleWidth(countdownText);
|
|
@@ -100,20 +205,47 @@ export class WelcomeComponent implements Component {
|
|
|
100
205
|
countdownStyled +
|
|
101
206
|
dim(hChar.repeat(Math.max(0, rightPad)));
|
|
102
207
|
|
|
103
|
-
|
|
208
|
+
const renderData: WelcomeData = {
|
|
209
|
+
...this.data,
|
|
210
|
+
whatsNewSelected: this.selectedWhatsNew,
|
|
211
|
+
focus: this.getFocus() ?? undefined,
|
|
212
|
+
};
|
|
213
|
+
return renderWelcomeBox(renderData, termWidth, bottomLine, this.revealArt(termWidth));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** One hint per section: what the arrows and Enter can do right now. */
|
|
217
|
+
private pausedHint(): string {
|
|
218
|
+
switch (this.focus.section) {
|
|
219
|
+
case "sessions":
|
|
220
|
+
return tr(
|
|
221
|
+
"welcome.pausedHint.sessions",
|
|
222
|
+
"↑/↓ browse crafts · tab switches section · any other key continues",
|
|
223
|
+
);
|
|
224
|
+
case "shortcuts":
|
|
225
|
+
return tr(
|
|
226
|
+
"welcome.pausedHint.shortcuts",
|
|
227
|
+
"↑/↓ choose · enter primes the prompt · tab switches section",
|
|
228
|
+
);
|
|
229
|
+
default:
|
|
230
|
+
return tr("welcome.pausedHint", "↑/↓ browse news · any other key continues");
|
|
231
|
+
}
|
|
104
232
|
}
|
|
105
233
|
|
|
106
|
-
/**
|
|
234
|
+
/**
|
|
235
|
+
* Left-column art override. Animated lanterns keep their own frame source
|
|
236
|
+
* after the boot window so the flame never freezes on the first paint.
|
|
237
|
+
*/
|
|
107
238
|
private revealArt(termWidth: number): string[] | undefined {
|
|
108
239
|
if (this.mountedAt === 0) return undefined;
|
|
109
240
|
const now = Date.now();
|
|
110
241
|
const elapsed = now - this.mountedAt;
|
|
111
|
-
|
|
242
|
+
const revealElapsed = revealElapsedForArt(elapsed, this.data.animateArt === true);
|
|
243
|
+
if (revealElapsed === undefined) return undefined;
|
|
112
244
|
const frames = renderWelcomeArtWithReveal(
|
|
113
245
|
this.data.art ?? "lantern",
|
|
114
246
|
termWidth,
|
|
115
|
-
this.data.animateArt === true,
|
|
116
|
-
|
|
247
|
+
this.data.animateArt === true || revealElapsed < BOOT_REVEAL_MS,
|
|
248
|
+
revealElapsed,
|
|
117
249
|
now,
|
|
118
250
|
);
|
|
119
251
|
const boxLayout = getBoxLayout(termWidth);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { tr } from "../i18n/index.ts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Quick Launch rows. The welcome cockpit renders these and lets non-printable
|
|
5
|
+
* navigation move between them, so the list lives here once instead of being
|
|
6
|
+
* hardcoded inside the widget.
|
|
7
|
+
*
|
|
8
|
+
* `insert` is the text primed in the prompt editor when the row is activated.
|
|
9
|
+
* Rows without `insert` are genuine keybindings — the overlay cannot press a
|
|
10
|
+
* key for the operator, so activating them only closes the overlay.
|
|
11
|
+
*/
|
|
12
|
+
export interface QuickLaunchItem {
|
|
13
|
+
id: string;
|
|
14
|
+
keys: string;
|
|
15
|
+
label: string;
|
|
16
|
+
insert?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function quickLaunchItems(): QuickLaunchItem[] {
|
|
20
|
+
return [
|
|
21
|
+
{
|
|
22
|
+
id: "idea",
|
|
23
|
+
keys: "# <idea>",
|
|
24
|
+
label: tr("welcome.shortcuts.idea", "capture idea to queue"),
|
|
25
|
+
insert: "# ",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: "deck",
|
|
29
|
+
keys: "alt+p",
|
|
30
|
+
label: tr("welcome.shortcuts.deck", "tactical powerline overlay"),
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: "bash",
|
|
34
|
+
keys: "!cmd",
|
|
35
|
+
label: tr("welcome.shortcuts.bash", "sticky bash session"),
|
|
36
|
+
insert: "! ",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: "stash",
|
|
40
|
+
keys: "alt+s",
|
|
41
|
+
label: tr("welcome.shortcuts.stash", "stash/pop prompt draft"),
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
}
|
package/src/welcome/types.ts
CHANGED
|
@@ -12,6 +12,15 @@ export interface RecentSession {
|
|
|
12
12
|
timeAgo: string;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
/** Sections the welcome overlay lets the operator step through with Tab. */
|
|
16
|
+
export type WelcomeSection = "news" | "sessions" | "shortcuts";
|
|
17
|
+
|
|
18
|
+
export interface WelcomeFocus {
|
|
19
|
+
section: WelcomeSection;
|
|
20
|
+
/** Row index within that section. */
|
|
21
|
+
index: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
15
24
|
export interface WelcomeData {
|
|
16
25
|
modelName: string;
|
|
17
26
|
providerName: string;
|
|
@@ -22,6 +31,10 @@ export interface WelcomeData {
|
|
|
22
31
|
hasStash?: boolean;
|
|
23
32
|
nextIdeaText?: string;
|
|
24
33
|
whatsNew?: string[];
|
|
34
|
+
/** Index of the `whatsNew` bullet shown expanded (wrapped, not truncated). */
|
|
35
|
+
whatsNewSelected?: number | null;
|
|
36
|
+
/** Which section Tab is on and which row inside it is highlighted. */
|
|
37
|
+
focus?: WelcomeFocus;
|
|
25
38
|
/**
|
|
26
39
|
* Heading above `whatsNew`. Defaults to "What's new"; the first-run flow
|
|
27
40
|
* swaps it for a short "Getting started" so a brand-new operator sees three
|
|
@@ -6,19 +6,23 @@ export const SessionsWidget: WelcomeWidget = {
|
|
|
6
6
|
render(ctx: WidgetRenderContext): string[] {
|
|
7
7
|
const { data, dim, bold, color } = ctx;
|
|
8
8
|
const lines: string[] = [];
|
|
9
|
-
|
|
9
|
+
const focused =
|
|
10
|
+
data.focus?.section === "sessions" ? data.focus.index : null;
|
|
11
|
+
|
|
10
12
|
lines.push(` ${bold(color("accent", tr("welcome.sessions", "Recent Crafts")))}`);
|
|
11
13
|
|
|
12
14
|
if (data.recentSessions.length === 0) {
|
|
13
15
|
lines.push(` ${dim(tr("welcome.sessions.none", "No recent sessions"))}`);
|
|
14
|
-
|
|
15
|
-
for (const session of data.recentSessions.slice(0, 3)) {
|
|
16
|
-
lines.push(
|
|
17
|
-
` ${dim("• ")}${color("path", session.name)}${dim(` (${session.timeAgo})`)}`
|
|
18
|
-
);
|
|
19
|
-
}
|
|
16
|
+
return lines;
|
|
20
17
|
}
|
|
21
|
-
|
|
18
|
+
|
|
19
|
+
data.recentSessions.slice(0, 3).forEach((session, index) => {
|
|
20
|
+
const marker = focused === index ? color("accent", "▸ ") : dim("• ");
|
|
21
|
+
lines.push(
|
|
22
|
+
` ${marker}${color("path", session.name)}${dim(` (${session.timeAgo})`)}`
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
|
|
22
26
|
return lines;
|
|
23
|
-
}
|
|
27
|
+
},
|
|
24
28
|
};
|