@turri-dev/cli 0.4.2 → 0.4.3-next.620bae9
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/dist/chat-commands.d.ts +2 -10
- package/dist/chat-commands.js +3 -57
- package/dist/chat-tab-header.d.ts +15 -0
- package/dist/chat-tab-header.js +78 -0
- package/dist/chat-tabs.d.ts +20 -0
- package/dist/chat-tabs.js +96 -0
- package/dist/chat-terminal.js +54 -8
- package/dist/chat-waiting.d.ts +4 -1
- package/dist/chat-waiting.js +7 -4
- package/dist/chats.d.ts +2 -0
- package/dist/extension.js +15 -4
- package/dist/pointer-hover.d.ts +12 -0
- package/dist/pointer-hover.js +44 -0
- package/dist/regenerate/jobs-tree.d.ts +1 -0
- package/dist/regenerate/jobs-tree.js +5 -1
- package/dist/regenerate/side-panel.d.ts +4 -1
- package/dist/regenerate/side-panel.js +131 -22
- package/dist/regenerate/spec-map-view.d.ts +9 -1
- package/dist/regenerate/spec-map-view.js +22 -2
- package/dist/resume-line.d.ts +4 -1
- package/dist/resume-line.js +5 -2
- package/docs/chats.md +6 -5
- package/docs/theming.md +1 -1
- package/docs/using.md +4 -0
- package/package.json +3 -3
package/dist/chat-commands.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { type
|
|
2
|
+
import { type TurriCore } from "./chats.ts";
|
|
3
3
|
/**
|
|
4
|
-
* The terminal's
|
|
5
|
-
* editor naming each chat with what it is doing.
|
|
4
|
+
* The keyboard counterparts to the terminal's chat tabs: `/chat` - new, close, a number, or a pick - and its keys.
|
|
6
5
|
*/
|
|
7
6
|
/** A fresh chat. */
|
|
8
7
|
export declare const NEW_CHAT_KEY = "alt+n";
|
|
@@ -15,11 +14,4 @@ export declare const CLOSE_CHAT_KEY = "alt+w";
|
|
|
15
14
|
export declare const OPTION_AS_META: string;
|
|
16
15
|
/** Said once a session, as its second chat opens, on a Mac. */
|
|
17
16
|
export declare function tellOfOptionOnce(session: TurriCore, platform?: NodeJS.Platform): void;
|
|
18
|
-
/** What a chat's mark in the strip and the picker says it is doing. */
|
|
19
|
-
export declare function chatMark(chat: ChatInfo, now?: number): string;
|
|
20
|
-
/** The strip: each chat by its number, its title and its mark - the one shown set apart - on one line, a rule between them. */
|
|
21
|
-
export declare function chatStrip(chats: ChatInfo[], width: number, style: {
|
|
22
|
-
shown: (text: string) => string;
|
|
23
|
-
muted: (text: string) => string;
|
|
24
|
-
}, now?: number): string[];
|
|
25
17
|
export declare function registerChats(pi: ExtensionAPI, session: TurriCore): void;
|
package/dist/chat-commands.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { truncateToWidth } from "@earendil-works/pi-tui";
|
|
2
1
|
import { MAX_CHATS } from "./chats.js";
|
|
3
|
-
import {
|
|
2
|
+
import { chatMark, closeTerminalChat } from "./chat-tabs.js";
|
|
4
3
|
/**
|
|
5
|
-
* The terminal's
|
|
6
|
-
* editor naming each chat with what it is doing.
|
|
4
|
+
* The keyboard counterparts to the terminal's chat tabs: `/chat` - new, close, a number, or a pick - and its keys.
|
|
7
5
|
*/
|
|
8
6
|
/** A fresh chat. */
|
|
9
7
|
export const NEW_CHAT_KEY = "alt+n";
|
|
@@ -11,7 +9,6 @@ export const NEW_CHAT_KEY = "alt+n";
|
|
|
11
9
|
export const CLOSE_CHAT_KEY = "alt+w";
|
|
12
10
|
/** alt+1 … alt+9: that chat, shown. */
|
|
13
11
|
const SHOW_KEYS = Array.from({ length: MAX_CHATS }, (_, index) => `alt+${index + 1}`);
|
|
14
|
-
const STRIP_WIDGET = "turri-chats";
|
|
15
12
|
/**
|
|
16
13
|
* On a Mac, alt is Option, which types ¡ and ñ unless the terminal sends it as Meta: said once a session, as the second
|
|
17
14
|
* chat opens - when the keys are first worth having.
|
|
@@ -34,33 +31,6 @@ export function tellOfOptionOnce(session, platform = process.platform) {
|
|
|
34
31
|
setTimeout(() => session.notify(OPTION_AS_META, "info"), 0);
|
|
35
32
|
});
|
|
36
33
|
}
|
|
37
|
-
/** What a chat's mark in the strip and the picker says it is doing. */
|
|
38
|
-
export function chatMark(chat, now = Date.now()) {
|
|
39
|
-
switch (chat.status) {
|
|
40
|
-
case "working":
|
|
41
|
-
return spinner(now);
|
|
42
|
-
case "question":
|
|
43
|
-
return "?";
|
|
44
|
-
case "unread":
|
|
45
|
-
return "•";
|
|
46
|
-
default:
|
|
47
|
-
return " ";
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/** Between two chats in the strip. */
|
|
51
|
-
const STRIP_DELIMITER = " │ ";
|
|
52
|
-
/** The strip: each chat by its number, its title and its mark - the one shown set apart - on one line, a rule between them. */
|
|
53
|
-
export function chatStrip(chats, width, style, now = Date.now()) {
|
|
54
|
-
if (chats.length < 2)
|
|
55
|
-
return [];
|
|
56
|
-
const room = Math.max(8, Math.floor((width - 2) / chats.length) - STRIP_DELIMITER.length - 4);
|
|
57
|
-
const parts = chats.map((chat, index) => {
|
|
58
|
-
const mark = chatMark(chat, now).trim();
|
|
59
|
-
const label = `${index + 1} ${truncateToWidth(chat.title, room, "…")}${mark !== "" ? ` ${mark}` : ""}`;
|
|
60
|
-
return chat.shown ? style.shown(label) : style.muted(label);
|
|
61
|
-
});
|
|
62
|
-
return [truncateToWidth(` ${parts.join(style.muted(STRIP_DELIMITER))}`, width, "…")];
|
|
63
|
-
}
|
|
64
34
|
const label = (chat, index) => `${index + 1} ${chatMark(chat)} ${chat.title}${chat.shown ? " (shown)" : ""}`;
|
|
65
35
|
/** What the person asked of the chats, done once pi has finished with the command or key that asked it. */
|
|
66
36
|
function later(ctx, session, work) {
|
|
@@ -88,10 +58,7 @@ function closeChat(ctx, session, which) {
|
|
|
88
58
|
const chat = chatNamed(session, which);
|
|
89
59
|
if (typeof chat === "string")
|
|
90
60
|
return ctx.ui.notify(chat, "warning");
|
|
91
|
-
|
|
92
|
-
if (chat.role === undefined && session.chats().filter((other) => other.role === undefined).length === 1)
|
|
93
|
-
return ctx.ui.notify("This is the only chat - /quit leaves turri.", "info");
|
|
94
|
-
later(ctx, session, () => session.close(chat.id));
|
|
61
|
+
later(ctx, session, () => closeTerminalChat(session, chat.id));
|
|
95
62
|
}
|
|
96
63
|
function showChat(ctx, session, which) {
|
|
97
64
|
const chat = chatNamed(session, which);
|
|
@@ -139,25 +106,4 @@ export function registerChats(pi, session) {
|
|
|
139
106
|
description: `Show chat ${index + 1}`,
|
|
140
107
|
handler: async (ctx) => showChat(ctx, session, `${index + 1}`),
|
|
141
108
|
}));
|
|
142
|
-
// The strip above the editor, while there are two chats or more: drawn again as they change, and while one works.
|
|
143
|
-
pi.on("session_start", (_event, ctx) => {
|
|
144
|
-
if (!ctx.hasUI)
|
|
145
|
-
return;
|
|
146
|
-
ctx.ui.setWidget(STRIP_WIDGET, (tui, theme) => {
|
|
147
|
-
const stop = session.onChats(() => tui.requestRender());
|
|
148
|
-
const ticker = setInterval(() => {
|
|
149
|
-
if (session.chats().some((chat) => chat.status === "working"))
|
|
150
|
-
tui.requestRender();
|
|
151
|
-
}, 250);
|
|
152
|
-
ticker.unref?.();
|
|
153
|
-
return {
|
|
154
|
-
render: (width) => chatStrip(session.chats(), width, { shown: (text) => theme.bold(theme.fg("accent", text)), muted: (text) => theme.fg("muted", text) }),
|
|
155
|
-
invalidate: () => { },
|
|
156
|
-
dispose: () => {
|
|
157
|
-
stop();
|
|
158
|
-
clearInterval(ticker);
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
109
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Component, type Container, type ScrollView, type TUI } from "@earendil-works/pi-tui";
|
|
2
|
+
import type { ChatTabs } from "./chat-tabs.ts";
|
|
3
|
+
export interface ChatScreen {
|
|
4
|
+
fullscreenLayoutRoot: Component;
|
|
5
|
+
documentContainer: Container;
|
|
6
|
+
chatContainer: Container;
|
|
7
|
+
transcriptScrollView: ScrollView;
|
|
8
|
+
}
|
|
9
|
+
/** The inline tabs are a sibling of the banner in the transcript. A single fixed row takes over when they scroll
|
|
10
|
+
* off the top (or a resumed conversation has no banner). The banner itself scrolls normally. */
|
|
11
|
+
export declare function chatTabHeader(tabs: ChatTabs): {
|
|
12
|
+
mount(screen: ChatScreen, components: Component[]): Component[];
|
|
13
|
+
afterBanner(chat: Container, entry: unknown): void;
|
|
14
|
+
watch(screen: ChatScreen, tui: TUI): () => void;
|
|
15
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { VStack } from "@earendil-works/pi-tui";
|
|
2
|
+
import { terminalPointer } from "./pointer-hover.js";
|
|
3
|
+
/** Where pi drew a child. Use the row counts its Container already measured for mouse dispatch: the width of the
|
|
4
|
+
* chat, the banner's image and any wrapped warnings all affect where the divider lands. */
|
|
5
|
+
function rowOf(parent, child) {
|
|
6
|
+
const measured = parent.childLines;
|
|
7
|
+
if (measured === undefined)
|
|
8
|
+
return undefined;
|
|
9
|
+
let row = 0;
|
|
10
|
+
for (const [index, component] of measured.children.entries()) {
|
|
11
|
+
if (component === child)
|
|
12
|
+
return row;
|
|
13
|
+
row += measured.parts[index].length;
|
|
14
|
+
}
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
/** The inline tabs are a sibling of the banner in the transcript. A single fixed row takes over when they scroll
|
|
18
|
+
* off the top (or a resumed conversation has no banner). The banner itself scrolls normally. */
|
|
19
|
+
export function chatTabHeader(tabs) {
|
|
20
|
+
let pinned = true;
|
|
21
|
+
const sticky = {
|
|
22
|
+
render: (width) => pinned ? tabs.render(width) : [],
|
|
23
|
+
handleMouse: (event) => pinned ? tabs.handleMouse?.(event) : undefined,
|
|
24
|
+
invalidate() { },
|
|
25
|
+
};
|
|
26
|
+
return {
|
|
27
|
+
mount(screen, components) {
|
|
28
|
+
if (components.includes(sticky))
|
|
29
|
+
return components;
|
|
30
|
+
screen.fullscreenLayoutRoot = new VStack([sticky, { component: screen.fullscreenLayoutRoot, basis: 0, grow: 1, minSize: 1 }]);
|
|
31
|
+
return [sticky, ...components];
|
|
32
|
+
},
|
|
33
|
+
afterBanner(chat, entry) {
|
|
34
|
+
if (chat.children.includes(tabs))
|
|
35
|
+
return;
|
|
36
|
+
const at = chat.children.findIndex((child) => child.entry === entry);
|
|
37
|
+
if (at !== -1)
|
|
38
|
+
chat.children.splice(at + 1, 0, tabs);
|
|
39
|
+
},
|
|
40
|
+
watch(screen, tui) {
|
|
41
|
+
if (tui.mode !== "fullscreen") {
|
|
42
|
+
// Regular mode has native scrollback: the row below the banner scrolls with it.
|
|
43
|
+
pinned = false;
|
|
44
|
+
return () => { };
|
|
45
|
+
}
|
|
46
|
+
const view = screen.transcriptScrollView;
|
|
47
|
+
tabs.pointer = terminalPointer(tui.terminal);
|
|
48
|
+
const update = view.updateLayout;
|
|
49
|
+
view.updateLayout = function (height, viewport, redraw) {
|
|
50
|
+
update.call(this, height, viewport, redraw);
|
|
51
|
+
const chat = rowOf(screen.documentContainer, screen.chatContainer);
|
|
52
|
+
const tab = rowOf(screen.chatContainer, tabs);
|
|
53
|
+
const row = chat === undefined || tab === undefined ? -1 : chat + tab;
|
|
54
|
+
const next = row < this.scrollTop || row >= this.scrollTop + viewport;
|
|
55
|
+
if (next !== pinned) {
|
|
56
|
+
pinned = next;
|
|
57
|
+
redraw();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
// pi normally asks multiplexers for button motion only. The tabs need motion without a button too. pi disables
|
|
61
|
+
// all mouse modes itself when it leaves fullscreen, including when the terminal is suspended.
|
|
62
|
+
const mouse = tui;
|
|
63
|
+
const start = mouse.beforeTerminalStart;
|
|
64
|
+
mouse.beforeTerminalStart = function () {
|
|
65
|
+
start.call(this);
|
|
66
|
+
if (this.mouseEnabled)
|
|
67
|
+
tui.terminal.write("\x1b[?1003h");
|
|
68
|
+
};
|
|
69
|
+
const input = mouse.handleViewportInput;
|
|
70
|
+
mouse.handleViewportInput = (data) => tabs.pointer.dispatch(() => input.call(mouse, data), () => tui.requestRender());
|
|
71
|
+
return () => {
|
|
72
|
+
view.updateLayout = update;
|
|
73
|
+
mouse.beforeTerminalStart = start;
|
|
74
|
+
mouse.handleViewportInput = input;
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Component } from "@earendil-works/pi-tui";
|
|
2
|
+
import type { ChatInfo, TurriCore } from "./chats.ts";
|
|
3
|
+
import { PointerHover, type ButtonPaint } from "./pointer-hover.ts";
|
|
4
|
+
/** Shared by the tabs and the /chat picker. */
|
|
5
|
+
export declare function chatMark(chat: ChatInfo): string;
|
|
6
|
+
export type TabAction = {
|
|
7
|
+
kind: "open";
|
|
8
|
+
} | {
|
|
9
|
+
kind: "plain";
|
|
10
|
+
} | {
|
|
11
|
+
kind: "show" | "close";
|
|
12
|
+
id: string;
|
|
13
|
+
};
|
|
14
|
+
/** Shared by ×, /chat close and alt+w. The last person's chat stays open even if the sentinel has its own tab. */
|
|
15
|
+
export declare function closeTerminalChat(session: TurriCore, id: string): Promise<void>;
|
|
16
|
+
export interface ChatTabs extends Component {
|
|
17
|
+
pointer: PointerHover;
|
|
18
|
+
}
|
|
19
|
+
/** Mouse positions, like the layout, are in terminal cells, not string offsets. */
|
|
20
|
+
export declare function chatTabs(chats: () => ChatInfo[], style: ButtonPaint, pick: (action: TabAction) => void): ChatTabs;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { stripTerminalSequences, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
2
|
+
import { PointerHover } from "./pointer-hover.js";
|
|
3
|
+
import { spinner } from "./regenerate/job-panel.js";
|
|
4
|
+
/** Shared by the tabs and the /chat picker. */
|
|
5
|
+
export function chatMark(chat) {
|
|
6
|
+
switch (chat.status) {
|
|
7
|
+
case "working": return spinner(Date.now());
|
|
8
|
+
case "question": return "?";
|
|
9
|
+
case "unread": return "•";
|
|
10
|
+
default: return " ";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const buttonRole = { open: "new", plain: "panel", show: "tab", close: "close" };
|
|
14
|
+
function buttonKey(action) {
|
|
15
|
+
return "id" in action ? `${action.kind}:${action.id}` : action.kind;
|
|
16
|
+
}
|
|
17
|
+
/** Shared by ×, /chat close and alt+w. The last person's chat stays open even if the sentinel has its own tab. */
|
|
18
|
+
export async function closeTerminalChat(session, id) {
|
|
19
|
+
const chats = session.chats();
|
|
20
|
+
const people = chats.filter((chat) => chat.role === undefined);
|
|
21
|
+
if (people.length === 1 && people[0].id === id)
|
|
22
|
+
return session.notify("This is the only chat - /quit leaves turri.", "info");
|
|
23
|
+
await session.close(id);
|
|
24
|
+
}
|
|
25
|
+
function layout(chats, width) {
|
|
26
|
+
if (width <= 0)
|
|
27
|
+
return [];
|
|
28
|
+
// Keep the panel button at the right edge while chat titles grow and shrink on the left.
|
|
29
|
+
const panel = width >= 30 ? " ***plain › " : width >= 14 ? " ***plain " : width >= 6 ? "≡" : "";
|
|
30
|
+
const panelWidth = visibleWidth(panel);
|
|
31
|
+
const chatWidth = width - (panel ? panelWidth + 1 : 0);
|
|
32
|
+
// Reserve + and a close target per tab before spending cells on padding, gaps and titles.
|
|
33
|
+
const spaced = chatWidth >= chats.length * 5 + 3;
|
|
34
|
+
const plus = spaced ? " + " : "+";
|
|
35
|
+
const count = Math.min(chats.length, Math.floor((chatWidth - plus.length) / 2));
|
|
36
|
+
const room = Math.floor((chatWidth - plus.length) / Math.max(1, count)) - (spaced ? 1 : 0);
|
|
37
|
+
const parts = [];
|
|
38
|
+
for (const [index, chat] of chats.slice(0, count).entries()) {
|
|
39
|
+
const lead = !spaced ? "" : room >= 8 ? (chat.shown ? " ▸ " : " ") : (chat.shown ? "▸" : " ");
|
|
40
|
+
let label = `${lead}${index + 1}`;
|
|
41
|
+
const close = spaced ? (room > 4 ? " × " : "× ") : "×";
|
|
42
|
+
const mark = chatMark(chat).trim();
|
|
43
|
+
const suffix = mark ? ` ${mark}` : "";
|
|
44
|
+
const titleRoom = room - visibleWidth(label + close + suffix) - 1;
|
|
45
|
+
if (titleRoom > 0)
|
|
46
|
+
label += ` ${truncateToWidth(stripTerminalSequences(chat.title).replace(/\s+/g, " ").trim(), titleRoom, "…")}${suffix}`;
|
|
47
|
+
parts.push({ text: label, action: { kind: "show", id: chat.id }, shown: chat.shown }, { text: close, action: { kind: "close", id: chat.id }, shown: chat.shown });
|
|
48
|
+
if (spaced)
|
|
49
|
+
parts.push({ text: " " });
|
|
50
|
+
}
|
|
51
|
+
parts.push({ text: plus, action: { kind: "open" } });
|
|
52
|
+
if (panel) {
|
|
53
|
+
const used = parts.reduce((cells, part) => cells + visibleWidth(part.text), 0);
|
|
54
|
+
parts.push({ text: " ".repeat(width - used - panelWidth) }, { text: panel, action: { kind: "plain" } });
|
|
55
|
+
}
|
|
56
|
+
return parts;
|
|
57
|
+
}
|
|
58
|
+
/** Mouse positions, like the layout, are in terminal cells, not string offsets. */
|
|
59
|
+
export function chatTabs(chats, style, pick) {
|
|
60
|
+
let pressed;
|
|
61
|
+
return {
|
|
62
|
+
pointer: new PointerHover(),
|
|
63
|
+
render(width) {
|
|
64
|
+
return [layout(chats(), width).map((part) => part.action ? style(part.text, part.shown === true, this.pointer.target === buttonKey(part.action), buttonRole[part.action.kind]) : part.text).join("")];
|
|
65
|
+
},
|
|
66
|
+
handleMouse(event) {
|
|
67
|
+
const move = event.type === "move";
|
|
68
|
+
if (event.y !== 0 || (!move && (event.button !== "left" || (event.type !== "press" && event.type !== "click"))))
|
|
69
|
+
return;
|
|
70
|
+
const down = pressed;
|
|
71
|
+
if (!move)
|
|
72
|
+
pressed = undefined;
|
|
73
|
+
let x = 0;
|
|
74
|
+
for (const part of layout(chats(), event.width)) {
|
|
75
|
+
const end = x + visibleWidth(part.text);
|
|
76
|
+
if (event.x >= x && event.x < end && part.action) {
|
|
77
|
+
const key = buttonKey(part.action);
|
|
78
|
+
this.pointer.target = key;
|
|
79
|
+
if (move)
|
|
80
|
+
return { handled: true, render: false };
|
|
81
|
+
// Claim the press so pi delivers a click on release, without moving focus out of the editor.
|
|
82
|
+
if (event.type === "press")
|
|
83
|
+
pressed = key;
|
|
84
|
+
// A chat can change its title or close between press and release, moving another tab under the pointer.
|
|
85
|
+
else if (down === key && !(part.shown && part.action.kind === "show")) {
|
|
86
|
+
this.pointer.target = undefined;
|
|
87
|
+
pick(part.action);
|
|
88
|
+
}
|
|
89
|
+
return { handled: true };
|
|
90
|
+
}
|
|
91
|
+
x = end;
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
invalidate() { },
|
|
95
|
+
};
|
|
96
|
+
}
|
package/dist/chat-terminal.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { AgentSessionRuntime, InteractiveMode, SessionManager } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { chatTabHeader } from "./chat-tab-header.js";
|
|
3
|
+
import { chatTabs, closeTerminalChat } from "./chat-tabs.js";
|
|
2
4
|
import { showWaitingMessages } from "./chat-waiting.js";
|
|
5
|
+
import { buttonLabel } from "./pointer-hover.js";
|
|
3
6
|
import { interruptChat, terminalUi } from "./chats.js";
|
|
4
7
|
/**
|
|
5
8
|
* ctrl+c, in the chat shown: what it is doing stopped, the other chats left as they are (`interruptChat`). In a chat
|
|
@@ -59,6 +62,47 @@ export function driveTerminal(core, options = {}) {
|
|
|
59
62
|
};
|
|
60
63
|
showWaitingMessages();
|
|
61
64
|
const prototype = InteractiveMode.prototype;
|
|
65
|
+
let switching = false;
|
|
66
|
+
const tabs = chatTabs(() => core.chats(), (text, shown, hovered, role) => {
|
|
67
|
+
const theme = real?.theme;
|
|
68
|
+
return theme === undefined ? text : buttonLabel(theme, text, shown, hovered, role);
|
|
69
|
+
}, (action) => {
|
|
70
|
+
if (switching || runtime === undefined)
|
|
71
|
+
return;
|
|
72
|
+
if (action.kind === "plain")
|
|
73
|
+
return core.shownChat()?.instance?.openPlainPanel?.();
|
|
74
|
+
switching = true;
|
|
75
|
+
const change = action.kind === "open" ? core.open() : action.kind === "close" ? closeTerminalChat(core, action.id) : core.show(action.id);
|
|
76
|
+
void change.catch((error) => core.notify(error instanceof Error ? error.message : String(error), "warning")).finally(() => { switching = false; });
|
|
77
|
+
});
|
|
78
|
+
const header = chatTabHeader(tabs);
|
|
79
|
+
const addEntry = prototype.addCustomEntryToChat;
|
|
80
|
+
prototype.addCustomEntryToChat = function (entry) {
|
|
81
|
+
addEntry.call(this, entry);
|
|
82
|
+
if (entry.customType === "turri_banner")
|
|
83
|
+
header.afterBanner(this.chatContainer, entry);
|
|
84
|
+
};
|
|
85
|
+
let stopWatchingTabs;
|
|
86
|
+
const mount = prototype.mountInteractiveTui;
|
|
87
|
+
prototype.mountInteractiveTui = function (tui, components) {
|
|
88
|
+
stopWatchingTabs?.();
|
|
89
|
+
mount.call(this, tui, header.mount(this, components));
|
|
90
|
+
const unwatch = header.watch(this, tui);
|
|
91
|
+
let ticker;
|
|
92
|
+
const refresh = () => {
|
|
93
|
+
if (core.chats().some((chat) => chat.status === "working")) {
|
|
94
|
+
ticker ??= setInterval(() => tui.requestRender(), 250).unref();
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
clearInterval(ticker);
|
|
98
|
+
ticker = undefined;
|
|
99
|
+
}
|
|
100
|
+
tui.requestRender();
|
|
101
|
+
};
|
|
102
|
+
const stop = core.onChats(refresh);
|
|
103
|
+
refresh();
|
|
104
|
+
stopWatchingTabs = () => { stop(); clearInterval(ticker); unwatch(); };
|
|
105
|
+
};
|
|
62
106
|
const rebind = prototype.rebindCurrentSession;
|
|
63
107
|
prototype.rebindCurrentSession = async function (...args) {
|
|
64
108
|
await rebind.apply(this, args);
|
|
@@ -102,8 +146,10 @@ export function driveTerminal(core, options = {}) {
|
|
|
102
146
|
// Leaving turri: every chat let go - the one shown by pi, as it always is.
|
|
103
147
|
const dispose = runtimes.dispose;
|
|
104
148
|
runtimes.dispose = async function () {
|
|
105
|
-
if (this === runtime)
|
|
149
|
+
if (this === runtime) {
|
|
150
|
+
stopWatchingTabs?.();
|
|
106
151
|
await core.dispose({ except: runtime.session });
|
|
152
|
+
}
|
|
107
153
|
return dispose.call(this);
|
|
108
154
|
};
|
|
109
155
|
core.setDriver({
|
|
@@ -135,17 +181,17 @@ export function driveTerminal(core, options = {}) {
|
|
|
135
181
|
return;
|
|
136
182
|
from?.ui?.hide();
|
|
137
183
|
// pi takes the shown chat's widgets and dialogs off the screen, as it does before replacing a session - but not the
|
|
138
|
-
//
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
184
|
+
// overlays on it: the side panel, the session's and not the chat's, stays where it is, beside the chat or over it.
|
|
185
|
+
// pi takes off every overlay it holds, so for that moment it holds none.
|
|
186
|
+
const overlays = screen?.extensionOverlays;
|
|
187
|
+
const kept = [...(overlays ?? [])];
|
|
188
|
+
overlays?.clear();
|
|
143
189
|
try {
|
|
144
190
|
runtime.beforeSessionInvalidate?.();
|
|
145
191
|
}
|
|
146
192
|
finally {
|
|
147
|
-
|
|
148
|
-
|
|
193
|
+
for (const [handle, remove] of kept)
|
|
194
|
+
overlays?.set(handle, remove);
|
|
149
195
|
}
|
|
150
196
|
runtime._session = chat.session;
|
|
151
197
|
runtime._services = chat.services;
|
package/dist/chat-waiting.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ import { type Component } from "@earendil-works/pi-tui";
|
|
|
14
14
|
export interface WaitingScreen {
|
|
15
15
|
chatContainer: Container;
|
|
16
16
|
pendingMessagesContainer: Container;
|
|
17
|
+
/** The output of commands the person ran (`!`) while the agent works: pi keeps it there until it goes in the chat. */
|
|
18
|
+
pendingBashComponents?: Component[];
|
|
17
19
|
getAllQueuedMessages(): {
|
|
18
20
|
steering: string[];
|
|
19
21
|
followUp: string[];
|
|
@@ -36,7 +38,8 @@ export declare class Shade implements Component {
|
|
|
36
38
|
}
|
|
37
39
|
/**
|
|
38
40
|
* Under the chat, each message the agent has not read yet, drawn as pi draws a message in the chat - shaded, and
|
|
39
|
-
* marked not read yet - in the order they were sent
|
|
41
|
+
* marked not read yet - in the order they were sent; under the output of any command the person ran meanwhile, as pi
|
|
42
|
+
* draws them.
|
|
40
43
|
*/
|
|
41
44
|
export declare function showWaiting(screen: WaitingScreen): void;
|
|
42
45
|
/** What of pi's session `unqueue` reaches. */
|
package/dist/chat-waiting.js
CHANGED
|
@@ -21,11 +21,14 @@ export class Shade {
|
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* Under the chat, each message the agent has not read yet, drawn as pi draws a message in the chat - shaded, and
|
|
24
|
-
* marked not read yet - in the order they were sent
|
|
24
|
+
* marked not read yet - in the order they were sent; under the output of any command the person ran meanwhile, as pi
|
|
25
|
+
* draws them.
|
|
25
26
|
*/
|
|
26
27
|
export function showWaiting(screen) {
|
|
27
28
|
const area = screen.pendingMessagesContainer;
|
|
28
29
|
area.clear();
|
|
30
|
+
for (const output of screen.pendingBashComponents ?? [])
|
|
31
|
+
area.addChild(output);
|
|
29
32
|
const { steering, followUp } = screen.getAllQueuedMessages();
|
|
30
33
|
const waiting = [...steering, ...followUp];
|
|
31
34
|
if (waiting.length === 0)
|
|
@@ -36,9 +39,9 @@ export function showWaiting(screen) {
|
|
|
36
39
|
const chat = screen.chatContainer;
|
|
37
40
|
screen.chatContainer = area;
|
|
38
41
|
try {
|
|
39
|
-
for (const text of waiting) {
|
|
40
|
-
// A line between it and
|
|
41
|
-
if (
|
|
42
|
+
for (const [index, text] of waiting.entries()) {
|
|
43
|
+
// A line between it and what is above it; pi puts one between messages itself.
|
|
44
|
+
if (index === 0)
|
|
42
45
|
area.addChild(new Spacer(1));
|
|
43
46
|
const before = area.children.length;
|
|
44
47
|
screen.addMessageToChat({ role: "user", content: [{ type: "text", text }], timestamp: Date.now() });
|
package/dist/chats.d.ts
CHANGED
|
@@ -102,6 +102,8 @@ export interface TurriHost {
|
|
|
102
102
|
}
|
|
103
103
|
/** What a chat's extension does for its chat when the session asks. */
|
|
104
104
|
export interface ChatInstance {
|
|
105
|
+
/** The terminal header's button: open the project's spec map beside this chat. */
|
|
106
|
+
openPlainPanel?(): void;
|
|
105
107
|
/** A pulse it asked for ended: said in the chat, and its agent told, to react to it. */
|
|
106
108
|
announce(job: Job): void;
|
|
107
109
|
/**
|
package/dist/extension.js
CHANGED
|
@@ -78,6 +78,7 @@ import { ignoredGuidance, keepGuidance, landedNote, pulseEndsBlock, SENTINEL, SE
|
|
|
78
78
|
import { noticeDialogs, registerSentinel } from "./sentinel-chat.js";
|
|
79
79
|
import { currentChat } from "./chat-scope.js";
|
|
80
80
|
import { registerChats } from "./chat-commands.js";
|
|
81
|
+
import { buttonLabel, terminalPointer } from "./pointer-hover.js";
|
|
81
82
|
import { turriIdentity } from "./environment.js";
|
|
82
83
|
import { answerSideQuestion, askWithAsides, BTW_HOW, runningSkill, skillRunStarted, skillSessionText, transcriptOf } from "./btw.js";
|
|
83
84
|
import { createJobRegistry, defaultParallelJobs, describeJob, formatDuration, pulseName, shouldWait, STOPPED_ON_REQUEST, } from "./regenerate/jobs.js";
|
|
@@ -548,6 +549,11 @@ function turriExtension(api, session, link) {
|
|
|
548
549
|
};
|
|
549
550
|
const notices = noticeDialogs(pi, session, link, contextNow);
|
|
550
551
|
link.live({
|
|
552
|
+
openPlainPanel: () => {
|
|
553
|
+
const ctx = contextNow();
|
|
554
|
+
if (ctx?.hasUI)
|
|
555
|
+
sidePanelOf(jobs, cwd).open(ctx, "map", "beside");
|
|
556
|
+
},
|
|
551
557
|
announce,
|
|
552
558
|
landed,
|
|
553
559
|
brief,
|
|
@@ -2286,7 +2292,7 @@ function sidePanelOf(jobs, cwd) {
|
|
|
2286
2292
|
if (known !== undefined)
|
|
2287
2293
|
return known;
|
|
2288
2294
|
const self = {
|
|
2289
|
-
open: (ctx, view) => openPanel(ctx, view),
|
|
2295
|
+
open: (ctx, view, placement) => openPanel(ctx, view, placement),
|
|
2290
2296
|
shown: () => panel !== undefined && panel.keys,
|
|
2291
2297
|
};
|
|
2292
2298
|
sidePanels.set(jobs, self);
|
|
@@ -2324,7 +2330,7 @@ function sidePanelOf(jobs, cwd) {
|
|
|
2324
2330
|
plan: () => workLoops.get(jobs)?.loop.mapPlan() ?? { files: [], codebases: [] },
|
|
2325
2331
|
});
|
|
2326
2332
|
/** Open the side panel - on the view named, or as it was left. */
|
|
2327
|
-
const openPanel = (ctx, view) => {
|
|
2333
|
+
const openPanel = (ctx, view, placement) => {
|
|
2328
2334
|
// Found: ctrl+h under the job panel stops breathing.
|
|
2329
2335
|
keyPressed("peek");
|
|
2330
2336
|
if (view !== undefined)
|
|
@@ -2337,7 +2343,10 @@ function sidePanelOf(jobs, cwd) {
|
|
|
2337
2343
|
mapState.view = "pulses";
|
|
2338
2344
|
}
|
|
2339
2345
|
needsLooking.delete(jobs);
|
|
2346
|
+
if (placement === "beside")
|
|
2347
|
+
panelDocked = true;
|
|
2340
2348
|
if (panel !== undefined) {
|
|
2349
|
+
panel.layOut();
|
|
2341
2350
|
panel.keepChatFocus();
|
|
2342
2351
|
panel.handle?.setHidden(false);
|
|
2343
2352
|
panel.keys = true;
|
|
@@ -2406,6 +2415,8 @@ function sidePanelOf(jobs, cwd) {
|
|
|
2406
2415
|
// Opened, it reads the files again at once: they may have changed while it was closed.
|
|
2407
2416
|
specMap.refresh();
|
|
2408
2417
|
const view = createSidePanel({
|
|
2418
|
+
pointer: terminalPointer(tui.terminal),
|
|
2419
|
+
tabLabel: (text, active, hovered, role) => buttonLabel(theme, text, active, hovered, role),
|
|
2409
2420
|
jobs: () => shownJobs(jobs),
|
|
2410
2421
|
earlier: earlierJobs,
|
|
2411
2422
|
tree: jobsTree,
|
|
@@ -2451,7 +2462,7 @@ function sidePanelOf(jobs, cwd) {
|
|
|
2451
2462
|
return focused !== null && focused !== component;
|
|
2452
2463
|
},
|
|
2453
2464
|
});
|
|
2454
|
-
const entry = { view, close, keepChatFocus, keys: true };
|
|
2465
|
+
const entry = { view, close, keepChatFocus, layOut, keys: true };
|
|
2455
2466
|
panel = entry;
|
|
2456
2467
|
layOut();
|
|
2457
2468
|
// Every key goes to the panel while it shows, whatever has the focus: a question the chat model asks in the
|
|
@@ -2529,7 +2540,7 @@ function sidePanelOf(jobs, cwd) {
|
|
|
2529
2540
|
view.handleInput(data);
|
|
2530
2541
|
tui.requestRender();
|
|
2531
2542
|
},
|
|
2532
|
-
handleMouse: (event) => view.handleMouse(event),
|
|
2543
|
+
handleMouse: (event) => view.handleMouse(panelBeside() > 0 ? { ...event, x: event.x - 2, width: event.width - 2 } : event),
|
|
2533
2544
|
invalidate: () => view.invalidate(),
|
|
2534
2545
|
dispose: () => {
|
|
2535
2546
|
unlisten();
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
export type ButtonRole = "tab" | "new" | "close" | "panel";
|
|
3
|
+
export type ButtonPaint = (text: string, active: boolean, hovered: boolean, role: ButtonRole) => string;
|
|
4
|
+
/** The layout owns the padding, so the entire coloured surface is also the click target. */
|
|
5
|
+
export declare function buttonLabel(theme: Theme, text: string, active: boolean, hovered: boolean, role: ButtonRole): string;
|
|
6
|
+
/** pi sends moves to the component under the pointer but has no leave event. Share one hover target across the
|
|
7
|
+
* screen: if the next input is dispatched elsewhere the old highlight goes away. Redraw only on a change. */
|
|
8
|
+
export declare class PointerHover {
|
|
9
|
+
target: string | undefined;
|
|
10
|
+
dispatch<T>(dispatch: () => T, redraw: () => void): T;
|
|
11
|
+
}
|
|
12
|
+
export declare function terminalPointer(terminal: object): PointerHover;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { colorToRgb, parseColor } from "@earendil-works/pi-tui";
|
|
2
|
+
const abyss = parseColor("#0a0f1a");
|
|
3
|
+
const white = parseColor("#f4f7f9");
|
|
4
|
+
const linear = (byte) => byte <= 10 ? byte / 3294.6 : ((byte / 255 + 0.055) / 1.055) ** 2.4;
|
|
5
|
+
function luminance(color) {
|
|
6
|
+
const { r, g, b } = colorToRgb(color);
|
|
7
|
+
return 0.2126 * linear(r) + 0.7152 * linear(g) + 0.0722 * linear(b);
|
|
8
|
+
}
|
|
9
|
+
// The point at which white and abyss have equal contrast on a fill. Paint both sides explicitly: the
|
|
10
|
+
// terminal's own background can still be dark when the person picks the light theme (and vice versa).
|
|
11
|
+
const inkSwitch = Math.sqrt((luminance(abyss) + 0.05) * (luminance(white) + 0.05)) - 0.05;
|
|
12
|
+
/** The layout owns the padding, so the entire coloured surface is also the click target. */
|
|
13
|
+
export function buttonLabel(theme, text, active, hovered, role) {
|
|
14
|
+
if (role === "new" || active || hovered) {
|
|
15
|
+
const fill = theme.colors[role === "new" ? "success" : role === "close" && hovered ? "error" : "accent"];
|
|
16
|
+
return theme.style(text, { bg: fill, fg: luminance(fill) > inkSwitch ? abyss : white, bold: true, underline: hovered });
|
|
17
|
+
}
|
|
18
|
+
return theme.style(text, { bg: "selectedBg", fg: role === "panel" ? "accent" : "text", bold: role === "panel" });
|
|
19
|
+
}
|
|
20
|
+
/** pi sends moves to the component under the pointer but has no leave event. Share one hover target across the
|
|
21
|
+
* screen: if the next input is dispatched elsewhere the old highlight goes away. Redraw only on a change. */
|
|
22
|
+
export class PointerHover {
|
|
23
|
+
target;
|
|
24
|
+
dispatch(dispatch, redraw) {
|
|
25
|
+
const before = this.target;
|
|
26
|
+
this.target = undefined;
|
|
27
|
+
try {
|
|
28
|
+
return dispatch();
|
|
29
|
+
}
|
|
30
|
+
finally {
|
|
31
|
+
if (before !== this.target)
|
|
32
|
+
redraw();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const pointers = new WeakMap();
|
|
37
|
+
export function terminalPointer(terminal) {
|
|
38
|
+
let pointer = pointers.get(terminal);
|
|
39
|
+
if (pointer === undefined) {
|
|
40
|
+
pointer = new PointerHover();
|
|
41
|
+
pointers.set(terminal, pointer);
|
|
42
|
+
}
|
|
43
|
+
return pointer;
|
|
44
|
+
}
|
|
@@ -54,6 +54,7 @@ export declare function jobsTreeRows(jobs: Job[], state: JobsTreeState): TreeRow
|
|
|
54
54
|
export declare function jobsTreeLines(jobs: Job[], state: JobsTreeState, width: number, style: TranscriptStyle): {
|
|
55
55
|
lines: string[];
|
|
56
56
|
rowStarts: number[];
|
|
57
|
+
labelHeights: number[];
|
|
57
58
|
rows: TreeRow[];
|
|
58
59
|
};
|
|
59
60
|
/** Keep the cursor's row in sight: scroll only as far as that takes. */
|
|
@@ -170,6 +170,7 @@ export function jobsTreeLines(jobs, state, width, style) {
|
|
|
170
170
|
state.cursor = Math.max(0, Math.min(state.cursor, rows.length - 1));
|
|
171
171
|
const lines = [];
|
|
172
172
|
const rowStarts = [];
|
|
173
|
+
const labelHeights = [];
|
|
173
174
|
rows.forEach((row, index) => {
|
|
174
175
|
rowStarts.push(lines.length);
|
|
175
176
|
const here = index === state.cursor;
|
|
@@ -182,12 +183,14 @@ export function jobsTreeLines(jobs, state, width, style) {
|
|
|
182
183
|
}
|
|
183
184
|
const header = `${pointer} ${state.open[row.section] ? "▾" : "▸"} ${SECTION_NAMES[row.section]} (${row.count})`;
|
|
184
185
|
lines.push(here ? style.heading(header) : style.muted(header));
|
|
186
|
+
labelHeights.push(1);
|
|
185
187
|
return;
|
|
186
188
|
}
|
|
187
189
|
if (row.kind === "file") {
|
|
188
190
|
const open = isFileOpen(state, row);
|
|
189
191
|
const paint = style.diff ?? { ...PLAIN_PAINT, added: style.added, removed: style.removed, muted: style.muted };
|
|
190
192
|
const shown = diffFiles(row.job.diff, Math.max(10, width - FILE_INDENT.length), paint, row.job.diffWhere).find((file) => file.file === row.file);
|
|
193
|
+
labelHeights.push(shown === undefined ? 0 : 1);
|
|
191
194
|
if (shown === undefined)
|
|
192
195
|
return;
|
|
193
196
|
const header = `${pointer}${FILE_INDENT.slice(1)}${fileHeader(shown, paint, open)}`;
|
|
@@ -204,6 +207,7 @@ export function jobsTreeLines(jobs, state, width, style) {
|
|
|
204
207
|
const head = `${pointer} ${open ? "▾" : "▸"} ${markOf(job, style)} ${pulseName(job)}${time}${pulseCost(job)}`;
|
|
205
208
|
const [first = "", ...rest] = wrapTextWithAnsi(head, Math.max(10, width));
|
|
206
209
|
lines.push(here ? style.heading(first) : first, ...rest.map((line) => ` ${line}`));
|
|
210
|
+
labelHeights.push(1 + rest.length);
|
|
207
211
|
if (open)
|
|
208
212
|
lines.push(...detailLines(job, jobs, width, style));
|
|
209
213
|
});
|
|
@@ -211,7 +215,7 @@ export function jobsTreeLines(jobs, state, width, style) {
|
|
|
211
215
|
if (state.open.earlier && (state.earlierMore ?? 0) > 0) {
|
|
212
216
|
lines.push(style.muted(` ${state.earlierMore} earlier run${state.earlierMore === 1 ? "" : "s"} in the ledger - pulses with runs lists them`));
|
|
213
217
|
}
|
|
214
|
-
return { lines, rowStarts, rows };
|
|
218
|
+
return { lines, rowStarts, labelHeights, rows };
|
|
215
219
|
}
|
|
216
220
|
/** How far a job's files, and their lines, are indented under it. */
|
|
217
221
|
const FILE_INDENT = " ";
|
|
@@ -4,6 +4,7 @@ import { type JobsTreeState } from "./jobs-tree.ts";
|
|
|
4
4
|
import type { MarkedPage } from "./spec-map.ts";
|
|
5
5
|
import { type SpecMapState } from "./spec-map-view.ts";
|
|
6
6
|
import type { TranscriptStyle } from "./transcript-view.ts";
|
|
7
|
+
import type { ButtonPaint, PointerHover } from "../pointer-hover.ts";
|
|
7
8
|
/**
|
|
8
9
|
* The side panel: the spec and how far the code has been regenerated, beside the conversation rather than instead of
|
|
9
10
|
* it.
|
|
@@ -21,6 +22,8 @@ export interface SidePanelOptions {
|
|
|
21
22
|
earlier?: () => Job[];
|
|
22
23
|
/** The regeneration's pages. Not given: the pulse list alone. */
|
|
23
24
|
map?: () => MarkedPage[];
|
|
25
|
+
pointer?: PointerHover;
|
|
26
|
+
tabLabel?: ButtonPaint;
|
|
24
27
|
/** Rows the panel may use. */
|
|
25
28
|
rows: () => number;
|
|
26
29
|
style: TranscriptStyle;
|
|
@@ -53,7 +56,7 @@ export interface SidePanelOptions {
|
|
|
53
56
|
export declare function createSidePanel(options: SidePanelOptions): {
|
|
54
57
|
render(width: number): string[];
|
|
55
58
|
handleInput(data: string): void;
|
|
56
|
-
/**
|
|
59
|
+
/** View tabs switch on a click, and the wheel scrolls the panel wherever the keyboard is. */
|
|
57
60
|
handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined;
|
|
58
61
|
invalidate(): void;
|
|
59
62
|
};
|
|
@@ -12,6 +12,48 @@ export function createSidePanel(options) {
|
|
|
12
12
|
let drawnTree = { rows: [], rowStarts: [], lineCount: 0 };
|
|
13
13
|
let drawnMap = { rows: [], rowStarts: [], lineCount: 0 };
|
|
14
14
|
let pages = [];
|
|
15
|
+
let pressed;
|
|
16
|
+
// Hit regions for the last frame, in panel-local cells (the dock border is outside them).
|
|
17
|
+
const hits = new Map();
|
|
18
|
+
const hit = (y, target) => {
|
|
19
|
+
const row = hits.get(y);
|
|
20
|
+
if (row)
|
|
21
|
+
row.push(target);
|
|
22
|
+
else
|
|
23
|
+
hits.set(y, [target]);
|
|
24
|
+
};
|
|
25
|
+
let headerHeight = 0;
|
|
26
|
+
function hitLabels(drawn, first, y, height, width, target) {
|
|
27
|
+
drawn.rows.forEach((row, index) => {
|
|
28
|
+
const start = drawn.rowStarts[index] - first;
|
|
29
|
+
const end = Math.min(height, start + drawn.labelHeights[index]);
|
|
30
|
+
if (Math.max(0, start) >= end)
|
|
31
|
+
return;
|
|
32
|
+
const label = { ...target(row, index), x: 0, end: width };
|
|
33
|
+
for (let line = Math.max(0, start); line < end; line++)
|
|
34
|
+
hit(headerHeight + y + line, label);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const controls = (width) => {
|
|
38
|
+
if (width <= 0 || (!options.map && !options.dock))
|
|
39
|
+
return [];
|
|
40
|
+
const close = width >= 30 ? " × close " : width >= 3 ? " × " : "×";
|
|
41
|
+
const right = width - visibleWidth(close);
|
|
42
|
+
const buttons = [];
|
|
43
|
+
let x = 0;
|
|
44
|
+
if (options.map) {
|
|
45
|
+
for (const [action, label] of [["map", "***plain"], ["pulses", "pulses"]]) {
|
|
46
|
+
const marker = width >= 30 ? (map.view === action ? "▸ " : " ") : "";
|
|
47
|
+
const text = truncateToWidth(` ${marker}${label} `, Math.max(0, right - x - 1), "");
|
|
48
|
+
if (!text)
|
|
49
|
+
break;
|
|
50
|
+
buttons.push({ action, text, x });
|
|
51
|
+
x += visibleWidth(text) + 1;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return [...buttons, { action: "close", text: close, x: right }];
|
|
55
|
+
};
|
|
56
|
+
const tabLabel = options.tabLabel ?? ((text, active) => active ? style.heading(text) : style.muted(text));
|
|
15
57
|
/** The keys back to the chat - and `s`, from over the screen to beside the chat and back. */
|
|
16
58
|
const backKeys = () => {
|
|
17
59
|
if (options.dock === undefined)
|
|
@@ -65,7 +107,7 @@ export function createSidePanel(options) {
|
|
|
65
107
|
/** The rule under the top. */
|
|
66
108
|
const rule = (width) => style.muted("─".repeat(Math.max(1, width)));
|
|
67
109
|
const renderPulses = (width, rows) => {
|
|
68
|
-
const keys = ["↑↓ move", "enter open/close", "←→", "o/c all", "pgup pgdn scroll", ...(options.map !== undefined ? ["p regen"] : []), ...backKeys()];
|
|
110
|
+
const keys = ["↑↓ move", "click/enter open/close", "←→", "o/c all", "pgup pgdn scroll", ...(options.map !== undefined ? ["p regen"] : []), ...backKeys()];
|
|
69
111
|
const top = topBlock([`${style.heading("pulses")}${waitingNote()}`], keys, width);
|
|
70
112
|
// Under the top: the rule, and a line of space - as the map has.
|
|
71
113
|
const bodyHeight = Math.max(3, rows - top.length - 2);
|
|
@@ -75,6 +117,10 @@ export function createSidePanel(options) {
|
|
|
75
117
|
const tree_ = jobsTreeLines([...options.jobs(), ...(options.earlier?.() ?? [])], tree, width, style);
|
|
76
118
|
drawnTree = { rows: tree_.rows, rowStarts: tree_.rowStarts, lineCount: tree_.lines.length };
|
|
77
119
|
keepCursorInView(tree, tree_.rowStarts, tree_.lines.length, bodyHeight);
|
|
120
|
+
hitLabels(tree_, tree.top, top.length + 2, bodyHeight, width, (row, index) => ({
|
|
121
|
+
key: `tree:${row.section}:${row.kind}:${row.kind !== "section" ? row.job.id : ""}:${row.kind === "file" ? row.file : ""}`,
|
|
122
|
+
pick: () => { tree.cursor = index; treeKey(tree, drawnTree.rows, "toggle"); },
|
|
123
|
+
}));
|
|
78
124
|
const visible = tree_.lines.slice(tree.top, tree.top + bodyHeight);
|
|
79
125
|
while (visible.length < bodyHeight)
|
|
80
126
|
visible.push("");
|
|
@@ -94,12 +140,19 @@ export function createSidePanel(options) {
|
|
|
94
140
|
const tabbed = pages.length > 1;
|
|
95
141
|
const page = shownPage(pages, map);
|
|
96
142
|
const discuss = page.stuck && options.discuss !== undefined ? [`${DISCUSS_KEY} talk it through in the chat`] : [];
|
|
97
|
-
const keys = [...discuss, "↑↓ move", "enter open/close", ...(tabbed ? ["←→ module"] : []), "o/c all", "pgup pgdn", "p pulses", ...backKeys()];
|
|
143
|
+
const keys = [...discuss, "↑↓ move", "click/enter open/close", ...(tabbed ? ["←→ module"] : []), "o/c all", "pgup pgdn", "p pulses", ...backKeys()];
|
|
98
144
|
// The legend's box in the upper right corner, over what is under it; too narrow a panel has none.
|
|
99
145
|
const box = width >= 60 ? legendBox(legendLines(page, style)) : [];
|
|
100
146
|
const room = box.length > 0 ? width - visibleWidth(box[0]) - 1 : width;
|
|
101
147
|
// The top line whole - it wraps beside the box; the tabs fit themselves, counting what does not fit.
|
|
102
|
-
const title = [specMapHeader(page, Number.MAX_SAFE_INTEGER, style, waitingNote())
|
|
148
|
+
const title = [specMapHeader(page, Number.MAX_SAFE_INTEGER, style, waitingNote())];
|
|
149
|
+
if (tabbed) {
|
|
150
|
+
const tabs = tabBar(pages, page, room, style, now);
|
|
151
|
+
const y = headerHeight + wrapTextWithAnsi(title[0], room).length;
|
|
152
|
+
for (const tab of tabs.targets)
|
|
153
|
+
hit(y, { key: `module:${tab.page.plainFile}`, x: tab.x, end: tab.end, pick: () => switchTab(pages, map, pages.indexOf(tab.page) - pages.indexOf(page)) });
|
|
154
|
+
title.push(tabs.line);
|
|
155
|
+
}
|
|
103
156
|
const top = topBlock(title, keys, room);
|
|
104
157
|
// Under the top: the rule, a line of space, and the columns' headings - two lines.
|
|
105
158
|
const bodyHeight = Math.max(3, rows - top.length - 4);
|
|
@@ -110,6 +163,19 @@ export function createSidePanel(options) {
|
|
|
110
163
|
const drawn = long ? specMapLines(pages, map, width - 2, style, options.jobs(), now) : first;
|
|
111
164
|
drawnMap = { rows: drawn.rows, rowStarts: drawn.rowStarts, lineCount: drawn.lines.length };
|
|
112
165
|
keepCursorInView(map, drawn.rowStarts, drawn.lines.length, bodyHeight);
|
|
166
|
+
const headings = columnHeadings(page, width, style);
|
|
167
|
+
const bodyY = top.length + 2 + headings.length;
|
|
168
|
+
hitLabels(drawn, map.top, bodyY, bodyHeight, long ? width - 2 : width, (row, index) => ({
|
|
169
|
+
key: `map:${row.key}`,
|
|
170
|
+
pick: () => { map.cursor = index; map.cursorKey = row.key; toggleMapRow(row); },
|
|
171
|
+
}));
|
|
172
|
+
// On a short header the legend can cover part of a body row as well.
|
|
173
|
+
for (let i = bodyY; i < box.length; i++) {
|
|
174
|
+
const y = headerHeight + i;
|
|
175
|
+
const row = hits.get(y);
|
|
176
|
+
if (row)
|
|
177
|
+
hits.set(y, row.map((target) => ({ ...target, end: Math.min(target.end, room) })));
|
|
178
|
+
}
|
|
113
179
|
const visible = drawn.lines.slice(map.top, map.top + bodyHeight).map((line) => truncateToWidth(line, long ? width - 2 : width));
|
|
114
180
|
while (visible.length < bodyHeight)
|
|
115
181
|
visible.push("");
|
|
@@ -120,7 +186,7 @@ export function createSidePanel(options) {
|
|
|
120
186
|
})()
|
|
121
187
|
: visible;
|
|
122
188
|
// The rule beside the box stops short of it.
|
|
123
|
-
return overBox([...top, rule(top.length < box.length ? room - 1 : width), "", ...
|
|
189
|
+
return overBox([...top, rule(top.length < box.length ? room - 1 : width), "", ...headings, ...body], box, width);
|
|
124
190
|
};
|
|
125
191
|
/** From the map to the pulse list: onto the pulse that regenerates the item under the cursor, when one does. */
|
|
126
192
|
const toPulses = () => {
|
|
@@ -155,6 +221,17 @@ export function createSidePanel(options) {
|
|
|
155
221
|
return;
|
|
156
222
|
}
|
|
157
223
|
};
|
|
224
|
+
const toggleMapRow = (target, open) => {
|
|
225
|
+
if (target === undefined || target.kind === "group")
|
|
226
|
+
return;
|
|
227
|
+
const to = open ?? !(target.kind === "import" ? target.open : map.open.has(target.key));
|
|
228
|
+
if (target.kind === "import")
|
|
229
|
+
map.imports.set(target.key.replace(/^import\n/, ""), to);
|
|
230
|
+
else if (to)
|
|
231
|
+
map.open.add(target.key);
|
|
232
|
+
else
|
|
233
|
+
map.open.delete(target.key);
|
|
234
|
+
};
|
|
158
235
|
/** A key in the map. */
|
|
159
236
|
const mapKey = (data) => {
|
|
160
237
|
const page = Math.max(1, lastBodyHeight - 1);
|
|
@@ -164,25 +241,12 @@ export function createSidePanel(options) {
|
|
|
164
241
|
map.cursor = Math.max(0, Math.min(rows.length - 1, to));
|
|
165
242
|
map.cursorKey = rows[map.cursor]?.key;
|
|
166
243
|
};
|
|
167
|
-
const isOpen = (target) => (target.kind === "item" ? map.open.has(target.key) : target.kind === "group" ? false : target.open);
|
|
168
|
-
const toggle = (target, open) => {
|
|
169
|
-
// A group's heading only says what is under it.
|
|
170
|
-
if (target === undefined || target.kind === "group")
|
|
171
|
-
return;
|
|
172
|
-
const to = open ?? !isOpen(target);
|
|
173
|
-
if (target.kind === "import")
|
|
174
|
-
map.imports.set(target.key.replace(/^import\n/, ""), to);
|
|
175
|
-
else if (to)
|
|
176
|
-
map.open.add(target.key);
|
|
177
|
-
else
|
|
178
|
-
map.open.delete(target.key);
|
|
179
|
-
};
|
|
180
244
|
if (matchesKey(data, Key.up))
|
|
181
245
|
move(map.cursor - 1);
|
|
182
246
|
else if (matchesKey(data, Key.down))
|
|
183
247
|
move(map.cursor + 1);
|
|
184
248
|
else if (matchesKey(data, Key.enter) || data === " ")
|
|
185
|
-
|
|
249
|
+
toggleMapRow(row);
|
|
186
250
|
// ←→ go from one module's tab to the next.
|
|
187
251
|
else if (matchesKey(data, Key.right))
|
|
188
252
|
switchTab(pages, map, 1);
|
|
@@ -190,7 +254,7 @@ export function createSidePanel(options) {
|
|
|
190
254
|
switchTab(pages, map, -1);
|
|
191
255
|
else if (data === "o" || data === "c")
|
|
192
256
|
for (const entry of rows)
|
|
193
|
-
|
|
257
|
+
toggleMapRow(entry, data === "o");
|
|
194
258
|
else if (data === DISCUSS_KEY && options.discuss !== undefined) {
|
|
195
259
|
const shown = shownPage(pages, map);
|
|
196
260
|
if (shown?.stuck === true)
|
|
@@ -211,15 +275,26 @@ export function createSidePanel(options) {
|
|
|
211
275
|
};
|
|
212
276
|
return {
|
|
213
277
|
render(width) {
|
|
214
|
-
|
|
278
|
+
hits.clear();
|
|
279
|
+
let bar = "";
|
|
280
|
+
let end = 0;
|
|
281
|
+
for (const { action, text, x } of controls(width)) {
|
|
282
|
+
bar += " ".repeat(x - end) + tabLabel(text, map.view === action, options.pointer?.target === `panel:${action}`, action === "close" ? "close" : "tab");
|
|
283
|
+
end = x + visibleWidth(text);
|
|
284
|
+
}
|
|
285
|
+
const header = bar ? [bar] : [];
|
|
286
|
+
headerHeight = header.length;
|
|
287
|
+
const rows = Math.max(8, options.rows()) - header.length;
|
|
215
288
|
try {
|
|
216
|
-
return map.view === "map" && options.map !== undefined ? renderMap(width, rows) : renderPulses(width, rows);
|
|
289
|
+
return [...header, ...(map.view === "map" && options.map !== undefined ? renderMap(width, rows) : renderPulses(width, rows))];
|
|
217
290
|
}
|
|
218
291
|
catch (error) {
|
|
292
|
+
hits.clear();
|
|
219
293
|
// A frame that throws is never drawn - nor is anything after it: the screen would freeze. What failed is shown instead.
|
|
220
294
|
const top = topBlock([`${style.heading(map.view === "map" ? "regen" : "pulses")}${waitingNote()}`], [...(options.map !== undefined ? ["p the other view"] : []), ...backKeys()], width);
|
|
221
295
|
const lines = (error instanceof Error ? (error.stack ?? error.message) : String(error)).split("\n").slice(0, Math.max(1, rows - top.length - 1));
|
|
222
296
|
return [
|
|
297
|
+
...header,
|
|
223
298
|
...top,
|
|
224
299
|
rule(width),
|
|
225
300
|
...lines.map((line, index) => truncateToWidth(index === 0 ? style.error(`could not be drawn: ${line}`) : style.muted(line), width)),
|
|
@@ -274,8 +349,42 @@ export function createSidePanel(options) {
|
|
|
274
349
|
else if (matchesKey(data, Key.end) || data === "G")
|
|
275
350
|
tree.cursor = Math.max(0, drawnTree.rows.length - 1);
|
|
276
351
|
},
|
|
277
|
-
/**
|
|
352
|
+
/** View tabs switch on a click, and the wheel scrolls the panel wherever the keyboard is. */
|
|
278
353
|
handleMouse(event) {
|
|
354
|
+
const down = pressed;
|
|
355
|
+
if (event.type === "press" || event.type === "click")
|
|
356
|
+
pressed = undefined;
|
|
357
|
+
if (event.y === 0 && (event.type === "move" || (event.button === "left" && (event.type === "press" || event.type === "click")))) {
|
|
358
|
+
for (const { action, text, x } of controls(event.width)) {
|
|
359
|
+
if (event.x >= x && event.x < x + visibleWidth(text)) {
|
|
360
|
+
if (options.pointer)
|
|
361
|
+
options.pointer.target = `panel:${action}`;
|
|
362
|
+
if (event.type === "move")
|
|
363
|
+
return { handled: true, render: false };
|
|
364
|
+
if (event.type === "press")
|
|
365
|
+
pressed = action;
|
|
366
|
+
else if (action === down && action !== map.view) {
|
|
367
|
+
if (action === "close")
|
|
368
|
+
options.close();
|
|
369
|
+
else if (action === "map")
|
|
370
|
+
toMap();
|
|
371
|
+
else
|
|
372
|
+
toPulses();
|
|
373
|
+
}
|
|
374
|
+
return { handled: true };
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
if (event.button === "left" && (event.type === "press" || event.type === "click")) {
|
|
379
|
+
const target = hits.get(event.y)?.find(({ x, end }) => event.x >= x && event.x < end);
|
|
380
|
+
if (target) {
|
|
381
|
+
if (event.type === "press")
|
|
382
|
+
pressed = target.key;
|
|
383
|
+
else if (down === target.key)
|
|
384
|
+
target.pick();
|
|
385
|
+
return { handled: true };
|
|
386
|
+
}
|
|
387
|
+
}
|
|
279
388
|
if (event.type !== "wheel" || event.wheelDelta === undefined)
|
|
280
389
|
return undefined;
|
|
281
390
|
if (map.view === "map" && options.map !== undefined)
|
|
@@ -70,7 +70,14 @@ export declare function switchTab(pages: MarkedPage[], state: SpecMapState, by:
|
|
|
70
70
|
* The tabs, a module each in the chain's order, the one shown marked - those regenerating spin, those stuck say so - fitted to
|
|
71
71
|
* `width` around the one shown, what does not fit counted at either end.
|
|
72
72
|
*/
|
|
73
|
-
export declare function tabBar(pages: MarkedPage[], shown: MarkedPage | undefined, width: number, style: TranscriptStyle, now: number):
|
|
73
|
+
export declare function tabBar(pages: MarkedPage[], shown: MarkedPage | undefined, width: number, style: TranscriptStyle, now: number): {
|
|
74
|
+
line: string;
|
|
75
|
+
targets: {
|
|
76
|
+
x: number;
|
|
77
|
+
end: number;
|
|
78
|
+
page: MarkedPage;
|
|
79
|
+
}[];
|
|
80
|
+
};
|
|
74
81
|
/**
|
|
75
82
|
* Where an item stands, as one mark on a ladder every item climbs: planned, working, regenerated, validating, conform - and needs
|
|
76
83
|
* you, off it - named in the legend in the panel's corner. The same mark means the same thing whatever the config says
|
|
@@ -123,6 +130,7 @@ export declare function specMapRows(pages: MarkedPage[], state: SpecMapState): M
|
|
|
123
130
|
export declare function specMapLines(pages: MarkedPage[], state: SpecMapState, width: number, style: TranscriptStyle, _jobs?: Job[], now?: number): {
|
|
124
131
|
lines: string[];
|
|
125
132
|
rowStarts: number[];
|
|
133
|
+
labelHeights: number[];
|
|
126
134
|
rows: MapRow[];
|
|
127
135
|
marks: LineMark[];
|
|
128
136
|
};
|
|
@@ -67,7 +67,23 @@ export function tabBar(pages, shown, width, style, now) {
|
|
|
67
67
|
if (from > 0 && visibleWidth(lineOf(from - 1, to)) <= width)
|
|
68
68
|
(from -= 1), (widened = true);
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
const full = lineOf(from, to);
|
|
71
|
+
const end = visibleWidth(full) > width ? Math.max(0, width - 1) : width;
|
|
72
|
+
const targets = [];
|
|
73
|
+
let x = 0;
|
|
74
|
+
const target = (text, index) => {
|
|
75
|
+
const next = x + visibleWidth(text);
|
|
76
|
+
if (x < end && pages[index])
|
|
77
|
+
targets.push({ x, end: Math.min(next, end), page: pages[index] });
|
|
78
|
+
x = next + 2;
|
|
79
|
+
};
|
|
80
|
+
if (from > 0)
|
|
81
|
+
target(`‹ ${from}`, from - 1);
|
|
82
|
+
for (let i = from; i < to; i++)
|
|
83
|
+
target(tabs[i] ?? "", i);
|
|
84
|
+
if (to < tabs.length)
|
|
85
|
+
target(`${tabs.length - to} ›`, to);
|
|
86
|
+
return { line: truncateToWidth(full, width, "…"), targets };
|
|
71
87
|
}
|
|
72
88
|
/** What needs the person - a stuck page, its `!` - in the warning colour: it waits on them, nothing is broken. */
|
|
73
89
|
const needs = (style) => style.warning ?? style.error;
|
|
@@ -427,6 +443,7 @@ export function specMapLines(pages, state, width, style, _jobs = [], now = Date.
|
|
|
427
443
|
const lines = [];
|
|
428
444
|
const marks = [];
|
|
429
445
|
const rowStarts = [];
|
|
446
|
+
const labelHeights = [];
|
|
430
447
|
const add = (line, mark) => {
|
|
431
448
|
lines.push(line);
|
|
432
449
|
marks.push(mark);
|
|
@@ -455,6 +472,7 @@ export function specMapLines(pages, state, width, style, _jobs = [], now = Date.
|
|
|
455
472
|
rowStarts.push(lines.length);
|
|
456
473
|
const text = `${INDENT.repeat(row.depth + 1)}${row.label}`;
|
|
457
474
|
add(`${pointer}${here ? style.heading(text) : style.muted(text)}`);
|
|
475
|
+
labelHeights.push(0); // A heading, with nothing to open.
|
|
458
476
|
underImport = true;
|
|
459
477
|
return;
|
|
460
478
|
}
|
|
@@ -468,6 +486,7 @@ export function specMapLines(pages, state, width, style, _jobs = [], now = Date.
|
|
|
468
486
|
const items = page.items.filter((item) => item.file === row.file);
|
|
469
487
|
const text = `${row.open ? "▾" : "▸"} from ${row.file} · ${importSummary(items)}`;
|
|
470
488
|
add(`${pointer}${INDENT.repeat(row.depth + 1)}${here ? style.heading(text) : style.muted(text)}`);
|
|
489
|
+
labelHeights.push(1);
|
|
471
490
|
underImport = true;
|
|
472
491
|
return;
|
|
473
492
|
}
|
|
@@ -516,6 +535,7 @@ export function specMapLines(pages, state, width, style, _jobs = [], now = Date.
|
|
|
516
535
|
if (heading !== undefined)
|
|
517
536
|
for (const line of hanging(body, first, room))
|
|
518
537
|
add(`${CONTINUED}${line}`, mark);
|
|
538
|
+
labelHeights.push(lines.length - rowStarts[index]);
|
|
519
539
|
// The first item that needs the person says what for, and how to go about it - opened or closed.
|
|
520
540
|
if (page.stuck && !toldWhy && rungOf(item) === "needsYou") {
|
|
521
541
|
toldWhy = true;
|
|
@@ -540,7 +560,7 @@ export function specMapLines(pages, state, width, style, _jobs = [], now = Date.
|
|
|
540
560
|
add(`${CONTINUED}${style.muted(`… ${changed.length - 4} more - enter opens it`)}`, mark);
|
|
541
561
|
}
|
|
542
562
|
});
|
|
543
|
-
return { lines, rowStarts, rows, marks };
|
|
563
|
+
return { lines, rowStarts, labelHeights, rows, marks };
|
|
544
564
|
}
|
|
545
565
|
/** How the strip and the minimap colour a mark. */
|
|
546
566
|
function paintOf(mark, style) {
|
package/dist/resume-line.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* pi's lines on the way out that say how to resume the session - its label, then the command on a line of its own -
|
|
3
|
+
* left out: turri leaves nothing behind but the command run.
|
|
4
|
+
*/
|
|
2
5
|
export declare function withoutResumeLine(text: string): string;
|
package/dist/resume-line.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* pi's lines on the way out that say how to resume the session - its label, then the command on a line of its own -
|
|
3
|
+
* left out: turri leaves nothing behind but the command run.
|
|
4
|
+
*/
|
|
2
5
|
export function withoutResumeLine(text) {
|
|
3
|
-
return text.replace(/^(?:\x1b\[[0-9;]*m)*To resume this session
|
|
6
|
+
return text.replace(/^(?:\x1b\[[0-9;]*m)*To resume this session:(?:\x1b\[[0-9;]*m)*\n[^\n]*\n?/m, "");
|
|
4
7
|
}
|
package/docs/chats.md
CHANGED
|
@@ -25,22 +25,23 @@ A pulse's end goes to the [sentinel](sentinel.md) - a chat of turri's own, opene
|
|
|
25
25
|
|
|
26
26
|
| | |
|
|
27
27
|
| --- | --- |
|
|
28
|
-
| `/chat new`, `alt+n` | a fresh chat, with the session's settings and an empty history, shown at once |
|
|
29
|
-
| `/chat 2`, `alt+2` | chat 2, shown - `alt+1` … `alt+9` |
|
|
30
|
-
| `/chat close
|
|
28
|
+
| Click `+`, `/chat new`, `alt+n` | a fresh chat, with the session's settings and an empty history, shown at once |
|
|
29
|
+
| Click tab 2, `/chat 2`, `alt+2` | chat 2, shown - `alt+1` … `alt+9` |
|
|
30
|
+
| Click a tab's `×`, `/chat close 3` | close that chat; closing a background chat leaves the one shown in place |
|
|
31
|
+
| `/chat close`, `alt+w` | close the chat shown and switch to the next one |
|
|
31
32
|
| `/chat` | a list of the chats, to pick one - or a new one |
|
|
32
33
|
| `/new` | the same as `/chat new` |
|
|
33
34
|
| `/resume` | a saved chat, opened as a chat of its own beside the others - or shown, when it is open |
|
|
34
35
|
| `ctrl+c` | what the chat shown is doing, stopped - its turn, a skill or a tool in it, a `!` command, a compaction; in a chat doing nothing, a draft in the editor cleared, else turri left, every chat with it |
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
The chat tabs sit just below the banner's horizontal rule. When the banner scrolls away, the tabs stay at the top of the fullscreen terminal. A fresh session starts with one tab and a `+` button. Click `+` to open a chat, a tab's title to switch to it, or its `×` to close it. The active tab has the accent fill and a `▸` marker when there is room. Moving the pointer over a control highlights and underlines that target, including the close button independently of its tab. Each tab shows its number and title - "new chat" until the first message, unless `/name` gives it a name - and a spinner while it works, `?` while a question waits, or `•` when it said something since you last looked. In `--tui-mode regular` the tabs scroll with the terminal; use the commands or keys to switch.
|
|
37
38
|
|
|
38
39
|
A message you send while a chat's agent works is shown under the chat at once, shaded and marked `not read yet`, and stays under what the agent writes and the tools it calls until the agent reads it - at the end of its current step - when it goes into the chat as a normal message, where it was read. `alt+up` takes the messages waiting back into the editor (`src/chat-waiting.ts`). While a skill runs in the chat its own agent is the one at work, and the chat's waits for the whole run: what you type then goes to the skill's agent, shown waiting until it reads it, at the end of its current step - and is in the chat from then, where it was read. The chat's agent is told what you said to the skill when the run ends. A message the skill's agent has not read when the run ends goes to the chat's agent instead.
|
|
39
40
|
|
|
40
41
|
On macOS, `alt` is Option (⌥), and reaches turri only when the terminal sends Option as Meta - otherwise ⌥N is the dead key for ñ and ⌥1 types `¡`, and nothing reaches turri. turri says so as a session's second chat opens. To turn it on: Ghostty, `macos-option-as-alt = true` in its config; iTerm2, Profiles → Keys → Left Option key: Esc+; Terminal.app, Profiles → Keyboard → Use Option as Meta key; Kitty, `macos_option_as_alt yes`; WezTerm, `send_composed_key_when_left_alt_is_pressed = false`. `/chat` works without it.
|
|
41
42
|
|
|
42
43
|
- **A hidden chat's questions** wait until you show it, then come up one after another. What it says in passing is said as you show it; what it keeps on the screen - a skill's progress, the job panel - is put back each time; what you had typed in its editor and not sent is still there.
|
|
43
|
-
- **The side panel**
|
|
44
|
+
- **The side panel** belongs to the session and stays open when you switch chats. Click `***plain ›` at the right end of the chat tabs to open the spec beside the chat. Click `***plain` or `pulses` at the top of the panel to switch views, or `× close` at the top right to close the panel. `ctrl+h` and `p` are the keyboard controls. A terminal under 104 columns shows the panel full screen.
|
|
44
45
|
- **A long command** - `/regenerate`, planning a module from scratch - does its work in the background once it is under way: the chat, and switching to another, stay free while the planner plans.
|
|
45
46
|
- **`ctrl+c`** reaches the chat shown and nothing else: another chat's turn and skill go on, and so do the pulses - `/halt` stops one. A skill stopped keeps its run, for the model to continue with `resume`. At a question - the chat's `ask_user`, a skill's interview - `ctrl+c` declines it, and the asker is told so and goes on - each question it is pressed at, however many in a row. A skill is stopped by `ctrl+c` with no question open. A second press straight after one that stopped something does nothing, so pressing twice to be sure does not leave turri; once the chat is doing nothing, the next one does - with what every other chat is doing. A host has the same as `interrupt(id)`, and `decline(id)` for a question ([hosting](hosting.md)).
|
|
46
47
|
- **The sentinel** is a chat in the strip like the others, `sentinel`, and never shown by itself: it closes like any chat, and the next pulse that finishes opens it again. Each pulse it checks in a fresh conversation, replacing the one in its tab. With it on, you open up to eight chats - the ninth slot is its. See [the sentinel](sentinel.md).
|
package/docs/theming.md
CHANGED
|
@@ -36,7 +36,7 @@ Both themes, the command line's colours, the \*\*\*plain diff's, the banner's je
|
|
|
36
36
|
| indigo | `#5b57d9` | the jellyfish's bell, at its rim - nowhere else |
|
|
37
37
|
| orange | `#ff7a3d` | the jellyfish's gut, the `$` of bash mode, and everything that asks for you - what failed (`✗`), what works with limits, what needs you (the \*\*\*plain map's `!`): `error`, `warning` |
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
In the chat header, the `+` is the one pink button. Tabs use the theme's `selectedBg` for their padded surfaces and `accent` for the active tab. Hover underlines the target; `×` takes the warning colour on hover to distinguish closing from switching. The side panel uses the same treatment. In the transcript, pink carries what is done and orange everything that asks for you - what failed, what works with limits, what waits on you - the mark (`✗`, `!`, `■`) telling them apart. The palette has no red.
|
|
40
40
|
|
|
41
41
|
## Why there are two
|
|
42
42
|
|
package/docs/using.md
CHANGED
|
@@ -42,6 +42,10 @@ The agent does this work with these tools, never by running turri's command line
|
|
|
42
42
|
|
|
43
43
|
## Pulses
|
|
44
44
|
|
|
45
|
+
In the fullscreen TUI, click `***plain ›` at the right end of the chat tabs to open the spec map on the right. The panel has two clickable tabs: `***plain` for the spec and `pulses` for the work regenerating it. The filled tab marked `▸` is the current view. Click `× close` in the panel's upper-right corner to return to the full-width chat. Below 104 terminal columns the same controls open and close a full-screen panel.
|
|
46
|
+
|
|
47
|
+
Click a spec's heading or summary, or an imported file's name, to select it and toggle its details. A wrapped summary is clickable on any of its lines. Click a module tab to switch modules. In `pulses`, click a section, a pulse or a file in its diff to expand or collapse it. The arrow keys and Enter continue from the row you clicked.
|
|
48
|
+
|
|
45
49
|
A pulse is one unit of work regenerating the code. It was called a job, and still is where a name is kept - `job_id`, `parallel-jobs`, `allow-to-stop-jobs`, `.turri/jobs/` - and in a project's own files written before: the chat is told the two are the same, so an `AGENTS.md` or a skill that says "job" needs no change.
|
|
46
50
|
|
|
47
51
|
A regeneration takes minutes, so in the TUI every tool that regenerates starts the work as a pulse and returns straight away. The conversation carries on, and you need not wait for a pulse to finish: go on shaping the \*\*\*plain and writing its next change, ask questions, try what has landed - turri says so as each pulse starts, and never waits for one itself. A \*\*\*plain change made meanwhile steers the running pulse or is planned again around it (see below); pulses on the same module - or on modules of one `requires` chain - queue behind each other, in the order they were asked for, from the first pulse on: one queued while the module's \*\*\*plain is only a scaffold, with no functional specs yet, or while it does not parse, still holds its module, so nothing on the module runs beside it. Pulses on modules that share nothing run side by side, each with its own progress panel - two modules or ten. How many run at once is capped by what the machine has room for: past `parallel-jobs` (see [the project config](config.md#how-many-jobs-at-once)), a pulse whose turn has come waits for a free slot, and says so.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turri-dev/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3-next.620bae9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"prepack": "npm run build"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@earendil-works/pi-coding-agent": "1.
|
|
43
|
-
"@earendil-works/pi-tui": "1.
|
|
42
|
+
"@earendil-works/pi-coding-agent": "1.6.0",
|
|
43
|
+
"@earendil-works/pi-tui": "1.6.0",
|
|
44
44
|
"@langchain/langgraph": "1.4.15",
|
|
45
45
|
"gray-matter": "^4.0.3",
|
|
46
46
|
"js-yaml": "^5.4.2",
|