pal-code 0.0.14 → 0.0.16
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/bin/pal-code.js +31 -15
- package/package.json +2 -2
- package/packages/cli/src/components/assistant-body.ts +107 -8
- package/packages/cli/src/components/permission-prompt.ts +35 -19
- package/packages/cli/src/components/sidebar.ts +39 -22
- package/packages/cli/src/index.ts +423 -20
- package/packages/cli/src/overlays/model-picker.ts +6 -6
- package/packages/cli/src/overlays/session-picker.ts +6 -6
- package/packages/cli/src/theme.ts +237 -71
- package/packages/cli/src/themes/github-dark.ts +174 -0
- package/packages/cli/src/themes/index.ts +36 -0
- package/packages/cli/src/themes/types.ts +192 -0
- package/packages/cli/src/themes/vanilla-pi.ts +175 -0
- package/packages/cli/src/tui/paint-panel.ts +20 -0
- package/packages/cli/src/tui/tty-width.ts +973 -0
- package/packages/cli/src/turn.ts +16 -4
- package/packages/cli/src/utils/code-block.ts +90 -13
- package/packages/cli/src/utils/format.ts +11 -7
- package/packages/cli/src/utils/highlight.ts +15 -15
- package/packages/cli/src/utils/osc-canvas.ts +102 -0
- package/packages/cli/src/utils/osc52.ts +32 -3
- package/packages/cli/src/utils/permissions.ts +3 -3
package/bin/pal-code.js
CHANGED
|
@@ -6,12 +6,14 @@
|
|
|
6
6
|
* This thin wrapper detects the current platform and spawns the appropriate
|
|
7
7
|
* compiled binary. Users run `pal` after `npm install -g pal-code`.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
* platform
|
|
9
|
+
* Resolution order:
|
|
10
|
+
* 1. `pal-code-<platform>` optional dependency (prebuilt, preferred)
|
|
11
|
+
* 2. `dist/pal-<platform>` shipped inside this package
|
|
12
|
+
* 3. bundled TypeScript run under Bun (last-resort fallback)
|
|
11
13
|
*/
|
|
12
14
|
|
|
13
15
|
const { spawn } = require('child_process');
|
|
14
|
-
const { existsSync
|
|
16
|
+
const { existsSync } = require('fs');
|
|
15
17
|
const { join, dirname } = require('path');
|
|
16
18
|
|
|
17
19
|
// Fast version check — before any binary lookup
|
|
@@ -43,6 +45,12 @@ function getPlatform() {
|
|
|
43
45
|
return platformMap[key] || null;
|
|
44
46
|
}
|
|
45
47
|
|
|
48
|
+
// Binary filename inside a platform package's `bin/` dir. Built artifacts are
|
|
49
|
+
// named `pal-<platform>[.exe]` (see build scripts in package.json).
|
|
50
|
+
function binaryName(platform) {
|
|
51
|
+
return platform === 'windows-x64' ? 'pal-windows-x64.exe' : `pal-${platform}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
46
54
|
// Find the binary
|
|
47
55
|
function findBinary() {
|
|
48
56
|
const platform = getPlatform();
|
|
@@ -52,32 +60,40 @@ function findBinary() {
|
|
|
52
60
|
process.exit(1);
|
|
53
61
|
}
|
|
54
62
|
|
|
55
|
-
//
|
|
63
|
+
// 1. Platform-specific optional dependency holding the prebuilt binary.
|
|
56
64
|
try {
|
|
57
65
|
const pkgName = `pal-code-${platform}`;
|
|
58
66
|
const pkgPath = require.resolve(`${pkgName}/package.json`);
|
|
59
67
|
const pkgDir = dirname(pkgPath);
|
|
60
|
-
const
|
|
61
|
-
const binPath = join(pkgDir, 'bin', binName);
|
|
68
|
+
const binPath = join(pkgDir, 'bin', binaryName(platform));
|
|
62
69
|
|
|
63
70
|
if (existsSync(binPath)) {
|
|
64
71
|
return binPath;
|
|
65
72
|
}
|
|
66
|
-
} catch
|
|
67
|
-
// Package not
|
|
73
|
+
} catch {
|
|
74
|
+
// Package not installed for this platform — expected on most installs.
|
|
68
75
|
}
|
|
69
76
|
|
|
70
|
-
//
|
|
77
|
+
// 2. Compiled binary shipped in this package's own dist/ directory.
|
|
78
|
+
// `npm pack` strips dist/ via .npmignore, so this only applies to local
|
|
79
|
+
// installs (e.g. `bun install -g` from a checkout).
|
|
71
80
|
const distDir = join(dirname(__dirname), 'dist');
|
|
72
|
-
const
|
|
73
|
-
|
|
81
|
+
const preferred = join(distDir, binaryName(platform));
|
|
82
|
+
|
|
83
|
+
if (existsSync(preferred)) {
|
|
84
|
+
return preferred;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// 2b. Older local installs may only have the short `pal` / `pal.exe` name.
|
|
88
|
+
const shortName = platform === 'windows-x64' ? 'pal.exe' : 'pal';
|
|
89
|
+
const shortBin = join(distDir, shortName);
|
|
74
90
|
|
|
75
|
-
if (existsSync(
|
|
76
|
-
return
|
|
91
|
+
if (existsSync(shortBin)) {
|
|
92
|
+
return shortBin;
|
|
77
93
|
}
|
|
78
94
|
|
|
79
|
-
//
|
|
80
|
-
//
|
|
95
|
+
// 3. Last resort: run the bundled TypeScript source under Bun. Slower to
|
|
96
|
+
// start and requires Bun on PATH, but keeps `pal` working everywhere.
|
|
81
97
|
const { execSync } = require('child_process');
|
|
82
98
|
const srcPath = join(__dirname, '../packages/cli/src/index.ts');
|
|
83
99
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pal-code",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "A terminal coding agent with BYOK, tool use, and extensions",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"gemini"
|
|
63
63
|
],
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@pal-code/core": "0.0.
|
|
65
|
+
"@pal-code/core": "0.0.16",
|
|
66
66
|
"@earendil-works/pi-tui": "^0.85.1"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
@@ -6,21 +6,40 @@
|
|
|
6
6
|
* (`codeBlockBox`) so snippets read as distinct blocks instead of running
|
|
7
7
|
* into the surrounding text.
|
|
8
8
|
*
|
|
9
|
-
* Rendering must be a pure function of (content, width
|
|
10
|
-
* differentially and this component caches by
|
|
11
|
-
* randomness would desync the screen from the
|
|
9
|
+
* Rendering must be a pure function of (content, width, hover/success
|
|
10
|
+
* state): pi-tui repaints differentially and this component caches by
|
|
11
|
+
* width, so any clock or randomness would desync the screen from the
|
|
12
|
+
* cache on repaint/resize. Hover and success are explicit fields set
|
|
13
|
+
* through `setHovered`/`setSuccess`, never sampled from input devices.
|
|
12
14
|
*/
|
|
13
15
|
|
|
14
16
|
import {Markdown, type Component} from '@earendil-works/pi-tui';
|
|
15
17
|
|
|
16
18
|
import {markdownTheme} from '../theme.js';
|
|
17
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
codeBlockBox,
|
|
21
|
+
copyZoneRect,
|
|
22
|
+
COPY_LABEL,
|
|
23
|
+
parseCodeSegments,
|
|
24
|
+
SUCCESS_LABEL,
|
|
25
|
+
} from '../utils/code-block.js';
|
|
18
26
|
import type {CodeSegment} from '../utils/code-block.js';
|
|
19
27
|
|
|
20
28
|
type BodySegment =
|
|
21
29
|
| {readonly kind: 'text'; readonly md: Markdown}
|
|
22
30
|
| {readonly kind: 'code'; readonly code: string; readonly lang: string};
|
|
23
31
|
|
|
32
|
+
type CodeBoxOpts = {copy?: boolean; hover?: boolean; success?: boolean};
|
|
33
|
+
|
|
34
|
+
/** A clickable code-block header located by `AssistantBody.blockAt`. */
|
|
35
|
+
export type AssistantBlockHit = {
|
|
36
|
+
readonly code: string;
|
|
37
|
+
readonly lang: string;
|
|
38
|
+
readonly headerRow: number;
|
|
39
|
+
readonly boxWidth: number;
|
|
40
|
+
readonly zone: {startCol: number; width: number} | null;
|
|
41
|
+
};
|
|
42
|
+
|
|
24
43
|
function assertNever(x: never): never {
|
|
25
44
|
throw new Error(`unhandled code segment: ${JSON.stringify(x)}`);
|
|
26
45
|
}
|
|
@@ -40,6 +59,12 @@ export class AssistantBody implements Component {
|
|
|
40
59
|
private segments: readonly BodySegment[];
|
|
41
60
|
private cached: string[] | null = null;
|
|
42
61
|
private cachedWidth = -1;
|
|
62
|
+
/** Row spans of each rendered segment (blank separators excluded). */
|
|
63
|
+
private spans: {segIndex: number; start: number; height: number}[] = [];
|
|
64
|
+
/** Segment index the pointer is over, or null. */
|
|
65
|
+
private hoveredSeg: number | null = null;
|
|
66
|
+
/** Segment index showing the post-copy success chip, or null. */
|
|
67
|
+
private successSeg: number | null = null;
|
|
43
68
|
|
|
44
69
|
constructor(content: string) {
|
|
45
70
|
this.segments = parseCodeSegments(content).map(toBodySegment);
|
|
@@ -56,32 +81,106 @@ export class AssistantBody implements Component {
|
|
|
56
81
|
this.invalidate();
|
|
57
82
|
}
|
|
58
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Point the hover paint at segment `i` (or clear with null). Returns
|
|
86
|
+
* true only when the value actually changed — repeated same-value calls
|
|
87
|
+
* are free and never invalidate the render cache (Phase B repaints only
|
|
88
|
+
* on a real change).
|
|
89
|
+
*/
|
|
90
|
+
setHovered(i: number | null): boolean {
|
|
91
|
+
if (this.hoveredSeg === i) return false;
|
|
92
|
+
this.hoveredSeg = i;
|
|
93
|
+
this.invalidate();
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Show the success chip on segment `i` (or clear with null). Same
|
|
99
|
+
* change-detection contract as `setHovered`.
|
|
100
|
+
*/
|
|
101
|
+
setSuccess(i: number | null): boolean {
|
|
102
|
+
if (this.successSeg === i) return false;
|
|
103
|
+
this.successSeg = i;
|
|
104
|
+
this.invalidate();
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
|
|
59
108
|
invalidate(): void {
|
|
60
109
|
this.cached = null;
|
|
61
110
|
this.cachedWidth = -1;
|
|
111
|
+
this.spans = [];
|
|
62
112
|
}
|
|
63
113
|
|
|
64
114
|
render(width: number): string[] {
|
|
65
115
|
if (this.cached && this.cachedWidth === width) return this.cached;
|
|
66
116
|
|
|
67
117
|
const out: string[] = [];
|
|
68
|
-
|
|
118
|
+
const spans: {segIndex: number; start: number; height: number}[] = [];
|
|
119
|
+
for (let i = 0; i < this.segments.length; i++) {
|
|
69
120
|
if (out.length > 0) out.push(''); // one blank line between blocks
|
|
70
|
-
out.
|
|
121
|
+
const start = out.length;
|
|
122
|
+
const lines = renderSegment(this.segments[i], width, {
|
|
123
|
+
copy: true,
|
|
124
|
+
hover: this.hoveredSeg === i,
|
|
125
|
+
success: this.successSeg === i,
|
|
126
|
+
});
|
|
127
|
+
out.push(...lines);
|
|
128
|
+
spans.push({segIndex: i, start, height: lines.length});
|
|
71
129
|
}
|
|
72
130
|
|
|
131
|
+
this.spans = spans;
|
|
73
132
|
this.cached = out;
|
|
74
133
|
this.cachedWidth = width;
|
|
75
134
|
return out;
|
|
76
135
|
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Hit-test: locate the code block whose header row is `row` (0-based,
|
|
139
|
+
* local to this component's rendered output at `width`). Returns null
|
|
140
|
+
* unless the row is exactly a code segment's header AND that header has
|
|
141
|
+
* a copy zone (box wide enough for the label). The zone is computed with
|
|
142
|
+
* the same label the paint used, so success-state clicks still land.
|
|
143
|
+
*/
|
|
144
|
+
blockAt(width: number, row: number): AssistantBlockHit | null {
|
|
145
|
+
const lines = this.render(width);
|
|
146
|
+
if (row < 0 || row >= lines.length) return null;
|
|
147
|
+
const span = this.spans.find((s) => row >= s.start && row < s.start + s.height);
|
|
148
|
+
if (!span) return null;
|
|
149
|
+
const seg = this.segments[span.segIndex];
|
|
150
|
+
if (!seg || seg.kind !== 'code') return null;
|
|
151
|
+
if (row - span.start !== 0) return null;
|
|
152
|
+
const boxWidth = Math.max(6, Math.floor(width));
|
|
153
|
+
const label = this.successSeg === span.segIndex ? SUCCESS_LABEL : COPY_LABEL;
|
|
154
|
+
const zone = copyZoneRect(boxWidth, seg.lang, true, label);
|
|
155
|
+
if (!zone) return null;
|
|
156
|
+
return {code: seg.code, lang: seg.lang, headerRow: 0, boxWidth, zone};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Segment index owning the header row `row` (0-based, local to this
|
|
161
|
+
* component's rendered output at `width`), or null when the row is not a
|
|
162
|
+
* code-block header. Same hit rules as `blockAt`, minus the zone geometry —
|
|
163
|
+
* Phase B hover/success need the owning segment id to feed
|
|
164
|
+
* `setHovered`/`setSuccess`.
|
|
165
|
+
*/
|
|
166
|
+
blockIndexAt(width: number, row: number): number | null {
|
|
167
|
+
const lines = this.render(width);
|
|
168
|
+
if (row < 0 || row >= lines.length) return null;
|
|
169
|
+
const span = this.spans.find((s) => row >= s.start && row < s.start + s.height);
|
|
170
|
+
if (!span) return null;
|
|
171
|
+
const seg = this.segments[span.segIndex];
|
|
172
|
+
if (!seg || seg.kind !== 'code') return null;
|
|
173
|
+
if (row - span.start !== 0) return null;
|
|
174
|
+
return span.segIndex;
|
|
175
|
+
}
|
|
77
176
|
}
|
|
78
177
|
|
|
79
|
-
function renderSegment(seg: BodySegment, width: number): string[] {
|
|
178
|
+
function renderSegment(seg: BodySegment, width: number, opts: CodeBoxOpts): string[] {
|
|
80
179
|
switch (seg.kind) {
|
|
81
180
|
case 'text':
|
|
82
181
|
return seg.md.render(width);
|
|
83
182
|
case 'code':
|
|
84
|
-
return codeBlockBox(seg.code, width, seg.lang).split('\n');
|
|
183
|
+
return codeBlockBox(seg.code, width, seg.lang, opts).split('\n');
|
|
85
184
|
default:
|
|
86
185
|
return assertNever(seg);
|
|
87
186
|
}
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
import {visibleWidth} from '@earendil-works/pi-tui';
|
|
14
14
|
import type {Component} from '@earendil-works/pi-tui';
|
|
15
15
|
|
|
16
|
-
import {c} from '../theme.js';
|
|
16
|
+
import {c, surface} from '../theme.js';
|
|
17
17
|
import {state} from '../state.js';
|
|
18
18
|
|
|
19
19
|
/** Strip ANSI escape sequences for visible-width measurement. */
|
|
20
|
-
const ANSI_RE =
|
|
20
|
+
const ANSI_RE = new RegExp('\x1b\\[[0-9;]*m', 'g');
|
|
21
21
|
|
|
22
22
|
/** Repeat a character `n` times. */
|
|
23
23
|
const rep = (ch: string, n: number): string => ch.repeat(Math.max(0, n));
|
|
@@ -38,17 +38,16 @@ export class PermissionPrompt implements Component {
|
|
|
38
38
|
const maxBox = Math.min(60, Math.max(40, width));
|
|
39
39
|
const W = maxBox;
|
|
40
40
|
const inner = W - 2; // "│" content "│" — inner = total minus the two border chars
|
|
41
|
-
const boxColor =
|
|
41
|
+
const boxColor = surface.permission.border;
|
|
42
42
|
const paint = (s: string) => `${boxColor}${s}${c.reset}`;
|
|
43
43
|
|
|
44
44
|
// ── Content lines ──
|
|
45
|
-
const title = `${c.bold}${c.yellow}🔒 Permission Request${c.reset}`;
|
|
46
45
|
const summary = `${c.bold}${perm.summary}${c.reset}`;
|
|
47
46
|
const actions =
|
|
48
|
-
`${
|
|
49
|
-
`${
|
|
50
|
-
`${
|
|
51
|
-
const hint = `${
|
|
47
|
+
`${surface.permission.allow}[y]${c.reset} Allow once ` +
|
|
48
|
+
`${surface.permission.always}[a]${c.reset} Always allow ` +
|
|
49
|
+
`${surface.permission.deny}[n]${c.reset} Deny`;
|
|
50
|
+
const hint = `${surface.permission.dim}Press Esc to abort${c.reset}`;
|
|
52
51
|
|
|
53
52
|
// Wrap summary if it's wider than the inner area.
|
|
54
53
|
const summaryLines = wrapAnsi(summary, inner);
|
|
@@ -62,24 +61,29 @@ export class PermissionPrompt implements Component {
|
|
|
62
61
|
// Top border: ┌─── 🔒 Permission Request ───────┐
|
|
63
62
|
const tagText = '🔒 Permission Request';
|
|
64
63
|
const tagVisW = vw(tagText.replace(ANSI_RE, ''));
|
|
65
|
-
const tagFull = `${
|
|
64
|
+
const tagFull = `${surface.permission.header}${tagText}${c.reset}`;
|
|
66
65
|
const dashesBefore = Math.max(1, Math.floor((W - 2 - tagVisW) / 2));
|
|
67
66
|
const dashesAfter = Math.max(1, W - 2 - dashesBefore - tagVisW);
|
|
68
|
-
lines.push(
|
|
69
|
-
paint('┌') + rep('─', dashesBefore) + tagFull + rep('─', dashesAfter) + paint('┐'),
|
|
70
|
-
);
|
|
67
|
+
lines.push(paint('┌') + rep('─', dashesBefore) + tagFull + rep('─', dashesAfter) + paint('┐'));
|
|
71
68
|
|
|
72
69
|
// Empty content row
|
|
73
70
|
lines.push(paint('│') + rep(' ', inner) + paint('│'));
|
|
74
71
|
|
|
75
72
|
// "pal wants to:" label
|
|
76
73
|
const label = ' pal wants to:';
|
|
77
|
-
lines.push(
|
|
74
|
+
lines.push(
|
|
75
|
+
paint('│') +
|
|
76
|
+
`${surface.permission.dim}${label}${c.reset}` +
|
|
77
|
+
rep(' ', Math.max(0, inner - vw(label))) +
|
|
78
|
+
paint('│'),
|
|
79
|
+
);
|
|
78
80
|
|
|
79
81
|
// Summary (possibly wrapped)
|
|
80
82
|
for (const sl of summaryLines) {
|
|
81
83
|
const visW = vw(sl);
|
|
82
|
-
lines.push(
|
|
84
|
+
lines.push(
|
|
85
|
+
paint('│') + ' ' + sl + c.reset + rep(' ', Math.max(0, inner - 2 - visW)) + paint('│'),
|
|
86
|
+
);
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
// Empty row
|
|
@@ -101,7 +105,14 @@ export class PermissionPrompt implements Component {
|
|
|
101
105
|
);
|
|
102
106
|
} else {
|
|
103
107
|
// Fallback: left-align if too wide
|
|
104
|
-
lines.push(
|
|
108
|
+
lines.push(
|
|
109
|
+
paint('│') +
|
|
110
|
+
' ' +
|
|
111
|
+
actions +
|
|
112
|
+
c.reset +
|
|
113
|
+
rep(' ', Math.max(0, inner - 1 - actionsVisW)) +
|
|
114
|
+
paint('│'),
|
|
115
|
+
);
|
|
105
116
|
}
|
|
106
117
|
|
|
107
118
|
// Empty row
|
|
@@ -112,11 +123,16 @@ export class PermissionPrompt implements Component {
|
|
|
112
123
|
if (hintVisW <= inner) {
|
|
113
124
|
const leftPad = Math.floor((inner - hintVisW) / 2);
|
|
114
125
|
const rightPad = inner - hintVisW - leftPad;
|
|
126
|
+
lines.push(paint('│') + rep(' ', leftPad) + hint + c.reset + rep(' ', rightPad) + paint('│'));
|
|
127
|
+
} else {
|
|
115
128
|
lines.push(
|
|
116
|
-
paint('│') +
|
|
129
|
+
paint('│') +
|
|
130
|
+
' ' +
|
|
131
|
+
hint +
|
|
132
|
+
c.reset +
|
|
133
|
+
rep(' ', Math.max(0, inner - 1 - hintVisW)) +
|
|
134
|
+
paint('│'),
|
|
117
135
|
);
|
|
118
|
-
} else {
|
|
119
|
-
lines.push(paint('│') + ' ' + hint + c.reset + rep(' ', Math.max(0, inner - 1 - hintVisW)) + paint('│'));
|
|
120
136
|
}
|
|
121
137
|
|
|
122
138
|
// Empty content row
|
|
@@ -146,7 +162,7 @@ function wrapAnsi(text: string, maxWidth: number): string[] {
|
|
|
146
162
|
let currentW = 0;
|
|
147
163
|
|
|
148
164
|
// Tokenize: alternating plain text and ANSI escape sequences
|
|
149
|
-
const tokens = text.split(
|
|
165
|
+
const tokens = text.split(new RegExp('(\x1b\\[[0-9;]*m)'));
|
|
150
166
|
let activeStyle = '';
|
|
151
167
|
|
|
152
168
|
for (const token of tokens) {
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
import {Text} from '@earendil-works/pi-tui';
|
|
10
10
|
import type {Component} from '@earendil-works/pi-tui';
|
|
11
11
|
|
|
12
|
-
import {c} from '../theme.js';
|
|
12
|
+
import {c, surface} from '../theme.js';
|
|
13
|
+
import {paintPanel} from '../tui/paint-panel.js';
|
|
13
14
|
import {formatTokens, formatCost, formatCacheHit} from '../utils/cost.js';
|
|
14
15
|
import {truncate} from '../utils/format.js';
|
|
15
16
|
import {state} from '../state.js';
|
|
@@ -23,12 +24,20 @@ export interface SidebarStats {
|
|
|
23
24
|
priced: boolean;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
27
|
+
// Todo icons were a module-scope constant, which froze the palette at import
|
|
28
|
+
// time (before setTheme runs). Built per call so theme swaps apply live.
|
|
29
|
+
function todoIcon(status: string): string {
|
|
30
|
+
switch (status) {
|
|
31
|
+
case 'completed':
|
|
32
|
+
return `${c.green}✓${c.reset}`;
|
|
33
|
+
case 'in_progress':
|
|
34
|
+
return `${c.yellow}▸${c.reset}`;
|
|
35
|
+
case 'cancelled':
|
|
36
|
+
return `${c.dim}✗${c.reset}`;
|
|
37
|
+
default:
|
|
38
|
+
return `${c.dim}·${c.reset}`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
32
41
|
|
|
33
42
|
export class Sidebar implements Component {
|
|
34
43
|
private readonly body = new Text('', 1, 0);
|
|
@@ -55,10 +64,10 @@ export class Sidebar implements Component {
|
|
|
55
64
|
// The same symbols the old status bar used — one stat per line, left-aligned.
|
|
56
65
|
const lines: string[] = [];
|
|
57
66
|
if (state.sessionTitle) {
|
|
58
|
-
lines.push(`${
|
|
67
|
+
lines.push(`${surface.sidebar.title}${truncate(state.sessionTitle, w - 4)}${c.reset}`, '');
|
|
59
68
|
}
|
|
60
69
|
lines.push(
|
|
61
|
-
`${
|
|
70
|
+
`${surface.sidebar.itemAccent}Info${c.reset}`,
|
|
62
71
|
`↑${formatTokens(s.inputTokens)}${s.inputTokens > 0 && s.cachedTokens > 0 ? ` ${c.dim}${formatCacheHit(s.cachedTokens, s.inputTokens)}${c.reset}` : ''}`,
|
|
63
72
|
`↓${formatTokens(s.outputTokens)}`,
|
|
64
73
|
`${formatCost(s.cost)}${s.priced ? '' : `${c.dim} (unpriced)${c.reset}`}`,
|
|
@@ -67,42 +76,46 @@ export class Sidebar implements Component {
|
|
|
67
76
|
);
|
|
68
77
|
|
|
69
78
|
// Extensions
|
|
70
|
-
lines.push(`${
|
|
79
|
+
lines.push(`${surface.sidebar.itemAccent}Extensions${c.reset}`);
|
|
71
80
|
if (state.extensions.length === 0) {
|
|
72
|
-
lines.push(`${
|
|
81
|
+
lines.push(`${surface.sidebar.dim}· none${c.reset}`);
|
|
73
82
|
} else {
|
|
74
83
|
const sorted = [...state.extensions].sort((a, b) => a.name.localeCompare(b.name));
|
|
75
84
|
for (const ext of sorted) {
|
|
76
|
-
const dot = ext.active ? `${
|
|
85
|
+
const dot = ext.active ? `${surface.sidebar.item}●${c.reset}` : `${c.red}●${c.reset}`;
|
|
77
86
|
lines.push(`${dot} ${truncate(ext.name, w - 5)}`);
|
|
78
87
|
}
|
|
79
88
|
}
|
|
80
89
|
lines.push('');
|
|
81
90
|
|
|
82
91
|
// MCP Servers
|
|
83
|
-
lines.push(`${
|
|
92
|
+
lines.push(`${surface.sidebar.itemAccent}MCP Servers${c.reset}`);
|
|
84
93
|
if (state.mcpServers.length === 0) {
|
|
85
|
-
lines.push(`${
|
|
94
|
+
lines.push(`${surface.sidebar.dim}· none${c.reset}`);
|
|
86
95
|
} else {
|
|
87
96
|
const sorted = [...state.mcpServers].sort((a, b) => a.name.localeCompare(b.name));
|
|
88
97
|
for (const srv of sorted) {
|
|
89
|
-
const dot =
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
98
|
+
const dot =
|
|
99
|
+
srv.status === 'connected'
|
|
100
|
+
? `${surface.sidebar.item}●${c.reset}`
|
|
101
|
+
: srv.status === 'starting'
|
|
102
|
+
? `${c.yellow}●${c.reset}`
|
|
103
|
+
: `${c.red}●${c.reset}`;
|
|
104
|
+
const tools =
|
|
105
|
+
srv.toolCount > 0 ? ` ${surface.sidebar.dim}(${srv.toolCount} tools)${c.reset}` : '';
|
|
93
106
|
lines.push(`${dot} ${truncate(srv.name, w - 5)}${tools}`);
|
|
94
107
|
}
|
|
95
108
|
}
|
|
96
109
|
lines.push('');
|
|
97
110
|
|
|
98
|
-
lines.push(`${
|
|
111
|
+
lines.push(`${surface.sidebar.itemAccent}Todos${c.reset}`);
|
|
99
112
|
|
|
100
113
|
const todos = state.currentTodos;
|
|
101
114
|
if (todos.length === 0) {
|
|
102
|
-
lines.push(`${
|
|
115
|
+
lines.push(`${surface.sidebar.dim}· none${c.reset}`);
|
|
103
116
|
} else {
|
|
104
117
|
for (const t of todos) {
|
|
105
|
-
const icon =
|
|
118
|
+
const icon = todoIcon(t.status);
|
|
106
119
|
lines.push(`${icon} ${truncate(t.content, w - 6)}`);
|
|
107
120
|
}
|
|
108
121
|
}
|
|
@@ -115,6 +128,10 @@ export class Sidebar implements Component {
|
|
|
115
128
|
}
|
|
116
129
|
|
|
117
130
|
render(width: number): string[] {
|
|
118
|
-
|
|
131
|
+
// Panel fill behind every row — single choke point; bg '' (vanilla)
|
|
132
|
+
// passes through byte-identical. Status line and editor rows paint no
|
|
133
|
+
// panel: their GitHub bg is the canvas #0d1117 itself, so they sit
|
|
134
|
+
// flush on the canvas while the sidebar reads darker (#010409).
|
|
135
|
+
return this.body.render(width).map((line) => paintPanel(surface.sidebar.bg, line, width));
|
|
119
136
|
}
|
|
120
137
|
}
|