proper-base 0.5.0 → 0.6.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.
@@ -50,6 +50,7 @@ type NavigableEditor = Component & {
50
50
  isShowingAutocomplete?(): boolean;
51
51
  onChange?(text: string): void;
52
52
  setText?(text: string): void;
53
+ historyIndex?: number;
53
54
  state?: {
54
55
  lines: string[];
55
56
  cursorLine: number;
@@ -226,6 +227,25 @@ export function installEditorNavigation(
226
227
  }
227
228
  }
228
229
  if (previous) {
230
+ // Pi recalls history on Up from the first visual row whenever the
231
+ // cursor sits at column 0, so Home followed by Up, or Up pressed
232
+ // twice from a short first line, replaces a draft with an older
233
+ // prompt. Recall is only for an empty prompt: with a draft and no
234
+ // recall in progress, Up at that position is already at the line
235
+ // start Pi would otherwise jump to, so it does nothing. The dedicated
236
+ // history binding is left alone; it is opt-in and explicit.
237
+ if (
238
+ keybindings.matches(data, "tui.editor.cursorUp") &&
239
+ (target.historyIndex ?? -1) < 0 &&
240
+ target.getCursor?.().col === 0 &&
241
+ target.getLines?.().some((line) => line !== "")
242
+ ) {
243
+ const visualLines = target.buildVisualLineMap?.(target.lastWidth ?? 80);
244
+ const visualIndex = visualLines
245
+ ? target.findCurrentVisualLine?.(visualLines)
246
+ : undefined;
247
+ if (visualIndex === 0) return;
248
+ }
229
249
  const before = target.getLines?.().join("\n");
230
250
  handleInput(data);
231
251
  const state = target.state;
package/src/fast-mode.ts CHANGED
@@ -153,6 +153,14 @@ export class FastOverlay {
153
153
  return this.modelsCache.ids.has(model.id);
154
154
  }
155
155
 
156
+ /** Whether requests for this model currently carry the priority tier. */
157
+ isEffectiveFor(model: FastModel | undefined): boolean {
158
+ return (
159
+ (this.sessionEnabled || this.isGlobalEnabled()) &&
160
+ this.supportsModel(model)
161
+ );
162
+ }
163
+
156
164
  /**
157
165
  * The replacement payload for pi's `before_provider_request`, or
158
166
  * `undefined` to keep it. Adds `service_tier` when Fast is on for a
@@ -166,11 +174,11 @@ export class FastOverlay {
166
174
  return undefined;
167
175
  }
168
176
  const record = payload as JsonObject;
169
- const effective = this.sessionEnabled || this.isGlobalEnabled();
170
- if (effective && this.supportsModel(model)) {
177
+ if (this.isEffectiveFor(model)) {
171
178
  if (record.service_tier === PRIORITY_TIER) return undefined;
172
179
  return { ...record, service_tier: PRIORITY_TIER };
173
180
  }
181
+ const effective = this.sessionEnabled || this.isGlobalEnabled();
174
182
  if (!effective && record.service_tier === PRIORITY_TIER) {
175
183
  const { service_tier: _dropped, ...rest } = record;
176
184
  return rest;
@@ -42,6 +42,7 @@ type FooterTheme = ExtensionContext["ui"]["theme"];
42
42
  type FooterState = {
43
43
  ctx: ExtensionContext;
44
44
  tui: TUI;
45
+ fast: (() => boolean) | undefined;
45
46
  };
46
47
  type FooterController = {
47
48
  update(state: FooterState): void;
@@ -63,17 +64,18 @@ type FooterColorState = {
63
64
  export function installFooterColors(
64
65
  tui: TUI,
65
66
  ctx: ExtensionContext,
67
+ fast?: () => boolean,
66
68
  ): (() => void) | undefined {
67
69
  const footer = findFooter(tui);
68
70
  if (!footer) return undefined;
69
71
 
70
72
  const existing = footer[INSTALLED];
71
73
  if (existing) {
72
- existing.update({ ctx, tui });
74
+ existing.update({ ctx, tui, fast });
73
75
  return existing.uninstall;
74
76
  }
75
77
 
76
- let state = { ctx, tui };
78
+ let state: FooterState = { ctx, tui, fast };
77
79
  let timer: ReturnType<typeof setInterval> | undefined;
78
80
  const ownsRender = Object.hasOwn(footer, "render");
79
81
  const render = footer.render;
@@ -114,17 +116,17 @@ export function installFooterColors(
114
116
  if (level === "max" || level === "ultra") startAnimation();
115
117
  else stopAnimation();
116
118
  const theme = state.ctx.ui.theme;
117
- return colorFooter(
118
- layoutFooter(render.call(footer, width), width, theme, (wide) =>
119
- render.call(footer, wide),
120
- ),
121
- {
122
- level,
123
- model: state.ctx.model?.id,
124
- now: Date.now(),
125
- theme,
126
- },
127
- );
119
+ const model = state.ctx.model?.id;
120
+ const base = (at: number) => {
121
+ const lines = render.call(footer, at);
122
+ return model && state.fast?.() ? tagFast(lines, at, model, theme) : lines;
123
+ };
124
+ return colorFooter(layoutFooter(base(width), width, theme, base), {
125
+ level,
126
+ model,
127
+ now: Date.now(),
128
+ theme,
129
+ });
128
130
  };
129
131
  footer.dispose = () => {
130
132
  controller.uninstall();
@@ -134,6 +136,53 @@ export function installFooterColors(
134
136
  return controller.uninstall;
135
137
  }
136
138
 
139
+ // @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Fast tier scopes]]
140
+ /**
141
+ * Append the provider's `fast` chip when the session overlay makes Fast
142
+ * effective but the provider's own global flag is off. Pads are trimmed so
143
+ * the line keeps its width, matching how the provider's label would sit.
144
+ */
145
+ function tagFast(
146
+ lines: string[],
147
+ width: number,
148
+ model: string,
149
+ theme: FooterTheme,
150
+ ): string[] {
151
+ const index = lines.findIndex((line) =>
152
+ stripTerminalSequences(line).includes(model),
153
+ );
154
+ const line = lines[index];
155
+ if (line === undefined) return lines;
156
+ const plain = stripTerminalSequences(line);
157
+ if (/ • fast(?: • |$)/.test(plain)) return lines;
158
+
159
+ const tag = ` • ${theme.fg("warning", "fast")}`;
160
+ const tagWidth = 7;
161
+ const total = visibleWidth(line);
162
+ const pausedAt = plain.lastIndexOf(" • paused");
163
+ const cut = pausedAt >= 0 ? pausedAt : total;
164
+ let head = sliceByColumn(line, 0, cut, true);
165
+ const tail = sliceByColumn(line, cut, total - cut, true);
166
+ const gap = [...plain.slice(0, cut).matchAll(/ {2,}/g)].at(-1);
167
+ if (gap?.index !== undefined) {
168
+ const trim = Math.min(
169
+ gap[0].length - 2,
170
+ Math.max(0, total + tagWidth - width),
171
+ );
172
+ if (trim > 0) {
173
+ head = `${sliceByColumn(head, 0, gap.index, true)}${sliceByColumn(
174
+ head,
175
+ gap.index + trim,
176
+ cut - gap.index - trim,
177
+ true,
178
+ )}`;
179
+ }
180
+ }
181
+ const result = [...lines];
182
+ result[index] = `${head}${tag}${tail}`;
183
+ return result;
184
+ }
185
+
137
186
  function layoutFooter(
138
187
  lines: string[],
139
188
  width: number,
@@ -0,0 +1,130 @@
1
+ import {
2
+ getKeybindings,
3
+ isKeyRelease,
4
+ type TUI,
5
+ type TuiInputListener,
6
+ } from "@earendil-works/pi-tui";
7
+
8
+ const INSTALLED = Symbol.for("pi-proper-base.overlay-scroll");
9
+ // ESC prefix is matched separately: biome bans control characters in
10
+ // regexes, and string literals carry it fine.
11
+ const SGR_MOUSE_TAIL = /^\[<(\d+);(\d+);(\d+)[Mm]$/;
12
+ /** Mirrors pi-tui's private PAGE_SCROLL_OVERLAP. */
13
+ const PAGE_OVERLAP = 4;
14
+
15
+ /** Alternate-screen renderer surface, duck-typed since most of it is private. */
16
+ type ScrollHost = TUI & {
17
+ scrollBy(lines: number): void;
18
+ scrollToTop(): void;
19
+ scrollToBottom(): void;
20
+ isOverlayFocused?(): boolean;
21
+ getPrimaryScrollView?(): { viewportHeight: number };
22
+ routeWheel?(event: {
23
+ direction: number;
24
+ x: number;
25
+ y: number;
26
+ button: number;
27
+ }): void;
28
+ wheelScrollLines?: number;
29
+ [INSTALLED]?: () => void;
30
+ };
31
+
32
+ /** Same shape pi-tui's parseWheelEvent produces. */
33
+ export function parseWheel(data: string) {
34
+ if (!data.startsWith("\x1b")) return undefined;
35
+ const match = SGR_MOUSE_TAIL.exec(data.slice(1));
36
+ if (!match) return undefined;
37
+ const button = Number.parseInt(match[1] ?? "", 10);
38
+ if ((button & 64) === 0) return undefined;
39
+ const direction = button & 3;
40
+ if (direction !== 0 && direction !== 1) return undefined;
41
+ return {
42
+ direction: direction === 0 ? -1 : 1,
43
+ x: Number.parseInt(match[2] ?? "", 10) - 1,
44
+ y: Number.parseInt(match[3] ?? "", 10) - 1,
45
+ button,
46
+ };
47
+ }
48
+
49
+ /**
50
+ * Keep the fullscreen transcript scrollable while an overlay owns focus.
51
+ *
52
+ * Pi's viewport listener declines wheel events and every `tui.altScreen`
53
+ * scroll key as soon as a capturing overlay is focused, so an
54
+ * `ask_user_question` questionnaire freezes the transcript behind it. This
55
+ * listener registers after the renderer's own, so it only ever sees input the
56
+ * viewport (or an overlay's own mouse handler) already passed on, and routes
57
+ * that to the same scroll methods the renderer would have used. Keys are
58
+ * consumed so the overlay never receives a scroll chord; wheel events fall
59
+ * through untouched when no overlay is focused because the renderer already
60
+ * consumed them.
61
+ *
62
+ * Regular mode and renderer shapes without the scroll surface install
63
+ * nothing; a renamed private field only loses the wheel step or page size,
64
+ * not scrolling itself.
65
+ *
66
+ * @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Overlay transcript scrolling]]
67
+ */
68
+ export function installOverlayScroll(tui: TUI): (() => void) | undefined {
69
+ const host = tui as ScrollHost;
70
+ if (
71
+ typeof host.scrollBy !== "function" ||
72
+ typeof host.scrollToTop !== "function" ||
73
+ typeof host.scrollToBottom !== "function"
74
+ ) {
75
+ return undefined;
76
+ }
77
+ host[INSTALLED]?.();
78
+
79
+ const page = () =>
80
+ Math.max(
81
+ 1,
82
+ (host.getPrimaryScrollView?.().viewportHeight ?? 1) - PAGE_OVERLAP,
83
+ );
84
+ const half = () =>
85
+ Math.max(
86
+ 1,
87
+ Math.floor((host.getPrimaryScrollView?.().viewportHeight ?? 1) / 2),
88
+ );
89
+
90
+ const listener: TuiInputListener = (data) => {
91
+ if (host.isOverlayFocused?.() !== true) return undefined;
92
+ const wheel = parseWheel(data);
93
+ if (wheel) {
94
+ if (typeof host.routeWheel === "function") host.routeWheel(wheel);
95
+ else host.scrollBy(wheel.direction * (host.wheelScrollLines ?? 1));
96
+ return { consume: true };
97
+ }
98
+ if (!data.startsWith("\x1b")) return undefined;
99
+ const kb = getKeybindings();
100
+ const action = kb.matches(data, "tui.altScreen.pageUp")
101
+ ? () => host.scrollBy(-page())
102
+ : kb.matches(data, "tui.altScreen.pageDown")
103
+ ? () => host.scrollBy(page())
104
+ : kb.matches(data, "tui.altScreen.halfPageUp")
105
+ ? () => host.scrollBy(-half())
106
+ : kb.matches(data, "tui.altScreen.halfPageDown")
107
+ ? () => host.scrollBy(half())
108
+ : kb.matches(data, "tui.altScreen.lineUp")
109
+ ? () => host.scrollBy(-1)
110
+ : kb.matches(data, "tui.altScreen.lineDown")
111
+ ? () => host.scrollBy(1)
112
+ : kb.matches(data, "tui.altScreen.top")
113
+ ? () => host.scrollToTop()
114
+ : kb.matches(data, "tui.altScreen.bottom")
115
+ ? () => host.scrollToBottom()
116
+ : undefined;
117
+ if (!action) return undefined;
118
+ if (!isKeyRelease(data)) action();
119
+ return { consume: true };
120
+ };
121
+ const unsubscribe = tui.addInputListener(listener);
122
+
123
+ const dispose = () => {
124
+ if (host[INSTALLED] !== dispose) return;
125
+ unsubscribe();
126
+ delete host[INSTALLED];
127
+ };
128
+ host[INSTALLED] = dispose;
129
+ return dispose;
130
+ }
@@ -0,0 +1,91 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+
4
+ /**
5
+ * Codex switches GPT-6 Astra into `MultiAgentMode::Proactive` at the Ultra
6
+ * effort: a developer message telling the model to delegate whenever work
7
+ * parallelizes. Pi's subagent policy is the opposite, set by two sentences
8
+ * pi-subagents puts in the system prompt: a tool guideline and a line in
9
+ * the `<advertised_subagents>` catalog. This rewrites exactly those two
10
+ * sentences and appends the Codex paragraph; the preflight instructions
11
+ * around them and the tool description's safety guidance stay as they are.
12
+ *
13
+ * Codex's Ultra also picks each subagent's model. pi-subagents' `models`
14
+ * action lists the whole registry and the tool description says to copy
15
+ * one, so the paragraph also carries the session's scoped models (the same
16
+ * set `/model` shows) and tells the model to choose the best fit per task.
17
+ */
18
+
19
+ const GUIDELINE = "Use subagent only when delegation is needed.";
20
+ const CATALOG_SENTENCE =
21
+ "Their descriptions indicate available specializations, not instructions to delegate. Use subagent only when delegation is needed.";
22
+
23
+ const PROACTIVE_GUIDELINE =
24
+ "Delegate to subagents proactively whenever work parallelizes; see Multi-agent mode below.";
25
+ const PROACTIVE_CATALOG_SENTENCE =
26
+ "Their descriptions indicate available specializations; delegate to them proactively whenever work parallelizes.";
27
+
28
+ /**
29
+ * Codex's `PROACTIVE_MULTI_AGENT_MODE_TEXT` retargeted at pi's tool, plus
30
+ * the boundaries and legibility line OpenAI's GPT-6 Astra model guide pairs
31
+ * with it: delegate independent, sizeable work; keep sequential, small, and
32
+ * same-area edits local; own synthesis; keep inter-agent messages readable.
33
+ */
34
+ export const PROACTIVE_DELEGATION_TEXT = `# Multi-agent mode
35
+
36
+ Proactive multi-agent delegation is active. Any earlier instruction requiring an explicit user request before spawning subagents no longer applies. User requests override this mode.
37
+
38
+ If at any point you can parallelize work by delegating tasks to another agent (no matter if you are root or a subagent), you should do so with the subagent tool if it could save time or improve quality.
39
+
40
+ Delegate work that is independent and large enough to justify a fresh context; keep tightly sequential steps, small tasks where coordination costs more than it saves, and edits to the same area in this session. You own synthesis and the final answer: read every result and decide yourself, never hand a child "based on the findings, do X". Messages you send to other agents may be read by a human, so ensure they are legible and always put proper spaces between words and numbers.`;
41
+
42
+ const MODEL_CHOICE_HEADER =
43
+ "For every delegation choose the model best suited to that task's difficulty and cost, passing it as the subagent tool's exact provider/id model argument. Bounded, well-specified subtasks suit cheaper or faster models; reserve the strongest models for decomposition, review, and hard reasoning. Only these models are enabled in this session; a model the subagent models action lists that is missing here must not be used:";
44
+
45
+ /** A scoped model as the delegation text names it. */
46
+ export type ScopedModelRef = { provider: string; id: string };
47
+
48
+ /** proper-llm-router's placeholder routes the parent, never a child. */
49
+ const PLACEHOLDER_PROVIDER = "llm-router";
50
+
51
+ function modelChoiceText(models: readonly ScopedModelRef[]): string {
52
+ const ids = [
53
+ ...new Set(
54
+ models
55
+ .filter((m) => m.provider !== PLACEHOLDER_PROVIDER)
56
+ .map((m) => `${m.provider}/${m.id}`),
57
+ ),
58
+ ];
59
+ if (ids.length === 0) return "";
60
+ return `\n\n${MODEL_CHOICE_HEADER}\n${ids.map((id) => `- ${id}`).join("\n")}`;
61
+ }
62
+
63
+ /** `"proactiveDelegation": false` in the agent directory's `proper-base.json` turns it off. */
64
+ export function readProactiveDelegationEnabled(agentDir: string): boolean {
65
+ try {
66
+ const parsed = JSON.parse(
67
+ readFileSync(join(agentDir, "proper-base.json"), "utf8"),
68
+ ) as Record<string, unknown> | null;
69
+ return parsed?.proactiveDelegation !== false;
70
+ } catch {
71
+ return true;
72
+ }
73
+ }
74
+
75
+ /**
76
+ * The rewritten system prompt, or `undefined` when nothing changes: the
77
+ * subagent tool is absent, the mode is off, or the paragraph is already in.
78
+ */
79
+ export function applyProactiveDelegation(
80
+ systemPrompt: string,
81
+ hasSubagentTool: boolean,
82
+ scopedModels: readonly ScopedModelRef[] = [],
83
+ ): string | undefined {
84
+ if (!hasSubagentTool || systemPrompt.includes(PROACTIVE_DELEGATION_TEXT)) {
85
+ return undefined;
86
+ }
87
+ const rewritten = systemPrompt
88
+ .replace(CATALOG_SENTENCE, PROACTIVE_CATALOG_SENTENCE)
89
+ .replace(GUIDELINE, PROACTIVE_GUIDELINE);
90
+ return `${rewritten}\n\n${PROACTIVE_DELEGATION_TEXT}${modelChoiceText(scopedModels)}`;
91
+ }
@@ -3,8 +3,28 @@ import { join } from "node:path";
3
3
 
4
4
  import type { Component, TUI } from "@earendil-works/pi-tui";
5
5
 
6
+ // Keyed by its original name: a /reload of a build that still runs the
7
+ // rail-only module must find and hand over the wrapper it installed.
6
8
  const INSTALLED = Symbol.for("pi-proper-base.rail-setting");
7
- const ITEM_ID = "proper-base-session-rail";
9
+
10
+ /** Each toggle proper-base splices into Pi's `/settings` menu. */
11
+ const TOGGLES = [
12
+ {
13
+ id: "proper-base-session-rail",
14
+ key: "sessionRail",
15
+ label: "Session action rail",
16
+ description:
17
+ "proper-base: colored per-action jump symbols along the transcript's right edge",
18
+ },
19
+ {
20
+ id: "proper-base-editor-mouse",
21
+ key: "editorMouse",
22
+ label: "Prompt mouse clicks",
23
+ description:
24
+ "proper-base: clicking the prompt moves the cursor; off leaves the cursor where typing put it",
25
+ },
26
+ ] as const;
27
+ type ToggleKey = (typeof TOGGLES)[number]["key"];
8
28
 
9
29
  type SettingItem = {
10
30
  id: string;
@@ -26,9 +46,11 @@ type ComponentContainer = Component & {
26
46
  };
27
47
  type InstalledContainer = ComponentContainer & { [INSTALLED]?: () => void };
28
48
 
29
- export type RailSettingController = {
49
+ export type SettingsController = {
30
50
  /** Whether the session action rail is enabled. Cached per session. */
31
51
  enabled(): boolean;
52
+ /** Whether prompt clicks may move the editor cursor. Cached per session. */
53
+ editorMouse(): boolean;
32
54
  dispose(): void;
33
55
  };
34
56
 
@@ -36,20 +58,28 @@ function configPath(agentDir: string): string {
36
58
  return join(agentDir, "proper-base.json");
37
59
  }
38
60
 
39
- export function readRailEnabled(agentDir: string): boolean {
61
+ function readToggle(agentDir: string, key: ToggleKey): boolean {
40
62
  try {
41
63
  const parsed = JSON.parse(
42
64
  readFileSync(configPath(agentDir), "utf8"),
43
65
  ) as unknown;
44
- return (parsed as { sessionRail?: unknown } | null)?.sessionRail !== false;
66
+ return (parsed as Record<string, unknown> | null)?.[key] !== false;
45
67
  } catch {
46
68
  return true;
47
69
  }
48
70
  }
49
71
 
72
+ export function readRailEnabled(agentDir: string): boolean {
73
+ return readToggle(agentDir, "sessionRail");
74
+ }
75
+
76
+ export function readEditorMouseEnabled(agentDir: string): boolean {
77
+ return readToggle(agentDir, "editorMouse");
78
+ }
79
+
50
80
  /** Fail-open like the history store: a read-only agent dir only costs
51
81
  * persistence, never the session. Other keys in the file are preserved. */
52
- function writeRailEnabled(agentDir: string, enabled: boolean): void {
82
+ function writeToggle(agentDir: string, key: ToggleKey, enabled: boolean): void {
53
83
  try {
54
84
  let parsed: Record<string, unknown> = {};
55
85
  try {
@@ -62,7 +92,7 @@ function writeRailEnabled(agentDir: string, enabled: boolean): void {
62
92
  } catch {
63
93
  // Damaged or absent config starts fresh.
64
94
  }
65
- parsed.sessionRail = enabled;
95
+ parsed[key] = enabled;
66
96
  writeFileSync(
67
97
  configPath(agentDir),
68
98
  `${JSON.stringify(parsed, null, "\t")}\n`,
@@ -109,27 +139,33 @@ function findEditorContainer(
109
139
  }
110
140
 
111
141
  /**
112
- * Add a "Session action rail" toggle to Pi's native `/settings` menu.
142
+ * Add proper-base's toggles to Pi's native `/settings` menu: the session
143
+ * action rail and prompt mouse clicks.
113
144
  *
114
145
  * Pi has no extension hook into that menu, so this is a guarded
115
146
  * compatibility layer in the house style: the container Pi mounts selectors
116
147
  * into is the editor's own parent, its `addChild` is wrapped once, and every
117
- * settings selector that mounts receives one extra item spliced into its
148
+ * settings selector that mounts receives the extra items spliced into its
118
149
  * `SettingsList`, whose instance-held `onChange` is wrapped to keep the
119
- * toggle out of Pi's own switch. A renamed component or list shape installs
120
- * or injects nothing and the rail simply stays enabled.
150
+ * toggles out of Pi's own switch. A renamed component or list shape installs
151
+ * or injects nothing and both features simply stay enabled.
121
152
  *
122
- * The choice persists as `sessionRail` in the agent directory's
123
- * `proper-base.json`; other sessions pick a change up at their next start.
153
+ * Choices persist as `sessionRail` and `editorMouse` in the agent
154
+ * directory's `proper-base.json`; other sessions pick a change up at their
155
+ * next start.
124
156
  *
125
157
  * @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Session action rail]]
158
+ * @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Prompt mouse clicks]]
126
159
  */
127
- export function installRailSetting(
160
+ export function installSettings(
128
161
  tui: TUI,
129
162
  editor: Component,
130
163
  agentDir: string,
131
- ): RailSettingController {
132
- let enabled = readRailEnabled(agentDir);
164
+ ): SettingsController {
165
+ const state: Record<ToggleKey, boolean> = {
166
+ sessionRail: readToggle(agentDir, "sessionRail"),
167
+ editorMouse: readToggle(agentDir, "editorMouse"),
168
+ };
133
169
  let disposed = false;
134
170
  let uninstall: (() => void) | undefined;
135
171
 
@@ -138,20 +174,22 @@ export function installRailSetting(
138
174
  const items = list?.items;
139
175
  if (!list || !Array.isArray(items) || typeof list.onChange !== "function")
140
176
  return;
141
- if (items.some((item) => item?.id === ITEM_ID)) return;
142
- items.push({
143
- id: ITEM_ID,
144
- label: "Session action rail",
145
- description:
146
- "proper-base: colored per-action jump symbols along the transcript's right edge",
147
- currentValue: enabled ? "true" : "false",
148
- values: ["true", "false"],
149
- });
177
+ if (items.some((item) => item?.id === TOGGLES[0].id)) return;
178
+ for (const toggle of TOGGLES) {
179
+ items.push({
180
+ id: toggle.id,
181
+ label: toggle.label,
182
+ description: toggle.description,
183
+ currentValue: state[toggle.key] ? "true" : "false",
184
+ values: ["true", "false"],
185
+ });
186
+ }
150
187
  const native = list.onChange;
151
188
  list.onChange = (id, value) => {
152
- if (id === ITEM_ID) {
153
- enabled = value === "true";
154
- writeRailEnabled(agentDir, enabled);
189
+ const toggle = TOGGLES.find((entry) => entry.id === id);
190
+ if (toggle) {
191
+ state[toggle.key] = value === "true";
192
+ writeToggle(agentDir, toggle.key, state[toggle.key]);
155
193
  return;
156
194
  }
157
195
  native(id, value);
@@ -190,7 +228,8 @@ export function installRailSetting(
190
228
  queueMicrotask(wrap);
191
229
 
192
230
  return {
193
- enabled: () => enabled,
231
+ enabled: () => state.sessionRail,
232
+ editorMouse: () => state.editorMouse,
194
233
  dispose() {
195
234
  disposed = true;
196
235
  uninstall?.();