sideby 0.32.2 → 0.33.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/assets/brand/sai-painted-1024.png +0 -0
- package/assets/brand/sai-painted-128.png +0 -0
- package/assets/brand/sai-painted-256.png +0 -0
- package/assets/brand/sai-painted-64.png +0 -0
- package/dist/build.json +1 -1
- package/dist/src/cli/commands.js +57 -14
- package/dist/src/cli/format.js +3 -1
- package/dist/src/cli/json-schemas.js +30 -5
- package/dist/src/cli/main.js +9 -4
- package/dist/src/core/brand-mark.d.ts +18 -115
- package/dist/src/core/brand-mark.js +43 -174
- package/dist/src/core/messages.d.ts +17 -5
- package/dist/src/core/messages.js +38 -15
- package/dist/src/core/quota-fetch.js +9 -2
- package/dist/src/desktop/icon.d.ts +13 -1
- package/dist/src/desktop/icon.js +153 -285
- package/dist/src/families/claude/deliver.js +9 -1
- package/dist/src/families/claude/messaging.d.ts +7 -1
- package/dist/src/families/claude/messaging.js +10 -2
- package/dist/src/families/codex/deliver.d.ts +10 -1
- package/dist/src/families/codex/deliver.js +24 -2
- package/dist/src/families/messaging.d.ts +6 -1
- package/dist/src/menubar/script.d.ts +5 -0
- package/dist/src/menubar/script.js +111 -25
- package/dist/src/menubar/snapshot.d.ts +25 -5
- package/dist/src/menubar/snapshot.js +114 -26
- package/dist/src/menubar/strings.d.ts +22 -6
- package/dist/src/menubar/strings.js +22 -6
- package/dist/src/panel/handler.d.ts +2 -2
- package/dist/src/panel/handler.js +8 -2
- package/dist/src/panel/i18n.d.ts +5 -0
- package/dist/src/panel/i18n.js +14 -4
- package/dist/src/panel/page-logic.d.ts +25 -4
- package/dist/src/panel/page-logic.js +122 -10
- package/dist/src/panel/page-script.js +39 -8
- package/dist/src/panel/page-styles.js +5 -5
- package/dist/src/panel/page.js +2 -2
- package/dist/src/panel/theme.d.ts +4 -1
- package/dist/src/runtime.d.ts +3 -1
- package/dist/src/runtime.js +1 -1
- package/package.json +2 -1
- package/schemas/menubar-snapshot.json +102 -2
- package/schemas/messages.json +6 -2
- package/schemas/send.json +6 -2
- package/skills/sideby/SKILL.md +1 -1
- package/skills/sideby/references/panel.md +1 -1
- package/skills/sideby/references/sessions.md +6 -3
|
@@ -1,179 +1,48 @@
|
|
|
1
|
-
// The sideby mark:
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
],
|
|
21
|
-
};
|
|
22
|
-
const RED = '#e0685a';
|
|
23
|
-
const GOLD = '#ffd977';
|
|
24
|
-
const GREEN = '#5bb06a';
|
|
25
|
-
/** Sai (blue): a red cape behind the shoulders, a gold crown with a red jewel, a small smile. */
|
|
26
|
-
export const SAI = {
|
|
27
|
-
behind: [
|
|
28
|
-
{ d: 'M19 29 Q10 27 9 34 L4 53 Q13 57 22 50 L42 50 Q51 57 60 53 L55 34 Q54 27 45 29 Z', fill: RED },
|
|
29
|
-
],
|
|
30
|
-
mouth: { d: 'M29 46 Q32 49 35 46', fill: 'none', width: 2.5 },
|
|
31
|
-
above: [
|
|
32
|
-
{ d: 'M20 23 L17 10 L27 15 L32 6 L37 15 L47 10 L44 23 Z', fill: GOLD },
|
|
33
|
-
{
|
|
34
|
-
d: 'M35 19 C35 20.66 33.66 22 32 22 C30.34 22 29 20.66 29 19 C29 17.34 30.34 16 32 16 C33.66 16 35 17.34 35 19 Z',
|
|
35
|
-
fill: RED,
|
|
36
|
-
stroke: 'none',
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
};
|
|
40
|
-
/** Bai (amber): a green spare battery on its back, a bent antenna with a ball, an open laugh. */
|
|
41
|
-
export const BAI = {
|
|
42
|
-
behind: [
|
|
43
|
-
{
|
|
44
|
-
d: 'M52 23 H56 C58.21 23 60 24.79 60 27 L60 48 C60 50.21 58.21 52 56 52 H52 C49.79 52 48 50.21 48 48 L48 27 C48 24.79 49.79 23 52 23 Z',
|
|
45
|
-
fill: GREEN,
|
|
46
|
-
},
|
|
47
|
-
{ d: 'M52 23 L52 19 H57 L57 23', fill: GREEN },
|
|
48
|
-
{ d: 'M51 32 H57 M54 29 L54 35', fill: 'none', stroke: 'light', width: 2 },
|
|
49
|
-
],
|
|
50
|
-
mouth: { d: 'M29 46 Q32 52 35 46 Z', fill: 'ink', width: 2.5 },
|
|
51
|
-
above: [
|
|
52
|
-
{ d: 'M31 24 C24 17 26 9 36 10', fill: 'none', stroke: GREEN, width: 4 },
|
|
53
|
-
{
|
|
54
|
-
d: 'M44 10 C44 12.76 41.76 15 39 15 C36.24 15 34 12.76 34 10 C34 7.24 36.24 5 39 5 C41.76 5 44 7.24 44 10 Z',
|
|
55
|
-
fill: GREEN,
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
};
|
|
59
|
-
/** The eye highlights sit towards where the buddy looks: `1` right, `-1` left. */
|
|
60
|
-
export function highlights(look) {
|
|
61
|
-
return BUDDY.eyes.map((e) => ({
|
|
62
|
-
cx: e.cx + 1.5 * look,
|
|
63
|
-
cy: e.cy + (look > 0 ? 0.5 : -2),
|
|
64
|
-
rx: 1.65,
|
|
65
|
-
ry: 2.1,
|
|
66
|
-
fill: 'light',
|
|
67
|
-
}));
|
|
68
|
-
}
|
|
69
|
-
export const MARK_COLORS = {
|
|
70
|
-
blue: { body: '#3f8fc4', shade: '#29658e' },
|
|
71
|
-
amber: { body: '#f2b35e', shade: '#c98a35' },
|
|
72
|
-
ink: '#1e2a44',
|
|
73
|
-
light: '#f6f0e5',
|
|
74
|
-
};
|
|
75
|
-
/** The two buddies in mark units, back first. The blue one in front is the one a Portal's `logoColor` recolours. */
|
|
76
|
-
export const MARK = {
|
|
77
|
-
/** Outline width of a buddy drawn alone, on its 64-unit grid. */
|
|
78
|
-
line: 2.75,
|
|
79
|
-
/** Outline width of a placed buddy before its scale, so the outline stays about 2.5 mark units. */
|
|
80
|
-
placedLine: 3.6,
|
|
81
|
-
back: { colors: MARK_COLORS.amber, props: BAI, look: 1, mirror: true, x: -2, y: 2, scale: 0.7 },
|
|
82
|
-
front: { colors: MARK_COLORS.blue, props: SAI, look: -1, x: 22, y: 16, scale: 0.7 },
|
|
83
|
-
};
|
|
84
|
-
/** The square the pair is drawn in, in mark units (the Panel's 40 px tile and the app icon tile). */
|
|
85
|
-
export const MARK_VIEWBOX = { x: -2.5, y: 3, size: 69 };
|
|
86
|
-
/** Path data mirrored on the 64-unit grid (x → 64 − x); absolute M, L, H, Q, C, Z only. */
|
|
87
|
-
export function mirrorPath(d) {
|
|
88
|
-
let cmd = '';
|
|
89
|
-
let n = 0;
|
|
90
|
-
return d.replace(/[MLHQCZ]|-?\d*\.?\d+/g, (t) => {
|
|
91
|
-
if (/[A-Z]/.test(t)) {
|
|
92
|
-
cmd = t;
|
|
93
|
-
n = 0;
|
|
94
|
-
return t;
|
|
1
|
+
// The sideby mark (ADR-0064): Sai, the blue buddy with a gold crown and a red cape, painted in ink and watercolour.
|
|
2
|
+
// One source for the Panel header, the empty state, the Portal icon, the favicon, the Menu Bar Item and the app icon.
|
|
3
|
+
// The paintings are PNGs with a transparent background in assets/brand/ (shipped in the package), one per size; each
|
|
4
|
+
// place picks the smallest one that stays sharp at twice its size. Like the old vector mark, it sits on a light tile.
|
|
5
|
+
import { readFileSync } from 'node:fs';
|
|
6
|
+
/** The sizes painted, in pixels; `assets/brand/sai-painted-<size>.png`. */
|
|
7
|
+
export const MARK_SIZES = [64, 128, 256, 1024];
|
|
8
|
+
const cache = new Map();
|
|
9
|
+
/** The painting at `size` as PNG bytes, from `assets/brand/` (two levels above src/, three above dist/src/). */
|
|
10
|
+
export function markPng(size) {
|
|
11
|
+
const hit = cache.get(size);
|
|
12
|
+
if (hit)
|
|
13
|
+
return hit;
|
|
14
|
+
const name = `assets/brand/sai-painted-${size}.png`;
|
|
15
|
+
for (const rel of ['../../', '../../../']) {
|
|
16
|
+
try {
|
|
17
|
+
const png = readFileSync(new URL(rel + name, import.meta.url));
|
|
18
|
+
cache.set(size, png);
|
|
19
|
+
return png;
|
|
95
20
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* One buddy's shapes, back to front: the props behind, the body, the mouth, the eyes, the props above.
|
|
103
|
-
* `bodyFill`: `undefined` keeps the buddy's body colour, `null` leaves the body unfilled so it inherits.
|
|
104
|
-
*/
|
|
105
|
-
export function buddyShapes(b, bodyFill) {
|
|
106
|
-
const resolve = (p) => {
|
|
107
|
-
const fill = p.fill === 'none'
|
|
108
|
-
? 'none'
|
|
109
|
-
: p.fill === 'shade'
|
|
110
|
-
? b.colors.shade
|
|
111
|
-
: p.fill === 'body'
|
|
112
|
-
? bodyFill === null
|
|
113
|
-
? undefined
|
|
114
|
-
: (bodyFill ?? b.colors.body)
|
|
115
|
-
: paint(p.fill);
|
|
116
|
-
const stroke = p.stroke === undefined ? MARK_COLORS.ink : p.stroke === 'none' ? 'none' : paint(p.stroke);
|
|
117
|
-
return { d: p.d, fill, stroke, ...(p.width ? { width: p.width } : {}) };
|
|
118
|
-
};
|
|
119
|
-
const prop = (p) => {
|
|
120
|
-
const s = resolve(p);
|
|
121
|
-
return b.mirror ? { ...s, d: mirrorPath(s.d) } : s;
|
|
122
|
-
};
|
|
123
|
-
return {
|
|
124
|
-
paths: [...b.props.behind.map(prop), ...BUDDY.paths.map(resolve), resolve(b.props.mouth)],
|
|
125
|
-
dots: [...BUDDY.eyes, ...highlights(b.look)],
|
|
126
|
-
above: b.props.above.map(prop),
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
function shapeSvg(s) {
|
|
130
|
-
const fill = s.fill === undefined ? '' : ` fill="${s.fill}"`;
|
|
131
|
-
const stroke = s.stroke === MARK_COLORS.ink ? '' : ` stroke="${s.stroke}"`;
|
|
132
|
-
const width = s.width ? ` stroke-width="${s.width}"` : '';
|
|
133
|
-
return `<path d="${s.d}"${fill}${stroke}${width}/>`;
|
|
134
|
-
}
|
|
135
|
-
/** One placed buddy as SVG, drawn inside a group that sets the ink outline (`MARK_OUTLINE`). */
|
|
136
|
-
export function buddySvg(b, line, bodyFill) {
|
|
137
|
-
const { paths, dots, above } = buddyShapes(b, bodyFill);
|
|
138
|
-
const eyes = dots
|
|
139
|
-
.map((e) => `<ellipse cx="${e.cx}" cy="${e.cy}" rx="${e.rx}" ry="${e.ry}" fill="${e.fill === 'ink' ? MARK_COLORS.ink : MARK_COLORS.light}"/>`)
|
|
140
|
-
.join('');
|
|
141
|
-
const transform = b.scale === 1 && b.x === 0 && b.y === 0 ? '' : ` transform="translate(${b.x} ${b.y}) scale(${b.scale})"`;
|
|
142
|
-
return `<g${transform} stroke-width="${line}">${paths.map(shapeSvg).join('')}<g stroke="none">${eyes}</g>${above.map(shapeSvg).join('')}</g>`;
|
|
21
|
+
catch {
|
|
22
|
+
// try the next layout
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
throw new Error(`sideby: ${name} is missing from the package; reinstall sideby`);
|
|
143
26
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
*/
|
|
149
|
-
export
|
|
150
|
-
|
|
27
|
+
/** The painting at `size` as a `data:` URI. */
|
|
28
|
+
export const markDataUri = (size) => `data:image/png;base64,${markPng(size).toString('base64')}`;
|
|
29
|
+
/** The light tile behind the mark: the Panel's `--logo-bg` default and the app icon's tile. */
|
|
30
|
+
export const MARK_TILE = '#e5f2fb';
|
|
31
|
+
/** How much of its tile the painting fills on each side: 3 of 40 px in the Panel header. */
|
|
32
|
+
export const MARK_INSET = 3 / 40;
|
|
33
|
+
/** The Panel's header logo: the painting for its 40 px tile (sharp at 3x). The page's CSP allows `data:` images. */
|
|
34
|
+
export const MARK_IMG = `<img src="${markDataUri(128)}" alt="" width="40" height="40" decoding="async">`;
|
|
35
|
+
/** The painting as a square SVG with a transparent background, the PNG inside as a `data:` image. */
|
|
36
|
+
function markSvg(size) {
|
|
37
|
+
return (`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${size} ${size}" role="img" aria-label="sideby">` +
|
|
38
|
+
`<image href="${markDataUri(size)}" width="${size}" height="${size}"/></svg>`);
|
|
151
39
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
export const ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${viewBox(MARK_VIEWBOX)}" role="img" aria-label="sideby">` +
|
|
157
|
-
`${markSvgBody(MARK_COLORS.blue.body)}</svg>`;
|
|
158
|
-
/**
|
|
159
|
-
* `<basePath>/favicon.svg`: the small cut for sizes below about 24 px, for a 16 pt browser tab (ADR-0022): Sai alone
|
|
160
|
-
* on a 32 grid at half scale, his body, eyes, cape and crown; no feet, arms or mouth. The same cut as the tab icons
|
|
161
|
-
* of the brand design sheet.
|
|
162
|
-
*/
|
|
163
|
-
export const FAVICON_SVG = (() => {
|
|
164
|
-
const sai = { ...MARK.front, x: 0, y: 0, scale: 1 };
|
|
165
|
-
const { paths, dots, above } = buddyShapes(sai);
|
|
166
|
-
const body = BUDDY.paths[2].d;
|
|
167
|
-
const keep = paths.filter((p) => p.d === body || SAI.behind.some((q) => q.d === p.d));
|
|
168
|
-
const eyes = dots
|
|
169
|
-
.map((e) => `<ellipse cx="${e.cx}" cy="${e.cy}" rx="${e.rx}" ry="${e.ry}" fill="${e.fill === 'ink' ? MARK_COLORS.ink : MARK_COLORS.light}"/>`)
|
|
170
|
-
.join('');
|
|
171
|
-
return (`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" role="img" aria-label="sideby">` +
|
|
172
|
-
`<g transform="translate(0 -1) scale(.5)"><g ${MARK_OUTLINE} stroke-width="${MARK.line}">` +
|
|
173
|
-
`${keep.map(shapeSvg).join('')}<g stroke="none">${eyes}</g>${above.map(shapeSvg).join('')}</g></g></svg>`);
|
|
174
|
-
})();
|
|
40
|
+
/** `<basePath>/icon.svg`: the mark on a transparent square, for a Portal's tab or menu (ADR-0006 amendment). */
|
|
41
|
+
export const ICON_SVG = markSvg(128);
|
|
42
|
+
/** `<basePath>/favicon.svg`: the same painting at the size a 16 to 32 px browser tab needs. */
|
|
43
|
+
export const FAVICON_SVG = markSvg(64);
|
|
175
44
|
/**
|
|
176
|
-
* The Menu Bar Item's icon (spec §3.31)
|
|
177
|
-
* in light and dark mode
|
|
45
|
+
* The Menu Bar Item's icon (spec §3.31) and its card's, as base64 PNG: Sai in colour, drawn at 18 pt and 30 pt. It
|
|
46
|
+
* keeps its colours in light and dark mode; the painting's dark outline keeps it visible on both.
|
|
178
47
|
*/
|
|
179
|
-
export const
|
|
48
|
+
export const MENUBAR_ICON_PNG = markPng(64).toString('base64');
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { Runtime } from '../runtime.ts';
|
|
2
2
|
import type { LiveSession } from './live-sessions.ts';
|
|
3
3
|
import { type LiveSessionDeps, type ProcessInfo } from './live-sessions-procs.ts';
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* stored: kept as a file only; delivered: the Host's channel accepted it; read: the target Session shows it;
|
|
6
|
+
* paste-needed: the user must paste `pasteText` into the target; unknown: the channel was given it but never said
|
|
7
|
+
* whether it took it, so it may still show up (ADR-0065): check the target before sending again.
|
|
8
|
+
*/
|
|
9
|
+
export type MessageStatus = 'stored' | 'delivered' | 'read' | 'paste-needed' | 'unknown';
|
|
6
10
|
export interface MessageReceipt {
|
|
7
11
|
/** Short id, also written into the delivered text so it can be found in the target's record. */
|
|
8
12
|
id: string;
|
|
@@ -34,6 +38,8 @@ export interface SendOptions {
|
|
|
34
38
|
images?: readonly string[];
|
|
35
39
|
/** Sender Session id when known (the CLI detects it from its parent Host process). */
|
|
36
40
|
fromSessionId?: string;
|
|
41
|
+
/** The user sends it (the Panel): no sender Session is looked for, so it carries no Reply line. */
|
|
42
|
+
fromUser?: boolean;
|
|
37
43
|
lang?: 'en' | 'zh';
|
|
38
44
|
}
|
|
39
45
|
/** What sending touches on the machine; tests replace each part. */
|
|
@@ -68,14 +74,20 @@ export declare function messageFolder(stateDir: string, sub: readonly string[],
|
|
|
68
74
|
export declare function senderSession(pid: number, procs: readonly ProcessInfo[], sessions: readonly LiveSession[]): LiveSession | undefined;
|
|
69
75
|
/** The line the user pastes into the target (and keeps for reference when it was delivered). */
|
|
70
76
|
export declare function pasteLine(id: string, file: string, screenshots: number, lang: 'en' | 'zh'): string;
|
|
71
|
-
/** The
|
|
72
|
-
export declare
|
|
77
|
+
/** The line that tells the receiving AI how to answer a sender sideby identified: `sideby send <its full id>`. */
|
|
78
|
+
export declare const replyLine: (senderSessionId: string) => string;
|
|
79
|
+
/**
|
|
80
|
+
* The text a Claude session receives: who sent it, the text, one line per screenshot so it can read them, then the
|
|
81
|
+
* Reply line when the sender is a Session sideby identified.
|
|
82
|
+
*/
|
|
83
|
+
export declare function deliveredText(id: string, from: string | undefined, text: string, attachments: readonly string[], reply?: string): string;
|
|
73
84
|
/** Sends `opts` to the Live Session `target` names (an Account ref/alias with one Live Session, or a session id or its first 8 chars). */
|
|
74
85
|
export declare function sendMessage(rt: Runtime, target: string, opts: SendOptions, deps?: MessageDeps): Promise<MessageReceipt>;
|
|
75
86
|
/** How long after sending a held Message counts as dropped: Claude Code's five minutes plus one of margin. */
|
|
76
87
|
export declare const APPROVAL_EXPIRED_MS: number;
|
|
77
88
|
/**
|
|
78
|
-
* Messages sideby kept, newest first, with their current status (re-checks `delivered
|
|
89
|
+
* Messages sideby kept, newest first, with their current status (re-checks `delivered`, `paste-needed` and `unknown`
|
|
90
|
+
* for `read`; an `unknown` one never turns into anything else by itself, ADR-0065). A `read` found
|
|
79
91
|
* is saved into the receipt unless `persist` is false (a read-only Panel only computes it).
|
|
80
92
|
*/
|
|
81
93
|
export declare function listMessages(rt: Runtime, opts?: {
|
|
@@ -134,12 +134,22 @@ export function pasteLine(id, file, screenshots, lang) {
|
|
|
134
134
|
return `请读取 sideby 存好的消息 ${file}(sideby message ${id})${screenshots ? ',以及里面列出的截图' : ''}。`;
|
|
135
135
|
return `Read the message sideby kept for you at ${file} (sideby message ${id})${screenshots ? ' and the screenshots it lists' : ''}.`;
|
|
136
136
|
}
|
|
137
|
-
/** The
|
|
138
|
-
export
|
|
137
|
+
/** The line that tells the receiving AI how to answer a sender sideby identified: `sideby send <its full id>`. */
|
|
138
|
+
export const replyLine = (senderSessionId) => `Reply: sideby send ${senderSessionId} "<text>"`;
|
|
139
|
+
/**
|
|
140
|
+
* The text a Claude session receives: who sent it, the text, one line per screenshot so it can read them, then the
|
|
141
|
+
* Reply line when the sender is a Session sideby identified.
|
|
142
|
+
*/
|
|
143
|
+
export function deliveredText(id, from, text, attachments, reply) {
|
|
139
144
|
const head = `sideby message ${id} ${from ? `from ${from}` : 'from the user via sideby'}`;
|
|
140
|
-
return [
|
|
145
|
+
return [
|
|
146
|
+
head,
|
|
147
|
+
...(text ? [text] : []),
|
|
148
|
+
...attachments.map((a) => `Screenshot: ${a}`),
|
|
149
|
+
...(reply ? [reply] : []),
|
|
150
|
+
].join('\n');
|
|
141
151
|
}
|
|
142
|
-
function messageFile(r, text) {
|
|
152
|
+
function messageFile(r, text, reply) {
|
|
143
153
|
const lines = [
|
|
144
154
|
`# sideby message ${r.id}`,
|
|
145
155
|
'',
|
|
@@ -151,6 +161,8 @@ function messageFile(r, text) {
|
|
|
151
161
|
];
|
|
152
162
|
if (r.attachments.length)
|
|
153
163
|
lines.push('', 'Screenshots:', ...r.attachments.map((a) => `- ${a}`));
|
|
164
|
+
if (reply)
|
|
165
|
+
lines.push('', reply);
|
|
154
166
|
return `${lines.join('\n')}\n`;
|
|
155
167
|
}
|
|
156
168
|
const NO_CHANNEL = {
|
|
@@ -168,7 +180,7 @@ export async function sendMessage(rt, target, opts, deps = {}) {
|
|
|
168
180
|
const lang = opts.lang ?? 'en';
|
|
169
181
|
const images = await openImages(paths);
|
|
170
182
|
try {
|
|
171
|
-
return await sendOpened(rt, target, { text, lang, images, fromSessionId: opts.fromSessionId }, deps);
|
|
183
|
+
return await sendOpened(rt, target, { text, lang, images, fromSessionId: opts.fromSessionId, fromUser: opts.fromUser === true }, deps);
|
|
172
184
|
}
|
|
173
185
|
finally {
|
|
174
186
|
await Promise.all(images.map((i) => i.fh.close().catch(() => { })));
|
|
@@ -182,7 +194,9 @@ async function sendOpened(rt, target, opts, deps) {
|
|
|
182
194
|
deps: procDeps,
|
|
183
195
|
});
|
|
184
196
|
let from;
|
|
185
|
-
if (opts.
|
|
197
|
+
if (opts.fromUser)
|
|
198
|
+
from = undefined;
|
|
199
|
+
else if (opts.fromSessionId)
|
|
186
200
|
from = listed.sessions.find((s) => s.sessionId === opts.fromSessionId);
|
|
187
201
|
else {
|
|
188
202
|
const all = await processView(procDeps)
|
|
@@ -223,7 +237,9 @@ async function sendOpened(rt, target, opts, deps) {
|
|
|
223
237
|
sentAt,
|
|
224
238
|
...(to.transcript ? { transcript: to.transcript } : {}),
|
|
225
239
|
};
|
|
226
|
-
|
|
240
|
+
// Only a sender sideby knows exactly gets a way to answer: a guessed one may be the wrong session.
|
|
241
|
+
const reply = from && !from.guessed ? replyLine(from.sessionId) : undefined;
|
|
242
|
+
await writeFileAtomic(file, messageFile(receipt, text, reply), 0o600);
|
|
227
243
|
// From here on the Message is safe: whatever goes wrong, the user gets the line to paste.
|
|
228
244
|
try {
|
|
229
245
|
await saveReceipt(receipt);
|
|
@@ -237,7 +253,7 @@ async function sendOpened(rt, target, opts, deps) {
|
|
|
237
253
|
let result;
|
|
238
254
|
try {
|
|
239
255
|
const acct = (await rt.accounts()).find((a) => a.ref === to.account);
|
|
240
|
-
result = await deliver(rt, to, acct, receipt, text, procDeps, deps);
|
|
256
|
+
result = await deliver(rt, to, acct, receipt, text, reply, procDeps, deps);
|
|
241
257
|
}
|
|
242
258
|
catch (err) {
|
|
243
259
|
result = {
|
|
@@ -252,14 +268,14 @@ async function sendOpened(rt, target, opts, deps) {
|
|
|
252
268
|
catch (err) {
|
|
253
269
|
// The Message file is kept; only its status could not be recorded. Still hand the user what to do.
|
|
254
270
|
const why = err.code ?? err.message;
|
|
255
|
-
if (receipt.status
|
|
271
|
+
if (receipt.status === 'delivered')
|
|
256
272
|
receipt.note = `sideby could not save the message status (${why})`;
|
|
257
273
|
else
|
|
258
274
|
receipt.note = `${receipt.note ?? 'paste the line into its tab'} (sideby also could not save the message status: ${why})`;
|
|
259
275
|
}
|
|
260
276
|
return { ...publicReceipt(receipt), ...(handedOverFrom ? { handedOverFrom } : {}) };
|
|
261
277
|
}
|
|
262
|
-
async function deliver(rt, to, acct, r, text, procDeps, deps) {
|
|
278
|
+
async function deliver(rt, to, acct, r, text, reply, procDeps, deps) {
|
|
263
279
|
if (to.guessed)
|
|
264
280
|
return {
|
|
265
281
|
status: 'paste-needed',
|
|
@@ -276,15 +292,19 @@ async function deliver(rt, to, acct, r, text, procDeps, deps) {
|
|
|
276
292
|
status: 'paste-needed',
|
|
277
293
|
note: `${NO_CHANNEL[to.family] ?? `${rt.families.get(to.family)?.title ?? to.family} cannot receive messages directly`}; paste the line into its terminal tab`,
|
|
278
294
|
};
|
|
295
|
+
const pid = to.pid;
|
|
279
296
|
return family({
|
|
280
297
|
rt,
|
|
281
298
|
to,
|
|
282
|
-
pid
|
|
299
|
+
pid,
|
|
283
300
|
acct,
|
|
284
|
-
text: deliveredText(r.id, r.from, text, r.attachments),
|
|
301
|
+
text: deliveredText(r.id, r.from, text, r.attachments, reply),
|
|
285
302
|
pasteText: r.pasteText,
|
|
286
303
|
// A fresh look at the processes: the screenshots were copied since the listing, and the session may have ended.
|
|
287
304
|
procs: processView(procDeps),
|
|
305
|
+
ended: () => processView(procDeps)
|
|
306
|
+
.get(pid)
|
|
307
|
+
.then((p) => !p, () => false),
|
|
288
308
|
deps,
|
|
289
309
|
});
|
|
290
310
|
}
|
|
@@ -296,9 +316,11 @@ const receiptPath = (file) => file.replace(/\.md$/, '.json');
|
|
|
296
316
|
async function saveReceipt(r, path = receiptPath(r.file)) {
|
|
297
317
|
await writeFileAtomic(path, `${JSON.stringify(r, null, 2)}\n`, 0o600);
|
|
298
318
|
}
|
|
319
|
+
/** The statuses whose Message may still show in the target's record, so it is looked for there. */
|
|
320
|
+
const READ_CHECKED = new Set(['delivered', 'paste-needed', 'unknown']);
|
|
299
321
|
/** How long after sending a held Message counts as dropped: Claude Code's five minutes plus one of margin. */
|
|
300
322
|
export const APPROVAL_EXPIRED_MS = 6 * 60_000;
|
|
301
|
-
const STATUSES = ['stored', 'delivered', 'read', 'paste-needed'];
|
|
323
|
+
const STATUSES = ['stored', 'delivered', 'read', 'paste-needed', 'unknown'];
|
|
302
324
|
const optStr = (v) => v === undefined || typeof v === 'string';
|
|
303
325
|
/**
|
|
304
326
|
* The receipt at `path` in the Message folder `dir`, when every field has its type and its Message and screenshots
|
|
@@ -331,7 +353,8 @@ function validReceipt(raw, dir, path) {
|
|
|
331
353
|
return r;
|
|
332
354
|
}
|
|
333
355
|
/**
|
|
334
|
-
* Messages sideby kept, newest first, with their current status (re-checks `delivered
|
|
356
|
+
* Messages sideby kept, newest first, with their current status (re-checks `delivered`, `paste-needed` and `unknown`
|
|
357
|
+
* for `read`; an `unknown` one never turns into anything else by itself, ADR-0065). A `read` found
|
|
335
358
|
* is saved into the receipt unless `persist` is false (a read-only Panel only computes it).
|
|
336
359
|
*/
|
|
337
360
|
export async function listMessages(rt, opts = {}) {
|
|
@@ -386,7 +409,7 @@ export async function listMessages(rt, opts = {}) {
|
|
|
386
409
|
list = list.slice(0, opts.limit ?? 20);
|
|
387
410
|
const now = rt.readContext().now.getTime();
|
|
388
411
|
for (const { r, path } of list) {
|
|
389
|
-
if ((r.status
|
|
412
|
+
if (!READ_CHECKED.has(r.status) || !r.transcript)
|
|
390
413
|
continue;
|
|
391
414
|
const seen = await tailLinesWith(r.transcript, `sideby message ${r.id}`).catch(() => []);
|
|
392
415
|
let changed = false;
|
|
@@ -84,8 +84,15 @@ export function shownQuota(local, kept, off, localFallbackOnly = false) {
|
|
|
84
84
|
? { ...kept.quota, fetched: true, ...(kept.error ? { fetchError: kept.error } : {}) }
|
|
85
85
|
: null;
|
|
86
86
|
const own = local?.status === 'ok' ? local : null;
|
|
87
|
-
if (fetched && own)
|
|
88
|
-
|
|
87
|
+
if (fetched && own) {
|
|
88
|
+
if (localFallbackOnly || Date.parse(own.observedAt) <= Date.parse(fetched.observedAt))
|
|
89
|
+
return fetched;
|
|
90
|
+
// A local reading (Claude's status line) sees only the plan-wide windows. Keep the fetched model-group windows it
|
|
91
|
+
// cannot see, so a group's line (such as Fable) does not come and go with whichever reading is newer.
|
|
92
|
+
const seen = new Set(own.windows.map((w) => `${w.name ?? ''}\0${w.label}`));
|
|
93
|
+
const groups = fetched.windows.filter((w) => w.name && !seen.has(`${w.name}\0${w.label}`));
|
|
94
|
+
return groups.length ? { ...own, windows: [...own.windows, ...groups] } : own;
|
|
95
|
+
}
|
|
89
96
|
if (fetched)
|
|
90
97
|
return fetched;
|
|
91
98
|
if (own)
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
/** Text stored in every generated file, so `sideby app uninstall` deletes only what it wrote. */
|
|
2
2
|
export declare const APP_MARKER = "sideby-app-install";
|
|
3
|
+
/** Where the painting goes on a `size` canvas: inset from the tile's edge as in the Panel header. */
|
|
4
|
+
export declare function markRect(size: number): {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
w: number;
|
|
8
|
+
};
|
|
9
|
+
/** Decodes an 8-bit, non-interlaced RGB or RGBA PNG to straight-alpha RGBA pixels. */
|
|
10
|
+
export declare function decodePng(png: Buffer): {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
rgba: Uint8Array;
|
|
14
|
+
};
|
|
3
15
|
/** RGBA pixels (straight alpha) of the icon at `size`×`size`. */
|
|
4
16
|
export declare function renderIcon(size: number): Uint8Array;
|
|
5
17
|
/** Encodes straight-alpha RGBA pixels as a PNG with a `Software` text chunk holding APP_MARKER. */
|
|
@@ -12,5 +24,5 @@ export declare const ICONSET: readonly {
|
|
|
12
24
|
}[];
|
|
13
25
|
/** Builds an `.icns` file directly from PNGs; used when `iconutil` is not available. */
|
|
14
26
|
export declare function encodeIcns(pngs: ReadonlyMap<string, Buffer>): Buffer;
|
|
15
|
-
/** The same
|
|
27
|
+
/** The same icon as an SVG (1024-unit canvas), for Linux icon themes: the tile, and the painting as a `data:` image. */
|
|
16
28
|
export declare function iconSvg(): string;
|