pantheon-opencode 2.0.0-beta.6 → 2.0.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.
Files changed (93) hide show
  1. package/AGENTS.global.md +7 -2
  2. package/AGENTS.md +8 -8
  3. package/CHANGELOG.md +99 -0
  4. package/README.md +171 -510
  5. package/README.pt-BR.md +179 -149
  6. package/bin/pantheon-init.mjs +14 -1
  7. package/commands/pantheon-audit.md +1 -1
  8. package/commands/pantheon-deepwork.md +7 -2
  9. package/commands/pantheon-optimize.md +41 -63
  10. package/commands/pantheon.md +10 -5
  11. package/package.json +4 -3
  12. package/plugin.json +2 -2
  13. package/prompts/optimize-database.prompt.md +5 -5
  14. package/prompts/orchestrate-with-zeus.prompt.md +82 -290
  15. package/prompts/plan-architecture.prompt.md +6 -6
  16. package/prompts/subtask.prompt.md +1 -1
  17. package/pyproject.toml +1 -1
  18. package/scripts/build-agents-md.mjs +10 -10
  19. package/scripts/build-plugin.mjs +26 -0
  20. package/scripts/doctor.mjs +27 -11
  21. package/scripts/hooks/format-multi-language.sh +30 -48
  22. package/scripts/install/opencode-version.mjs +17 -5
  23. package/scripts/install/opencode.mjs +8 -1
  24. package/scripts/jev-live-probe.mjs +1 -1
  25. package/scripts/optimize.mjs +322 -0
  26. package/scripts/prune.mjs +105 -14
  27. package/scripts/release-gates.mjs +19 -5
  28. package/scripts/skill-search.mjs +27 -3
  29. package/scripts/test-opencode-sandbox.sh +44 -15
  30. package/scripts/update.mjs +29 -17
  31. package/skills-lock.json +15 -13
  32. package/src/agents/aphrodite.md +17 -14
  33. package/src/agents/apollo.md +10 -207
  34. package/src/agents/athena.md +30 -34
  35. package/src/agents/demeter.md +2 -0
  36. package/src/agents/hephaestus.md +1 -0
  37. package/src/agents/hermes.md +21 -95
  38. package/src/agents/iris.md +3 -0
  39. package/src/agents/mnemosyne.md +1 -1
  40. package/src/agents/nyx.md +2 -1
  41. package/src/agents/prometheus.md +2 -203
  42. package/src/agents/talos.md +5 -0
  43. package/src/agents/themis.md +93 -84
  44. package/src/agents/zeus.md +44 -263
  45. package/src/instructions/agent-return-format.instructions.md +1 -1
  46. package/src/instructions/memory-protocol.instructions.md +5 -1
  47. package/src/instructions/test-economy.instructions.md +1 -0
  48. package/src/instructions/zeus-anti-stall.instructions.md +3 -3
  49. package/src/instructions/zeus-communication-rules.instructions.md +1 -1
  50. package/src/instructions/zeus-council-synthesis.instructions.md +15 -3
  51. package/src/instructions/zeus-timeout-retry.instructions.md +10 -10
  52. package/src/pantheon/model-command.ts +12 -12
  53. package/src/pantheon/pantheon-decision-catalog.ts +8 -0
  54. package/src/pantheon/skill-search-tool.ts +193 -0
  55. package/src/pantheon/tools.ts +6 -0
  56. package/src/pantheon/tui-version-check.ts +1 -1
  57. package/src/pantheon/update-notifier.ts +13 -8
  58. package/src/pantheon/vision.ts +20 -20
  59. package/src/plugin/index.js +14594 -0
  60. package/src/plugins/tui/dist/tui.d.ts +15 -5
  61. package/src/plugins/tui/dist/tui.d.ts.map +1 -1
  62. package/src/plugins/tui/dist/tui.js +1761 -556
  63. package/src/plugins/tui/dist/tui.js.map +1 -1
  64. package/src/plugins/tui/package-lock.json +2 -2
  65. package/src/plugins/tui/package.json +1 -1
  66. package/src/plugins/tui/src/autonomy-state.ts +28 -16
  67. package/src/plugins/tui/src/context-gauge.ts +64 -5
  68. package/src/plugins/tui/src/decision-router-state.ts +49 -2
  69. package/src/plugins/tui/src/index.tsx +69 -26
  70. package/src/plugins/tui/src/pantheon-settings-state.ts +99 -0
  71. package/src/plugins/tui/src/pantheon-settings.tsx +771 -125
  72. package/src/plugins/tui/src/tui-prefs.ts +266 -12
  73. package/src/plugins/tui/src/update-notice.ts +9 -6
  74. package/src/plugins/tui/src/update-status.ts +27 -8
  75. package/src/plugins/tui/src/whats-new-open.ts +4 -4
  76. package/src/plugins/tui/src/whats-new.tsx +119 -17
  77. package/src/routing.yml +9 -0
  78. package/src/skills/README.md +35 -25
  79. package/src/skills/agent-coordination/SKILL.md +6 -6
  80. package/src/skills/artifact-management/SKILL.md +43 -39
  81. package/src/skills/artifact-management/references/artifact-templates.md +103 -48
  82. package/src/skills/auto-continue/references/auto-continue-details.md +13 -13
  83. package/src/skills/code-review-checklist/SKILL.md +6 -6
  84. package/src/skills/fast-path-execution/SKILL.md +54 -0
  85. package/src/skills/incremental-implementation/SKILL.md +13 -13
  86. package/src/skills/memory-bank/references/anti-patterns.md +3 -3
  87. package/src/skills/prompt-refinery/SKILL.md +51 -65
  88. package/src/skills/spec-driven-development/SKILL.md +12 -14
  89. package/src/skills/tdd-with-agents/SKILL.md +23 -10
  90. package/src/skills/test-slicing/SKILL.md +56 -0
  91. package/src/skills/verification-planning/SKILL.md +4 -3
  92. package/src/skills/visual-review-pipeline/SKILL.md +1 -1
  93. package/src/skills/visual-review-pipeline/references/workflow-steps.md +1 -1
@@ -11,6 +11,38 @@ import { fileURLToPath } from "node:url";
11
11
  const CONTEXT_BAR_CELLS = 12;
12
12
  const CONTEXT_BAR_FILLED_CELL = "▰";
13
13
  const CONTEXT_BAR_EMPTY_CELL = "▱";
14
+ const BAR_SHAPES = {
15
+ block: {
16
+ filled: "▰",
17
+ empty: "▱",
18
+ mark: "│"
19
+ },
20
+ line: {
21
+ filled: "━",
22
+ empty: "─",
23
+ mark: "┼"
24
+ },
25
+ smooth: {
26
+ filled: "█",
27
+ empty: "░",
28
+ mark: "┆"
29
+ },
30
+ ascii: {
31
+ filled: "=",
32
+ empty: "-",
33
+ mark: "|"
34
+ },
35
+ dots: {
36
+ filled: "●",
37
+ empty: "○",
38
+ mark: "│"
39
+ },
40
+ braille: {
41
+ filled: "⣿",
42
+ empty: "⣀",
43
+ mark: "⡇"
44
+ }
45
+ };
14
46
  function numberOrNull$1(value) {
15
47
  return typeof value === "number" && Number.isFinite(value) ? value : null;
16
48
  }
@@ -38,14 +70,34 @@ function contextBarFilled(percent, cells = 12) {
38
70
  if (!Number.isFinite(filled)) return 0;
39
71
  return Math.min(total, Math.max(0, filled));
40
72
  }
41
- function contextBar(percent, cells = 12) {
73
+ function contextBar(percent, options = 12) {
42
74
  const value = numberOrNull$1(percent);
43
75
  if (value === null) return null;
44
- const total = Math.max(1, Math.floor(cells));
45
- const filled = contextBarFilled(value, total);
76
+ const total = Math.max(1, Math.floor(typeof options === "number" ? options : options?.cells ?? 12));
77
+ const shapeKey = typeof options === "object" && options?.shape && options.shape in BAR_SHAPES ? options.shape : "block";
78
+ const glyphs = BAR_SHAPES[shapeKey] ?? BAR_SHAPES.block;
79
+ const evenMark = typeof options === "object" ? Boolean(options?.evenMark) : false;
80
+ const filledCount = contextBarFilled(value, total);
81
+ const emptyCount = total - filledCount;
82
+ if (!evenMark || total < 4) return {
83
+ filled: glyphs.filled.repeat(filledCount),
84
+ empty: glyphs.empty.repeat(emptyCount)
85
+ };
86
+ const mid = Math.floor(total / 2);
87
+ const mark = glyphs.mark ?? "|";
88
+ if (filledCount <= mid) {
89
+ const emptyBefore = mid - filledCount;
90
+ const emptyAfter = Math.max(0, emptyCount - emptyBefore - 1);
91
+ return {
92
+ filled: glyphs.filled.repeat(filledCount),
93
+ empty: `${glyphs.empty.repeat(emptyBefore)}${mark}${glyphs.empty.repeat(emptyAfter)}`
94
+ };
95
+ }
96
+ const filledBefore = mid;
97
+ const filledAfter = Math.max(0, filledCount - filledBefore - 1);
46
98
  return {
47
- filled: "▰".repeat(filled),
48
- empty: "▱".repeat(total - filled)
99
+ filled: `${glyphs.filled.repeat(filledBefore)}${mark}${glyphs.filled.repeat(filledAfter)}`,
100
+ empty: glyphs.empty.repeat(emptyCount)
49
101
  };
50
102
  }
51
103
  function formatSpent(cost) {
@@ -67,6 +119,19 @@ const DEFAULT_GOAL_LOOP_PREFS = {
67
119
  maxContinuations: 25
68
120
  };
69
121
  const GOAL_LOOP_ENABLED_CYCLE = Object.freeze(["enabled", "disabled"]);
122
+ const MAX_CONTINUATIONS_CYCLE = Object.freeze([
123
+ "10",
124
+ "25",
125
+ "50",
126
+ "100",
127
+ "200"
128
+ ]);
129
+ const COOLDOWN_MS_CYCLE = Object.freeze([
130
+ "1000",
131
+ "2000",
132
+ "5000",
133
+ "10000"
134
+ ]);
70
135
  const DEFAULT_DECISION_BUDGETS = {
71
136
  monthlyUsd: 5,
72
137
  perDecisionUsd: .1
@@ -105,65 +170,67 @@ function buildAutonomyTab(input) {
105
170
  title: "Autonomy",
106
171
  groups: [
107
172
  {
108
- title: "Goal loop (persisted mission, long sessions)",
173
+ title: "Goal loop (multi-turn session auto-continuation)",
109
174
  rows: [
110
175
  {
111
176
  id: "autonomy.goal_loop.enabled",
112
177
  name: "Goal loop",
113
178
  value: input.goalLoop.enabled ? "enabled" : "disabled",
114
179
  cycle: GOAL_LOOP_ENABLED_CYCLE,
115
- note: "mission persists in .pantheon/goals; auto-continues with cooldown" + (input.goalLoopRestartPending ? " · ⚠ saved value applies after OpenCode restart" : " · applies after OpenCode restart")
180
+ note: "auto-continues multi-turn tasks when session goes idle" + (input.goalLoopRestartPending ? " · [!] restart required to apply" : " · applies after OpenCode restart")
116
181
  },
117
182
  {
118
183
  id: "autonomy.goal_loop.maxContinuations",
119
184
  name: "Max continuations",
120
185
  value: String(input.goalLoop.maxContinuations),
121
- note: "1..200 — the anti-runaway cap per mission"
186
+ cycle: MAX_CONTINUATIONS_CYCLE,
187
+ note: "1..200 — safety ceiling to prevent runaway tasks"
122
188
  },
123
189
  {
124
190
  id: "autonomy.goal_loop.cooldownMs",
125
191
  name: "Cooldown (ms)",
126
192
  value: String(input.goalLoop.cooldownMs),
127
- note: "min 1000ms · between continuations"
193
+ cycle: COOLDOWN_MS_CYCLE,
194
+ note: "delay between autonomous turns (min 1000ms)"
128
195
  }
129
196
  ]
130
197
  },
131
198
  {
132
- title: "Decision budgets (applies live)",
199
+ title: "Decision budgets (applies live per gated call)",
133
200
  rows: [{
134
201
  id: "autonomy.budget.monthly",
135
202
  name: "Monthly cap",
136
203
  value: formatUsd(input.budgets.monthlyUsd),
137
204
  cycle: MONTHLY_USD_CYCLE,
138
- note: "the ledger refuses gated calls past this"
205
+ note: "monthly USD ceiling for gated arbitrator decisions"
139
206
  }, {
140
207
  id: "autonomy.budget.perDecision",
141
208
  name: "Per-decision cap",
142
209
  value: formatUsd(input.budgets.perDecisionUsd),
143
210
  cycle: PER_DECISION_USD_CYCLE,
144
- note: "each gated call above this is refused"
211
+ note: "price cap — gated decisions above this are refused"
145
212
  }]
146
213
  },
147
214
  {
148
- title: "Decision gradient (documented — J1 owns the risk axis)",
215
+ title: "Decision gradient (reference policy · J1 owns the risk axis)",
149
216
  rows: [
150
217
  {
151
218
  id: "autonomy.gradient.solo",
152
219
  name: "Decide solo",
153
- value: "reversible + low risk",
154
- note: "edits, routine fixes, ordering ties — no gate"
220
+ value: "autonomous",
221
+ note: "reversible & low-risk edits, routine fixes (no gate)"
155
222
  },
156
223
  {
157
224
  id: "autonomy.gradient.jev",
158
225
  name: "Jev decides",
159
- value: "typed ambiguity",
160
- note: "readings, ranking, verification — budget-capped"
226
+ value: "arbitrated",
227
+ note: "typed ambiguity & candidate ranking (budget-capped)"
161
228
  },
162
229
  {
163
230
  id: "autonomy.gradient.human",
164
231
  name: "Human decides",
165
- value: "high risk (J1)",
166
- note: "enforce ladder via PANTHEON_J1_* (J1 tab)"
232
+ value: "human review",
233
+ note: "high-risk & destructive operations (J1 gate)"
167
234
  }
168
235
  ]
169
236
  }
@@ -414,7 +481,31 @@ function applyDecisionRow(config, id, value) {
414
481
  default: return config;
415
482
  }
416
483
  }
417
- function buildDecisionTab(read, env = process.env) {
484
+ /** Provider ids as they appear in the host auth store / config providers. */
485
+ const PROVIDER_AUTH_NAMES = Object.freeze({
486
+ "openai-decisions": Object.freeze(["openai"]),
487
+ "typesafe-jev": Object.freeze(["typesafe-ai"]),
488
+ "opencode-console-jev": Object.freeze([]),
489
+ "openrouter-jev": Object.freeze(["openrouter"]),
490
+ "vercel-gateway-jev": Object.freeze(["vercel-ai-gateway", "vercel"]),
491
+ "cloudflare-workers-jev": Object.freeze(["cloudflare-workers-ai"])
492
+ });
493
+ /**
494
+ * TWO recognition forms (field feedback beta.6: keys registered via
495
+ * `opencode auth login` showed MISSING because only env vars were checked):
496
+ * env var set → 'env'; provider present in the host auth store → 'auth
497
+ * store'; provider entry in opencode.json providers → 'config'. Values are
498
+ * NEVER read — existence only.
499
+ */
500
+ function credentialStatus(provider, env, authProviders, configProviders) {
501
+ const credential = DECISION_PROVIDER_CREDENTIALS[provider];
502
+ if (credential?.env !== void 0 && env[credential.env]) return "env";
503
+ for (const name of PROVIDER_AUTH_NAMES[provider] ?? []) if (authProviders.has(name)) return "auth store";
504
+ for (const name of PROVIDER_AUTH_NAMES[provider] ?? []) if (configProviders.has(name)) return "config";
505
+ if (provider === "opencode-console-jev") return "auth store";
506
+ return "missing";
507
+ }
508
+ function buildDecisionTab(read, env = process.env, authProviders = /* @__PURE__ */ new Set(), configProviders = /* @__PURE__ */ new Set()) {
418
509
  const { config, corrupt } = read;
419
510
  const rows = [{
420
511
  id: "decision.enabled",
@@ -458,12 +549,12 @@ function buildDecisionTab(read, env = process.env) {
458
549
  }, {
459
550
  title: "Credentials (status only — values never enter the window)",
460
551
  rows: DECISION_KNOWN_PROVIDERS.map((provider) => {
552
+ const status = credentialStatus(provider, env, authProviders, configProviders);
461
553
  const credential = DECISION_PROVIDER_CREDENTIALS[provider] ?? { note: "" };
462
- const isSet = credential.env === void 0 ? true : Boolean(env[credential.env]);
463
554
  return {
464
555
  id: `decision.key.${provider}`,
465
556
  name: provider,
466
- value: credential.env === void 0 ? "n/a" : isSet ? "set" : "MISSING",
557
+ value: status === "missing" ? "MISSING" : status,
467
558
  note: credential.note
468
559
  };
469
560
  })
@@ -581,6 +672,9 @@ const EMPTY_TAB = {
581
672
  function tabRows(tab) {
582
673
  return tab.groups.flatMap((group) => group.rows);
583
674
  }
675
+ function findRow(tab, id) {
676
+ return tabRows(tab).find((row) => row.id === id);
677
+ }
584
678
  /** Step through the cycle with wrap-around; non-cyclable rows return the input. */
585
679
  function cycleValue(value, cycle, direction) {
586
680
  if (cycle.length === 0) return value;
@@ -602,6 +696,45 @@ function stageValue(draft, row, direction) {
602
696
  [row.id]: staged
603
697
  };
604
698
  }
699
+ /** Stage an explicit target value for one row (the Defaults action path). */
700
+ function stageRowToValue(draft, row, target) {
701
+ if (!row.cycle?.includes(target)) return draft;
702
+ if (target === row.value) {
703
+ if (draft[row.id] === void 0) return draft;
704
+ const next = { ...draft };
705
+ delete next[row.id];
706
+ return next;
707
+ }
708
+ return {
709
+ ...draft,
710
+ [row.id]: target
711
+ };
712
+ }
713
+ /**
714
+ * Stage every cyclable row's DEFAULT value of a tab. Rows already at their
715
+ * default have their staged entry dropped; rows staged elsewhere keep it
716
+ * until the Defaults action targets them.
717
+ */
718
+ function stageDefaults(draft, tab) {
719
+ let next = draft;
720
+ for (const row of tabRows(tab)) {
721
+ if (row.cycle === void 0 || row.def === void 0) continue;
722
+ const candidate = next[row.id] ?? row.value;
723
+ if (candidate === row.def) {
724
+ if (next[row.id] !== void 0) {
725
+ const copy = { ...next };
726
+ delete copy[row.id];
727
+ next = copy;
728
+ }
729
+ continue;
730
+ }
731
+ next = stageRowToValue(next, {
732
+ ...row,
733
+ value: candidate
734
+ }, row.def);
735
+ }
736
+ return next;
737
+ }
605
738
  /** Drop every staged entry of one tab (ctrl+r). */
606
739
  function resetTab(draft, tab) {
607
740
  const ids = new Set(tabRows(tab).map((row) => row.id));
@@ -686,19 +819,59 @@ function buildAboutTab(version) {
686
819
  }] }]
687
820
  };
688
821
  }
689
- /** Semver-ish compare for X.Y.Z[-beta.N]; betas sort before their release. */
822
+ function buildChangelogTab(version, items = []) {
823
+ const rows = [];
824
+ if (items.length > 0) items.forEach((item, index) => {
825
+ rows.push({
826
+ id: `changelog.item.${index + 1}`,
827
+ name: item.title.slice(0, 26),
828
+ value: item.detail.length > 20 ? `${item.detail.slice(0, 19)}…` : item.detail,
829
+ note: item.detail
830
+ });
831
+ });
832
+ else rows.push({
833
+ id: "changelog.info",
834
+ name: "Release",
835
+ value: `v${version}`,
836
+ note: "view full history in CHANGELOG.md or GitHub releases"
837
+ });
838
+ return {
839
+ id: "changelog",
840
+ title: "Changelog",
841
+ groups: [{
842
+ title: `What's New in v${version}`,
843
+ rows
844
+ }, {
845
+ title: "Release References",
846
+ rows: [{
847
+ id: "changelog.docs",
848
+ name: "Documentation",
849
+ value: "CHANGELOG.md",
850
+ note: "shipped at plugin root and repository root"
851
+ }, {
852
+ id: "changelog.repo",
853
+ name: "GitHub Repository",
854
+ value: "ils15/pantheon-opencode",
855
+ note: "releases, pull requests and discussion"
856
+ }]
857
+ }]
858
+ };
859
+ }
860
+ /** Semver-ish compare for X.Y.Z[-(beta|rc).N]; prereleases sort before their release. */
690
861
  function comparePantheonVersions(left, right) {
691
862
  const parse = (version) => {
692
- const match = String(version).trim().match(/^(\d+)\.(\d+)\.(\d+)(?:-beta\.(\d+))?$/);
863
+ const match = String(version).trim().match(/^(\d+)\.(\d+)\.(\d+)(?:-(beta|rc)\.(\d+))?$/);
693
864
  if (!match) return null;
694
- const [, major = "", minor = "", patch = "", beta = ""] = match;
865
+ const [, major = "", minor = "", patch = "", stage = "", stageNum = ""] = match;
866
+ const stageRank = stage === "beta" ? 1 : stage === "rc" ? 2 : 3;
695
867
  return {
696
868
  core: [
697
869
  +major,
698
870
  +minor,
699
871
  +patch
700
872
  ],
701
- beta: beta === "" ? Number.POSITIVE_INFINITY : +beta
873
+ stageRank,
874
+ stageNum: stage !== "" ? +stageNum : Number.POSITIVE_INFINITY
702
875
  };
703
876
  };
704
877
  const a = parse(left);
@@ -709,14 +882,15 @@ function comparePantheonVersions(left, right) {
709
882
  if (aMajor !== bMajor) return aMajor - bMajor;
710
883
  if (aMinor !== bMinor) return aMinor - bMinor;
711
884
  if (aPatch !== bPatch) return aPatch - bPatch;
712
- return a.beta - b.beta;
885
+ if (a.stageRank !== b.stageRank) return a.stageRank - b.stageRank;
886
+ return a.stageNum - b.stageNum;
713
887
  }
714
888
  function pickUpdateNotice(input) {
715
889
  const { currentVersion, latestVersion, state = {}, nowMs = Date.now() } = input;
716
890
  const ttlMs = input.ttlMs ?? 216e5;
717
891
  if (nowMs - (state.lastCheckMs ?? 0) < ttlMs) return null;
718
892
  if (state.lastNotifiedVersion === latestVersion) return null;
719
- const stable = (version) => !/-beta\.\d+$/.test(version);
893
+ const stable = (version) => !/-(?:beta|rc)\.\d+$/.test(version);
720
894
  if (stable(currentVersion) && !stable(latestVersion)) return null;
721
895
  if (comparePantheonVersions(latestVersion, currentVersion) <= 0) return null;
722
896
  return {
@@ -1040,21 +1214,85 @@ function buildPresetTab(input) {
1040
1214
  //#endregion
1041
1215
  //#region src/tui-prefs.ts
1042
1216
  const PREFS_SYMBOL = Symbol.for("pantheon.tui.prefs.v1");
1217
+ const DRAFT_PREVIEW_SYMBOL = Symbol.for("pantheon.tui.draft_preview.v1");
1043
1218
  function stash() {
1044
1219
  return globalThis[PREFS_SYMBOL];
1045
1220
  }
1221
+ function getDraftPreviewSignal() {
1222
+ const g = globalThis;
1223
+ if (!g[DRAFT_PREVIEW_SYMBOL]) g[DRAFT_PREVIEW_SYMBOL] = createSignal(void 0);
1224
+ return g[DRAFT_PREVIEW_SYMBOL];
1225
+ }
1226
+ /** Set the active draft preview overlay (used by settings window to provide live preview). */
1227
+ function setTuiDraftPreview(draft) {
1228
+ const [, setDraft] = getDraftPreviewSignal();
1229
+ setDraft(draft && Object.keys(draft).length > 0 ? { ...draft } : void 0);
1230
+ }
1231
+ /** Clear the active draft preview overlay. */
1232
+ function clearTuiDraftPreview() {
1233
+ const [, setDraft] = getDraftPreviewSignal();
1234
+ setDraft(void 0);
1235
+ }
1236
+ /** The active draft preview accessor. */
1237
+ function tuiDraftPreview() {
1238
+ const [draft] = getDraftPreviewSignal();
1239
+ return draft();
1240
+ }
1046
1241
  /** Create (or reuse) the durable prefs store. Fail-open: without host
1047
1242
  * storage the consumers fall back to DEFAULT_TUI_PREFS (read-only). */
1048
1243
  function initTuiPrefs(context) {
1049
1244
  if (stash() !== void 0) return;
1050
1245
  try {
1051
1246
  const handle = context.storage?.store?.("tui-prefs", { initial: DEFAULT_TUI_PREFS });
1052
- if (handle !== void 0) globalThis[PREFS_SYMBOL] = handle;
1247
+ if (handle !== void 0) {
1248
+ globalThis[PREFS_SYMBOL] = handle;
1249
+ if (!handle[0]?.layout) handle[1]((draft) => {
1250
+ if (!draft.layout) draft.layout = { ...DEFAULT_TUI_PREFS.layout };
1251
+ }).catch(() => {});
1252
+ }
1053
1253
  } catch {}
1054
1254
  }
1055
- /** The live reactive prefs (read properties inside memos/JSX — tracked). */
1255
+ /** Deep clone and overlay staged settings draft onto base TuiPrefs. */
1256
+ function previewTuiPrefs(base, draft) {
1257
+ if (!draft || Object.keys(draft).length === 0) return base;
1258
+ let hasTui = false;
1259
+ for (const k of Object.keys(draft)) if (k.startsWith("tui.")) {
1260
+ hasTui = true;
1261
+ break;
1262
+ }
1263
+ if (!hasTui) return base;
1264
+ const normalized = normalizeTuiPrefs(base);
1265
+ const effective = {
1266
+ version: 1,
1267
+ layout: { ...normalized.layout },
1268
+ sidebar: {
1269
+ header: { ...normalized.sidebar.header },
1270
+ blocks: { ...normalized.sidebar.blocks },
1271
+ context: { ...normalized.sidebar.context }
1272
+ },
1273
+ footer: { ...normalized.footer }
1274
+ };
1275
+ for (const [id, value] of Object.entries(draft)) if (id.startsWith("tui.")) applyTuiRow(effective, id, value);
1276
+ return effective;
1277
+ }
1278
+ /** The raw persisted prefs from host storage (no draft overlay). */
1279
+ function savedTuiPrefs() {
1280
+ const s = stash()?.[0];
1281
+ if (!s) return DEFAULT_TUI_PREFS;
1282
+ if (!s.layout) return {
1283
+ ...s,
1284
+ layout: DEFAULT_TUI_PREFS.layout
1285
+ };
1286
+ return s;
1287
+ }
1288
+ /** The live reactive prefs (read properties inside memos/JSX — tracked).
1289
+ * When a settings window has an active draft, preview overlays on top
1290
+ * of durable storage in real time. */
1056
1291
  function tuiPrefs() {
1057
- return stash()?.[0] ?? DEFAULT_TUI_PREFS;
1292
+ const base = savedTuiPrefs();
1293
+ const preview = tuiDraftPreview();
1294
+ if (!preview) return base;
1295
+ return previewTuiPrefs(base, preview);
1058
1296
  }
1059
1297
  /** Stage a mutation against the durable store; resolves when persisted. */
1060
1298
  function mutateTuiPrefs(mutation) {
@@ -1069,8 +1307,39 @@ const GAUGE_STYLES = Object.freeze([
1069
1307
  "off"
1070
1308
  ]);
1071
1309
  const ENABLED_CYCLE = Object.freeze(["enabled", "disabled"]);
1310
+ const BAR_SHAPES_CYCLE = Object.freeze([
1311
+ "line",
1312
+ "block",
1313
+ "smooth",
1314
+ "ascii",
1315
+ "dots",
1316
+ "braille"
1317
+ ]);
1318
+ const BAR_WIDTHS_CYCLE = Object.freeze([
1319
+ "standard",
1320
+ "compact",
1321
+ "wide",
1322
+ "full"
1323
+ ]);
1324
+ const LAYOUT_PRESETS_CYCLE = Object.freeze(["comfortable", "compact"]);
1325
+ const SEPARATOR_STYLES_CYCLE = Object.freeze([
1326
+ "spaces",
1327
+ "pipes",
1328
+ "dots",
1329
+ "slashes"
1330
+ ]);
1331
+ const SETTINGS_VIEW_MODES = Object.freeze([
1332
+ "docked",
1333
+ "fullscreen",
1334
+ "dialog"
1335
+ ]);
1072
1336
  const DEFAULT_TUI_PREFS = {
1073
1337
  version: 1,
1338
+ layout: {
1339
+ preset: "comfortable",
1340
+ separator: "spaces",
1341
+ settingsView: "fullscreen"
1342
+ },
1074
1343
  sidebar: {
1075
1344
  header: {
1076
1345
  version: true,
@@ -1085,6 +1354,9 @@ const DEFAULT_TUI_PREFS = {
1085
1354
  },
1086
1355
  context: {
1087
1356
  gauge: "both",
1357
+ barShape: "line",
1358
+ barWidth: "standard",
1359
+ evenMark: false,
1088
1360
  tokens: true,
1089
1361
  spent: true,
1090
1362
  modelUsage: true,
@@ -1097,6 +1369,62 @@ const DEFAULT_TUI_PREFS = {
1097
1369
  home: true
1098
1370
  }
1099
1371
  };
1372
+ function asBool(value, fallback) {
1373
+ return typeof value === "boolean" ? value : fallback;
1374
+ }
1375
+ /** Deep-merge stored JSON over the defaults; unknown keys and junk are ignored. */
1376
+ function normalizeTuiPrefs(raw) {
1377
+ const stored = typeof raw === "object" && raw !== null ? raw : {};
1378
+ const layout = typeof stored.layout === "object" && stored.layout !== null ? stored.layout : {};
1379
+ const sidebar = typeof stored.sidebar === "object" && stored.sidebar !== null ? stored.sidebar : {};
1380
+ const header = typeof sidebar.header === "object" && sidebar.header !== null ? sidebar.header : {};
1381
+ const blocks = typeof sidebar.blocks === "object" && sidebar.blocks !== null ? sidebar.blocks : {};
1382
+ const context = typeof sidebar.context === "object" && sidebar.context !== null ? sidebar.context : {};
1383
+ const footer = typeof stored.footer === "object" && stored.footer !== null ? stored.footer : {};
1384
+ const preset = LAYOUT_PRESETS_CYCLE.includes(layout.preset) ? layout.preset : DEFAULT_TUI_PREFS.layout.preset;
1385
+ const separator = SEPARATOR_STYLES_CYCLE.includes(layout.separator) ? layout.separator : DEFAULT_TUI_PREFS.layout.separator;
1386
+ const settingsView = SETTINGS_VIEW_MODES.includes(layout.settingsView) ? layout.settingsView : DEFAULT_TUI_PREFS.layout.settingsView;
1387
+ const gauge = GAUGE_STYLES.includes(context.gauge) ? context.gauge : DEFAULT_TUI_PREFS.sidebar.context.gauge;
1388
+ const barShape = BAR_SHAPES_CYCLE.includes(context.barShape) ? context.barShape : DEFAULT_TUI_PREFS.sidebar.context.barShape;
1389
+ const barWidth = BAR_WIDTHS_CYCLE.includes(context.barWidth) ? context.barWidth : DEFAULT_TUI_PREFS.sidebar.context.barWidth;
1390
+ const evenMark = asBool(context.evenMark, DEFAULT_TUI_PREFS.sidebar.context.evenMark);
1391
+ return {
1392
+ version: 1,
1393
+ layout: {
1394
+ preset,
1395
+ separator,
1396
+ settingsView
1397
+ },
1398
+ sidebar: {
1399
+ header: {
1400
+ version: asBool(header.version, true),
1401
+ preset: asBool(header.preset, true),
1402
+ session: asBool(header.session, true)
1403
+ },
1404
+ blocks: {
1405
+ context: asBool(blocks.context, true),
1406
+ git: asBool(blocks.git, true),
1407
+ todo: asBool(blocks.todo, true),
1408
+ dispatch: asBool(blocks.dispatch, true)
1409
+ },
1410
+ context: {
1411
+ gauge,
1412
+ barShape,
1413
+ barWidth,
1414
+ evenMark,
1415
+ tokens: asBool(context.tokens, true),
1416
+ spent: asBool(context.spent, true),
1417
+ modelUsage: asBool(context.modelUsage, true),
1418
+ performance: asBool(context.performance, true),
1419
+ localSpend: asBool(context.localSpend, true)
1420
+ }
1421
+ },
1422
+ footer: {
1423
+ prompt: asBool(footer.prompt, true),
1424
+ home: asBool(footer.home, true)
1425
+ }
1426
+ };
1427
+ }
1100
1428
  const onOff = ENABLED_CYCLE;
1101
1429
  const row = (id, name, value, note) => ({
1102
1430
  id,
@@ -1110,6 +1438,59 @@ function buildTuiTab(prefs) {
1110
1438
  id: "tui",
1111
1439
  title: "TUI",
1112
1440
  groups: [
1441
+ {
1442
+ title: "Preset & Layout",
1443
+ rows: [
1444
+ {
1445
+ id: "tui.layout.preset",
1446
+ name: "Layout preset",
1447
+ value: prefs.layout?.preset ?? DEFAULT_TUI_PREFS.layout.preset,
1448
+ cycle: LAYOUT_PRESETS_CYCLE,
1449
+ note: "comfortable | compact — sets spacing & borders"
1450
+ },
1451
+ {
1452
+ id: "tui.layout.separator",
1453
+ name: "Separator",
1454
+ value: prefs.layout?.separator ?? DEFAULT_TUI_PREFS.layout.separator,
1455
+ cycle: SEPARATOR_STYLES_CYCLE,
1456
+ note: "spaces | pipes | dots | slashes — status line glyphs"
1457
+ },
1458
+ {
1459
+ id: "tui.layout.settingsView",
1460
+ name: "Settings surface",
1461
+ value: tuiRowValue(prefs, "tui.layout.settingsView") ?? "docked",
1462
+ cycle: SETTINGS_VIEW_MODES,
1463
+ note: "docked (above prompt) | fullscreen router page | dialog overlay"
1464
+ }
1465
+ ]
1466
+ },
1467
+ {
1468
+ title: "Bars & Gauges",
1469
+ rows: [
1470
+ {
1471
+ id: "tui.sidebar.context.barShape",
1472
+ name: "Bar shape",
1473
+ value: prefs.sidebar.context.barShape,
1474
+ cycle: BAR_SHAPES_CYCLE,
1475
+ note: "line (━─) | block (▰▱) | smooth (█░) | ascii (=) | dots (●○) | braille"
1476
+ },
1477
+ {
1478
+ id: "tui.sidebar.context.barWidth",
1479
+ name: "Bar width",
1480
+ value: prefs.sidebar.context.barWidth,
1481
+ cycle: BAR_WIDTHS_CYCLE,
1482
+ note: "standard (12) | compact (8) | wide (16) | full (20 cells)"
1483
+ },
1484
+ row("tui.sidebar.context.evenMark", "Even-use mark", prefs.sidebar.context.evenMark, "| indicator at 50% midpoint in gauge bars"),
1485
+ {
1486
+ id: "tui.sidebar.context.gauge",
1487
+ name: "Gauge style",
1488
+ value: prefs.sidebar.context.gauge,
1489
+ cycle: GAUGE_STYLES,
1490
+ note: "both | bar | percent | off — `▰▱ 42% of 200k`"
1491
+ }
1492
+ ]
1493
+ },
1113
1494
  {
1114
1495
  title: "Sidebar header",
1115
1496
  rows: [
@@ -1130,15 +1511,8 @@ function buildTuiTab(prefs) {
1130
1511
  {
1131
1512
  title: "Context block detail",
1132
1513
  rows: [
1133
- {
1134
- id: "tui.sidebar.context.gauge",
1135
- name: "Gauge style",
1136
- value: prefs.sidebar.context.gauge,
1137
- cycle: GAUGE_STYLES,
1138
- note: "both | bar | percent | off — `▰▱ 42% of 200k`"
1139
- },
1140
1514
  row("tui.sidebar.context.tokens", "Tokens row", prefs.sidebar.context.tokens, "the raw token count line"),
1141
- row("tui.sidebar.context.spent", "Spent row", prefs.sidebar.context.spent, "the `$… gasto na sessão` line"),
1515
+ row("tui.sidebar.context.spent", "Spent row", prefs.sidebar.context.spent, "the `$… spent in session` line"),
1142
1516
  row("tui.sidebar.context.modelUsage", "Model usage table", prefs.sidebar.context.modelUsage, "per-model tokens/USD"),
1143
1517
  row("tui.sidebar.context.performance", "Performance line", prefs.sidebar.context.performance, "cache % + tok/s"),
1144
1518
  row("tui.sidebar.context.localSpend", "Local spend", prefs.sidebar.context.localSpend, "hoje / 30d totals")
@@ -1158,6 +1532,33 @@ function buildTuiTab(prefs) {
1158
1532
  function applyTuiRow(draft, id, value) {
1159
1533
  const enabled = value === "enabled";
1160
1534
  switch (id) {
1535
+ case "tui.layout.preset":
1536
+ if (LAYOUT_PRESETS_CYCLE.includes(value)) {
1537
+ if (!draft.layout) draft.layout = { ...DEFAULT_TUI_PREFS.layout };
1538
+ draft.layout.preset = value;
1539
+ }
1540
+ return;
1541
+ case "tui.layout.separator":
1542
+ if (SEPARATOR_STYLES_CYCLE.includes(value)) {
1543
+ if (!draft.layout) draft.layout = { ...DEFAULT_TUI_PREFS.layout };
1544
+ draft.layout.separator = value;
1545
+ }
1546
+ return;
1547
+ case "tui.layout.settingsView":
1548
+ if (SETTINGS_VIEW_MODES.includes(value)) {
1549
+ if (!draft.layout) draft.layout = { ...DEFAULT_TUI_PREFS.layout };
1550
+ draft.layout.settingsView = value;
1551
+ }
1552
+ return;
1553
+ case "tui.sidebar.context.barShape":
1554
+ if (BAR_SHAPES_CYCLE.includes(value)) draft.sidebar.context.barShape = value;
1555
+ return;
1556
+ case "tui.sidebar.context.barWidth":
1557
+ if (BAR_WIDTHS_CYCLE.includes(value)) draft.sidebar.context.barWidth = value;
1558
+ return;
1559
+ case "tui.sidebar.context.evenMark":
1560
+ draft.sidebar.context.evenMark = enabled;
1561
+ return;
1161
1562
  case "tui.sidebar.header.version":
1162
1563
  draft.sidebar.header.version = enabled;
1163
1564
  return;
@@ -1206,6 +1607,36 @@ function applyTuiRow(draft, id, value) {
1206
1607
  default: return;
1207
1608
  }
1208
1609
  }
1610
+ /** Read the current pref value for a row id ('enabled'/'disabled'/gauge/custom). */
1611
+ function tuiRowValue(prefs, id) {
1612
+ if (id === "tui.layout.preset") return prefs.layout?.preset ?? DEFAULT_TUI_PREFS.layout.preset;
1613
+ if (id === "tui.layout.separator") return prefs.layout?.separator ?? DEFAULT_TUI_PREFS.layout.separator;
1614
+ if (id === "tui.layout.settingsView") return prefs.layout?.settingsView ?? DEFAULT_TUI_PREFS.layout.settingsView ?? "docked";
1615
+ if (id === "tui.sidebar.context.barShape") return prefs.sidebar.context.barShape;
1616
+ if (id === "tui.sidebar.context.barWidth") return prefs.sidebar.context.barWidth;
1617
+ if (id === "tui.sidebar.context.gauge") return prefs.sidebar.context.gauge;
1618
+ if (id === "tui.sidebar.context.evenMark") return prefs.sidebar.context.evenMark ? "enabled" : "disabled";
1619
+ const enabled = (() => {
1620
+ switch (id) {
1621
+ case "tui.sidebar.header.version": return prefs.sidebar.header.version;
1622
+ case "tui.sidebar.header.preset": return prefs.sidebar.header.preset;
1623
+ case "tui.sidebar.header.session": return prefs.sidebar.header.session;
1624
+ case "tui.sidebar.block.context": return prefs.sidebar.blocks.context;
1625
+ case "tui.sidebar.block.git": return prefs.sidebar.blocks.git;
1626
+ case "tui.sidebar.block.todo": return prefs.sidebar.blocks.todo;
1627
+ case "tui.sidebar.block.dispatch": return prefs.sidebar.blocks.dispatch;
1628
+ case "tui.sidebar.context.tokens": return prefs.sidebar.context.tokens;
1629
+ case "tui.sidebar.context.spent": return prefs.sidebar.context.spent;
1630
+ case "tui.sidebar.context.modelUsage": return prefs.sidebar.context.modelUsage;
1631
+ case "tui.sidebar.context.performance": return prefs.sidebar.context.performance;
1632
+ case "tui.sidebar.context.localSpend": return prefs.sidebar.context.localSpend;
1633
+ case "tui.footer.prompt": return prefs.footer.prompt;
1634
+ case "tui.footer.home": return prefs.footer.home;
1635
+ default: return;
1636
+ }
1637
+ })();
1638
+ return enabled === void 0 ? void 0 : enabled ? "enabled" : "disabled";
1639
+ }
1209
1640
  //#endregion
1210
1641
  //#region src/update-status.ts
1211
1642
  /** The running version's channel: a `-beta.N` suffix rides the beta dist-tag. */
@@ -1227,13 +1658,16 @@ function formatAgo(ms) {
1227
1658
  }
1228
1659
  function buildUpdatesTab(input) {
1229
1660
  const nowMs = input.nowMs ?? Date.now();
1230
- const channel = updateChannelFor(input.currentVersion);
1661
+ const channel = input.selectedChannel ?? updateChannelFor(input.currentVersion);
1231
1662
  const lastCheckMs = input.state.lastCheckMs;
1232
1663
  const latest = input.lastCheckedVersion ?? input.state.lastNotifiedVersion;
1664
+ const stable = (version) => !/-beta\.\d+$/.test(version);
1665
+ const newer = latest !== void 0 && comparePantheonVersions(latest, input.currentVersion) > 0 && !(stable(input.currentVersion) && !stable(latest));
1233
1666
  const rows = [{
1234
1667
  id: "update.channel",
1235
1668
  name: "Channel",
1236
1669
  value: channel,
1670
+ cycle: ["stable", "beta"],
1237
1671
  note: "stable tracks npm `latest`; beta tracks npm `beta`"
1238
1672
  }, {
1239
1673
  id: "update.check",
@@ -1243,120 +1677,339 @@ function buildUpdatesTab(input) {
1243
1677
  note: "enter probes the registry for the running channel"
1244
1678
  }];
1245
1679
  if (latest) {
1246
- const stable = (version) => !/-beta\.\d+$/.test(version);
1247
- const newer = comparePantheonVersions(latest, input.currentVersion) > 0 && !(stable(input.currentVersion) && !stable(latest));
1248
1680
  rows.push({
1249
1681
  id: "update.latest",
1250
1682
  name: "Registry",
1251
1683
  value: newer ? `v${latest} available` : "up to date",
1252
1684
  note: newer ? "adopt with `pantheon-opencode update`" : "no newer compatible version"
1253
1685
  });
1686
+ rows.push({
1687
+ id: "update.run",
1688
+ name: "Update now",
1689
+ value: input.updating ? "updating…" : newer ? `install v${latest}` : "reinstall / refresh",
1690
+ action: "update-run",
1691
+ note: newer ? "enter runs `pantheon-opencode update`" : "enter refreshes installed copy"
1692
+ });
1254
1693
  }
1694
+ rows.push({
1695
+ id: "update.command",
1696
+ name: "CLI command",
1697
+ value: channel === "beta" ? "pantheon-opencode update" : "pantheon-opencode update --stable",
1698
+ note: "run in terminal or OpenCode Desktop terminal"
1699
+ });
1255
1700
  return {
1256
1701
  id: "updates",
1257
1702
  title: "Updates",
1258
1703
  groups: [{
1259
- title: "Updates",
1704
+ title: "Updates & Maintenance",
1260
1705
  rows
1261
1706
  }]
1262
1707
  };
1263
1708
  }
1264
- //#endregion
1265
- //#region src/pantheon-settings.tsx
1266
- /** @jsxImportSource @opentui/solid */
1267
- /**
1268
- * pantheon-settings.tsx — the /pantheon-settings window (2.0.0-beta.4).
1269
- *
1270
- * A FULL-SCREEN settings window in the OpenCode Quota shape: a tab header,
1271
- * grouped setting rows with ←/→ value cyclers, a note column, and a
1272
- * save/reset footer. The surface is a ROUTER PAGE (`ui.router.register` +
1273
- * `navigate({type:'plugin'})`) — true full-screen, reachable from the home
1274
- * route AND sessions, no focus dance (binary-verified precedent: the host's
1275
- * own opencode.diffs plugin). Hosts without a router fall back to the old
1276
- * dialog with the same commands (fail-open).
1277
- *
1278
- * Edits stage into a DRAFT: ←/→ cycles a row's value, `ctrl+s` saves every
1279
- * staged row through the per-surface guards, `ctrl+r` resets the current
1280
- * tab, `esc`/`q` confirms before discarding. The disk never changes before
1281
- * save, and every refusal surfaces in the notice line — never silent.
1282
- *
1283
- * The keymap layer is registered ONCE at setup with `priority: 1` (the host
1284
- * resolves bind conflicts by priority then registration order — a stale
1285
- * dispatch-panel layer must never win while this window is open; field
1286
- * report beta.2: navigation "stopped working" was exactly that theft).
1287
- */
1288
- const ROUTE_NAME = "pantheon-settings";
1289
- /** The input mode the page pushes while mounted (composer layers sleep). */
1290
- const ROUTE_MODE = "pantheon-settings";
1291
- /** Loose local shape of a host route (the real Route lives in the host typings). */
1709
+ /** Prefix of the "+N more" line appended when the bullet budget is exceeded. */
1710
+ const WHATS_NEW_MORE_PREFIX = "… +";
1711
+ const EMPTY_HIGHLIGHTS = {
1712
+ version: null,
1713
+ found: false,
1714
+ groups: [],
1715
+ totalItems: 0,
1716
+ truncated: false
1717
+ };
1718
+ /** Escape regex metacharacters so a version like 1.0.0 matches literally. */
1719
+ function escapeRegExp(text) {
1720
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1721
+ }
1292
1722
  /**
1293
- * Strip a LIVE route object down to the plain shape the route store expects.
1294
- * `router.current()` returns the host's live data (reactive proxies, location
1295
- * objects with cycles) and the host's navigate deep-clones via JSON.stringify
1296
- * — passing the live object through throws "cyclic structures" and the
1297
- * window could never close (field report beta.5, root cause).
1723
+ * Extract the body of a version section from changelog text — inline replica
1724
+ * of scripts/changelog-extract.mjs `extractSection` (see that file for the
1725
+ * full contract: `## [<version>] - YYYY-MM-DD`, leading `v` and the date
1726
+ * optional, `## [Unreleased]` never matched).
1298
1727
  */
1299
- function plainRoute(route) {
1300
- if (route === void 0) return { type: "home" };
1301
- if (route.type === "session" && "sessionID" in route && typeof route.sessionID === "string") return {
1302
- type: "session",
1303
- sessionID: route.sessionID
1728
+ function extractSection(changelogText, version) {
1729
+ const normalized = String(version).trim().replace(/^v/i, "");
1730
+ if (!normalized || /^unreleased$/i.test(normalized)) return {
1731
+ found: false,
1732
+ body: null
1304
1733
  };
1305
- if (route.type === "plugin" && typeof route.name === "string") return {
1306
- type: "plugin",
1307
- name: route.name
1734
+ const escaped = escapeRegExp(normalized);
1735
+ const match = new RegExp(`^##[ \\t]+\\[v?${escaped}\\](?:[ \\t]*-[ \\t]*\\d{4}-\\d{2}-\\d{2})?(?=[ \\t]|$)`, "m").exec(changelogText);
1736
+ if (!match) return {
1737
+ found: false,
1738
+ body: null
1308
1739
  };
1309
- return { type: "home" };
1310
- }
1311
- const [blocking, setBlocking] = createSignal(false);
1312
- /** True while a Pantheon settings surface (page or fallback dialog) is open. */
1313
- function pantheonSettingsBlocking() {
1314
- return blocking();
1315
- }
1316
- let routerAvailable = false;
1317
- function globalOverridesPath() {
1318
- const xdgConfig = process.env.XDG_CONFIG_HOME ?? join(process.env.HOME ?? "", ".config");
1319
- return join(xdgConfig, "opencode", "pantheon-overrides.json");
1320
- }
1321
- function projectOverridesPath() {
1322
- return join(process.cwd(), ".pantheon", "overrides.json");
1323
- }
1324
- function readOneOverrides(path) {
1325
- try {
1326
- const parsed = JSON.parse(readFileSync(path, "utf8"));
1327
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return {
1328
- value: {},
1329
- corrupt: true
1330
- };
1331
- return {
1332
- value: parsed,
1333
- corrupt: false
1334
- };
1335
- } catch (error) {
1336
- return {
1337
- value: {},
1338
- corrupt: error?.code !== "ENOENT"
1339
- };
1340
- }
1341
- }
1342
- function readOverridesLoad() {
1343
- const globalRead = readOneOverrides(globalOverridesPath());
1344
- const projectRead = readOneOverrides(projectOverridesPath());
1740
+ const newline = changelogText.indexOf("\n", match.index);
1741
+ const start = newline === -1 ? changelogText.length : newline + 1;
1742
+ const nextHeading = /^##[ \t]+\[/m.exec(changelogText.slice(start));
1743
+ const end = nextHeading ? start + nextHeading.index : changelogText.length;
1345
1744
  return {
1346
- global: globalRead.value,
1347
- project: projectRead.value,
1348
- corruptGlobal: globalRead.corrupt
1745
+ found: true,
1746
+ body: changelogText.slice(start, end).trim()
1349
1747
  };
1350
1748
  }
1351
- function writeOverridesToDisk(load) {
1352
- writeFileSync(globalOverridesPath(), serializeOverrides(load.global), "utf8");
1749
+ /**
1750
+ * Reduce one markdown line to plain text: links keep their label, emphasis
1751
+ * and inline-code markers are dropped, HTML comment fragments are removed,
1752
+ * and whitespace collapses. Deliberately simple — the input is our own
1753
+ * CHANGELOG (lint-capped at 200 chars per bullet), not hostile input.
1754
+ */
1755
+ function stripMarkdown(text) {
1756
+ return text.replace(/<!--[\s\S]*?-->/g, " ").replace(/\[([^\]]+)\]\([^)]*\)/g, "$1").replace(/(\*\*|__)/g, "").replace(/`/g, "").replace(/\s+/g, " ").trim();
1353
1757
  }
1354
- function userOpenCodeConfigPath() {
1355
- const xdgConfig = process.env.XDG_CONFIG_HOME ?? join(process.env.HOME ?? "", ".config");
1356
- return join(xdgConfig, "opencode", "opencode.json");
1758
+ /** Strip the leading H3 marker (`### Added` → `Added`). */
1759
+ function stripHeading(text) {
1760
+ return text.replace(/^#{1,6}[ \t]+/, "").trim();
1357
1761
  }
1358
- /** Read options.goal_loop from the user's opencode.json (fail-open). */
1359
- function readGoalLoopPrefs() {
1762
+ /**
1763
+ * Extract the curated summary block (`### 🆕 What's New` or `## 🆕 What's New`)
1764
+ * from a section body: its bullets only, each truncated to
1765
+ * WHATS_NEW_ITEM_MAX_CHARS, capped to WHATS_NEW_SUMMARY_MAX_ITEMS. Null when
1766
+ * the section carries no summary block (the full-section fallback applies).
1767
+ */
1768
+ function extractWhatsNewSummary(body) {
1769
+ const lines = body.split("\n");
1770
+ const start = lines.findIndex((line) => /^#{2,3}[ \t]+.*What'?s New/i.test(line.trim()));
1771
+ if (start === -1) return null;
1772
+ const items = [];
1773
+ for (const rawLine of lines.slice(start + 1)) {
1774
+ const line = rawLine.trim();
1775
+ if (line === "" || line.startsWith("<!--")) continue;
1776
+ if (/^#{1,6}[ \t]/.test(line)) break;
1777
+ if (!/^[-*][ \t]/.test(line)) continue;
1778
+ if (items.length >= 6) break;
1779
+ const content = stripMarkdown(line.replace(/^[-*][ \t]+/, ""));
1780
+ if (content === "") continue;
1781
+ items.push(content.length > 140 ? `${content.slice(0, 139)}…` : content);
1782
+ }
1783
+ return items.length > 0 ? items : null;
1784
+ }
1785
+ /**
1786
+ * Extract the release highlights for `version`. When the section carries a
1787
+ * curated `🆕 What's New` summary block, THE WINDOW SHOWS ONLY THAT (the
1788
+ * full Added/Changed/Fixed walls are for the CHANGELOG readers, not the
1789
+ * dialog); otherwise it falls back to the H3-group extraction bounded to
1790
+ * WHATS_NEW_MAX_ITEMS bullets. A missing section, a bullet-less section or a
1791
+ * blank changelog all return EMPTY_HIGHLIGHTS (no window).
1792
+ */
1793
+ function extractHighlights(changelogText, version) {
1794
+ const { found, body } = extractSection(changelogText ?? "", version ?? "");
1795
+ if (!found || !body) return { ...EMPTY_HIGHLIGHTS };
1796
+ const summary = extractWhatsNewSummary(body);
1797
+ if (summary !== null) return {
1798
+ version: String(version).trim().replace(/^v/i, ""),
1799
+ found: true,
1800
+ groups: [{
1801
+ heading: null,
1802
+ items: summary
1803
+ }],
1804
+ totalItems: summary.length,
1805
+ truncated: false
1806
+ };
1807
+ const groups = [];
1808
+ let totalItems = 0;
1809
+ let truncated = false;
1810
+ for (const rawLine of body.split("\n")) {
1811
+ const line = rawLine.trim();
1812
+ if (line === "" || line.startsWith("<!--")) continue;
1813
+ if (/^#{1,6}[ \t]/.test(line)) {
1814
+ const heading = stripMarkdown(stripHeading(line));
1815
+ if (heading === "") continue;
1816
+ if (groups.at(-1)?.items.length === 0) groups.pop();
1817
+ groups.push({
1818
+ heading,
1819
+ items: []
1820
+ });
1821
+ continue;
1822
+ }
1823
+ if (totalItems >= 12) {
1824
+ if (/^[-*][ \t]/.test(line)) totalItems += 1;
1825
+ continue;
1826
+ }
1827
+ const isBullet = /^[-*][ \t]/.test(line);
1828
+ const continuation = (groups.at(-1)?.items.length ?? 0) > 0;
1829
+ if (!isBullet && !continuation) continue;
1830
+ const content = stripMarkdown(isBullet ? line.replace(/^[-*][ \t]+/, "") : line);
1831
+ if (content === "") continue;
1832
+ const bounded = content.length > 140 ? `${content.slice(0, 139)}…` : content;
1833
+ const group = groups.at(-1);
1834
+ if (group === void 0) groups.push({
1835
+ heading: null,
1836
+ items: [bounded]
1837
+ });
1838
+ else if (isBullet || group.items.length === 0) group.items.push(bounded);
1839
+ else group.items[group.items.length - 1] = `${group.items.at(-1)} ${bounded}`.trim();
1840
+ if (isBullet) totalItems += 1;
1841
+ }
1842
+ const kept = groups.filter((group) => group.items.length > 0);
1843
+ truncated = totalItems > 12;
1844
+ return {
1845
+ version: found ? String(version).trim().replace(/^v/i, "") : null,
1846
+ found,
1847
+ groups: kept,
1848
+ totalItems,
1849
+ truncated
1850
+ };
1851
+ }
1852
+ /** Window title — mirrors the sidebar's `Pantheon v<version>` convention. */
1853
+ function whatsNewTitle(version) {
1854
+ return `O que há de novo — Pantheon v${String(version).trim().replace(/^v/i, "")}`;
1855
+ }
1856
+ /** Flat display lines for the window: group headings, `• ` bullets, `+N more`. */
1857
+ function whatsNewLines(highlights) {
1858
+ const lines = [];
1859
+ for (const group of highlights.groups) {
1860
+ if (group.heading !== null) lines.push(group.heading);
1861
+ for (const item of group.items) lines.push(`• ${item}`);
1862
+ }
1863
+ if (highlights.truncated) {
1864
+ const hidden = Math.max(0, highlights.totalItems - 12);
1865
+ if (hidden > 0) lines.push(`${WHATS_NEW_MORE_PREFIX}${hidden} mais`);
1866
+ }
1867
+ return lines;
1868
+ }
1869
+ /**
1870
+ * Candidate CHANGELOG.md locations for a bundle, first readable wins:
1871
+ * 1. the plugin copy root (`<configDir>/plugins/pantheon-tui/CHANGELOG.md`,
1872
+ * shipped by both installers next to package.json);
1873
+ * 2. the package root (dev checkout; also an npm-package install when the
1874
+ * bundle runs from `<pkg>/src/plugins/tui/dist/`).
1875
+ */
1876
+ function changelogCandidates(bundlePath) {
1877
+ const dist = dirname(bundlePath);
1878
+ const copyRoot = dirname(dist);
1879
+ const packageRoot = dirname(dirname(dirname(copyRoot)));
1880
+ return [join(copyRoot, "CHANGELOG.md"), join(packageRoot, "CHANGELOG.md")];
1881
+ }
1882
+ /** Read the first existing candidate; null when none is readable (no window). */
1883
+ async function readChangelogForBundle(bundleUrl) {
1884
+ try {
1885
+ const bundlePath = fileURLToPath(bundleUrl);
1886
+ for (const candidate of changelogCandidates(bundlePath)) try {
1887
+ return await readFile(candidate, "utf8");
1888
+ } catch {}
1889
+ return null;
1890
+ } catch {
1891
+ return null;
1892
+ }
1893
+ }
1894
+ /** The ambient build-time version, or null outside a tsdown build. */
1895
+ function embeddedVersion() {
1896
+ return "2.0.0";
1897
+ }
1898
+ /**
1899
+ * Resolve the running Pantheon version for the what's-new window: the plugin
1900
+ * copy's own package.json first (the copy root two levels above the bundle,
1901
+ * then the package root four levels above — the same legs as the V1 sidebar's
1902
+ * detectVersion try 0a/0b), falling back to the tsdown build embed. Null when
1903
+ * nothing resolves → no window (fail-open).
1904
+ */
1905
+ async function resolveRunningVersion$1(bundleUrl, embedded = embeddedVersion()) {
1906
+ try {
1907
+ const bundlePath = fileURLToPath(bundleUrl);
1908
+ const dist = dirname(bundlePath);
1909
+ for (const root of [dirname(dist), dirname(dirname(dirname(dist)))]) try {
1910
+ const raw = await readFile(join(root, "package.json"), "utf8");
1911
+ const parsed = JSON.parse(raw);
1912
+ if (typeof parsed.version === "string" && parsed.version.trim() !== "") return parsed.version;
1913
+ } catch {}
1914
+ } catch {}
1915
+ return embedded;
1916
+ }
1917
+ //#endregion
1918
+ //#region src/pantheon-settings.tsx
1919
+ /** @jsxImportSource @opentui/solid */
1920
+ /**
1921
+ * pantheon-settings.tsx — the /pantheon-settings window (2.0.0-beta.4).
1922
+ *
1923
+ * A FULL-SCREEN settings window in the OpenCode Quota shape: a tab header,
1924
+ * grouped setting rows with ←/→ value cyclers, a note column, and a
1925
+ * save/reset footer. The surface is a ROUTER PAGE (`ui.router.register` +
1926
+ * `navigate({type:'plugin'})`) — true full-screen, reachable from the home
1927
+ * route AND sessions, no focus dance (binary-verified precedent: the host's
1928
+ * own opencode.diffs plugin). Hosts without a router fall back to the old
1929
+ * dialog with the same commands (fail-open).
1930
+ *
1931
+ * Edits stage into a DRAFT: ←/→ cycles a row's value, `ctrl+s` saves every
1932
+ * staged row through the per-surface guards, `ctrl+r` resets the current
1933
+ * tab, `esc`/`q` confirms before discarding. The disk never changes before
1934
+ * save, and every refusal surfaces in the notice line — never silent.
1935
+ *
1936
+ * The keymap layer is registered ONCE at setup with `priority: 1` (the host
1937
+ * resolves bind conflicts by priority then registration order — a stale
1938
+ * dispatch-panel layer must never win while this window is open; field
1939
+ * report beta.2: navigation "stopped working" was exactly that theft).
1940
+ */
1941
+ const ROUTE_NAME = "pantheon-settings";
1942
+ /** The input mode the page pushes while mounted (composer layers sleep). */
1943
+ const ROUTE_MODE = "pantheon-settings";
1944
+ /** Loose local shape of a host route (the real Route lives in the host typings). */
1945
+ /**
1946
+ * Strip a LIVE route object down to the plain shape the route store expects.
1947
+ * `router.current()` returns the host's live data (reactive proxies, location
1948
+ * objects with cycles) and the host's navigate deep-clones via JSON.stringify
1949
+ * — passing the live object through throws "cyclic structures" and the
1950
+ * window could never close (field report beta.5, root cause).
1951
+ */
1952
+ function plainRoute(route) {
1953
+ if (route === void 0) return { type: "home" };
1954
+ if (route.type === "session" && "sessionID" in route && typeof route.sessionID === "string") return {
1955
+ type: "session",
1956
+ sessionID: route.sessionID
1957
+ };
1958
+ if (route.type === "plugin" && typeof route.name === "string") return {
1959
+ type: "plugin",
1960
+ name: route.name
1961
+ };
1962
+ return { type: "home" };
1963
+ }
1964
+ const [blocking, setBlocking] = createSignal(false);
1965
+ /** True while a Pantheon settings surface (page or fallback dialog) is open. */
1966
+ function pantheonSettingsBlocking() {
1967
+ return blocking();
1968
+ }
1969
+ let routerAvailable = false;
1970
+ function globalOverridesPath() {
1971
+ const xdgConfig = process.env.XDG_CONFIG_HOME ?? join(process.env.HOME ?? "", ".config");
1972
+ return join(xdgConfig, "opencode", "pantheon-overrides.json");
1973
+ }
1974
+ function projectOverridesPath() {
1975
+ return join(process.cwd(), ".pantheon", "overrides.json");
1976
+ }
1977
+ function readOneOverrides(path) {
1978
+ try {
1979
+ const parsed = JSON.parse(readFileSync(path, "utf8"));
1980
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return {
1981
+ value: {},
1982
+ corrupt: true
1983
+ };
1984
+ return {
1985
+ value: parsed,
1986
+ corrupt: false
1987
+ };
1988
+ } catch (error) {
1989
+ return {
1990
+ value: {},
1991
+ corrupt: error?.code !== "ENOENT"
1992
+ };
1993
+ }
1994
+ }
1995
+ function readOverridesLoad() {
1996
+ const globalRead = readOneOverrides(globalOverridesPath());
1997
+ const projectRead = readOneOverrides(projectOverridesPath());
1998
+ return {
1999
+ global: globalRead.value,
2000
+ project: projectRead.value,
2001
+ corruptGlobal: globalRead.corrupt
2002
+ };
2003
+ }
2004
+ function writeOverridesToDisk(load) {
2005
+ writeFileSync(globalOverridesPath(), serializeOverrides(load.global), "utf8");
2006
+ }
2007
+ function userOpenCodeConfigPath() {
2008
+ const xdgConfig = process.env.XDG_CONFIG_HOME ?? join(process.env.HOME ?? "", ".config");
2009
+ return join(xdgConfig, "opencode", "opencode.json");
2010
+ }
2011
+ /** Read options.goal_loop from the user's opencode.json (fail-open). */
2012
+ function readGoalLoopPrefs() {
1360
2013
  const fallback = { ...DEFAULT_GOAL_LOOP_PREFS };
1361
2014
  try {
1362
2015
  const raw = JSON.parse(readFileSync(userOpenCodeConfigPath(), "utf8"))?.options?.goal_loop;
@@ -1413,6 +2066,28 @@ function writeDecisionBudget(budgets) {
1413
2066
  writeFileSync(temp, `${JSON.stringify(doc, null, 2)}\n`, { mode: 384 });
1414
2067
  renameSync(temp, path);
1415
2068
  }
2069
+ function decisionAuthStorePath() {
2070
+ const xdgData = process.env.XDG_DATA_HOME ?? join(process.env.HOME ?? "", ".local", "share");
2071
+ return join(xdgData, "opencode", "auth.json");
2072
+ }
2073
+ /** Provider ids registered in the host auth store (existence only — never values). */
2074
+ function readAuthProviders() {
2075
+ const names = /* @__PURE__ */ new Set();
2076
+ try {
2077
+ const parsed = JSON.parse(readFileSync(decisionAuthStorePath(), "utf8"));
2078
+ for (const key of Object.keys(parsed)) names.add(key);
2079
+ } catch {}
2080
+ return names;
2081
+ }
2082
+ /** Provider ids present in opencode.json `providers` (the config copy the host reads). */
2083
+ function readConfigProviders() {
2084
+ const names = /* @__PURE__ */ new Set();
2085
+ try {
2086
+ const parsed = JSON.parse(readFileSync(userOpenCodeConfigPath(), "utf8"));
2087
+ for (const key of Object.keys(parsed?.providers ?? {})) names.add(key);
2088
+ } catch {}
2089
+ return names;
2090
+ }
1416
2091
  function updateCheckStatePath() {
1417
2092
  const stateDir = process.env.XDG_STATE_HOME ?? join(process.env.HOME ?? "", ".local", "state");
1418
2093
  return join(stateDir, "pantheon", "update-check.json");
@@ -1424,9 +2099,9 @@ function readUpdateCheckState() {
1424
2099
  return {};
1425
2100
  }
1426
2101
  }
1427
- async function fetchLatestForChannel(currentVersion) {
2102
+ async function fetchLatestForChannel(channel) {
1428
2103
  try {
1429
- const response = await fetch(registryUrlForChannel(updateChannelFor(currentVersion)), { signal: AbortSignal.timeout(5e3) });
2104
+ const response = await fetch(registryUrlForChannel(channel), { signal: AbortSignal.timeout(5e3) });
1430
2105
  return String((await response.json())?.version ?? "") || null;
1431
2106
  } catch {
1432
2107
  return null;
@@ -1442,156 +2117,389 @@ function persistUpdateCheckState(previous, latest) {
1442
2117
  } : null, Date.now()), null, 2)}\n`);
1443
2118
  } catch {}
1444
2119
  }
1445
- function resolveRunningVersion$1() {
1446
- return "2.0.0-beta.6";
2120
+ function resolveRunningVersion() {
2121
+ return "2.0.0";
1447
2122
  }
1448
- const VALUE_WIDTH = 22;
2123
+ const VALUE_WIDTH = 24;
1449
2124
  function SettingsWindow(props) {
1450
2125
  const tab = () => props.tabs()[props.page()] ?? props.tabs()[0] ?? EMPTY_TAB;
1451
- const rows = () => tabRows(tab());
1452
2126
  return (() => {
1453
- var _el$ = createElement("box"), _el$2 = createElement("box"), _el$3 = createElement("text"), _el$4 = createElement("box"), _el$5 = createElement("text"), _el$7 = createElement("text"), _el$0 = createElement("text"), _el$1 = createElement("text");
2127
+ var _el$ = createElement("box"), _el$2 = createElement("box"), _el$3 = createElement("text"), _el$4 = createElement("b"), _el$6 = createElement("span"), _el$7 = createElement("box"), _el$8 = createElement("box"), _el$9 = createElement("box"), _el$0 = createElement("text"), _el$10 = createElement("box"), _el$11 = createElement("scrollbox");
1454
2128
  insertNode(_el$, _el$2);
1455
- insertNode(_el$, _el$7);
1456
- insertNode(_el$, _el$0);
1457
- insertNode(_el$, _el$1);
1458
- setProp(_el$, "flexDirection", "column");
1459
- setProp(_el$, "paddingLeft", 1);
1460
- setProp(_el$, "paddingRight", 1);
1461
- setProp(_el$, "paddingTop", 1);
2129
+ insertNode(_el$, _el$10);
2130
+ spread(_el$, mergeProps(() => props.boxRef !== void 0 ? { ref: props.boxRef } : {}, {
2131
+ "focusable": true,
2132
+ "flexDirection": "column"
2133
+ }, () => props.height !== void 0 ? { height: props.height } : {
2134
+ flexGrow: 1,
2135
+ flexBasis: 0
2136
+ }, {
2137
+ "minHeight": 0,
2138
+ get border() {
2139
+ return !props.isDialog;
2140
+ }
2141
+ }, () => props.isDialog ? {} : { borderStyle: "rounded" }, {
2142
+ get borderColor() {
2143
+ return memo(() => !!props.isDialog)() ? void 0 : memo(() => !!props.hasKeyboard?.())() ? props.warn ?? "#fba970" : props.muted ?? "#52525b";
2144
+ },
2145
+ "paddingLeft": 1,
2146
+ "paddingRight": 1,
2147
+ "paddingTop": 0,
2148
+ "paddingBottom": 0
2149
+ }, () => props.onMouseDown !== void 0 ? { onMouseDown: props.onMouseDown } : {}), true);
1462
2150
  insertNode(_el$2, _el$3);
1463
- insertNode(_el$2, _el$4);
1464
- insertNode(_el$2, _el$5);
2151
+ insertNode(_el$2, _el$7);
2152
+ insertNode(_el$2, _el$8);
2153
+ insertNode(_el$2, _el$9);
1465
2154
  setProp(_el$2, "flexDirection", "row");
1466
- setProp(_el$3, "flexShrink", 0);
2155
+ setProp(_el$2, "flexWrap", "wrap");
2156
+ setProp(_el$2, "alignItems", "center");
2157
+ setProp(_el$2, "flexShrink", 0);
2158
+ setProp(_el$2, "marginBottom", 1);
2159
+ setProp(_el$2, "rowGap", 1);
2160
+ insertNode(_el$3, _el$4);
2161
+ insertNode(_el$3, _el$6);
1467
2162
  setProp(_el$3, "attributes", 1);
1468
- insert(_el$3, () => `Pantheon v${props.version}`);
1469
- insert(_el$2, createComponent(For, {
2163
+ setProp(_el$3, "wrapMode", "none");
2164
+ insertNode(_el$4, createTextNode(`Pantheon`));
2165
+ insert(_el$6, () => ` v${props.version}`);
2166
+ setProp(_el$7, "width", 2);
2167
+ setProp(_el$8, "flexDirection", "row");
2168
+ setProp(_el$8, "flexWrap", "wrap");
2169
+ setProp(_el$8, "flexGrow", 1);
2170
+ setProp(_el$8, "flexShrink", 0);
2171
+ setProp(_el$8, "columnGap", 1);
2172
+ setProp(_el$8, "rowGap", 1);
2173
+ insert(_el$8, createComponent(For, {
1470
2174
  get each() {
1471
2175
  return props.tabs();
1472
2176
  },
1473
- children: (t, index) => (() => {
1474
- var _el$11 = createElement("text");
1475
- setProp(_el$11, "flexShrink", 0);
1476
- spread(_el$11, mergeProps({ get fg() {
1477
- return memo(() => index() === props.page())() ? props.fg : props.muted;
1478
- } }, () => index() === props.page() ? { attributes: 1 } : {}), true);
1479
- insert(_el$11, () => ` ${t.title}${tabDirty(props.draft(), t) ? " ●" : ""}`);
1480
- return _el$11;
1481
- })()
1482
- }), _el$4);
1483
- setProp(_el$4, "flexGrow", 1);
1484
- insertNode(_el$5, createTextNode(`esc`));
1485
- setProp(_el$5, "flexShrink", 0);
1486
- insertNode(_el$7, createTextNode(`────────────────────────────────────────────────────────────────────────`));
1487
- insert(_el$, createComponent(For, {
2177
+ children: (t, index) => {
2178
+ const isActive = () => index() === props.page();
2179
+ return (() => {
2180
+ var _el$32 = createElement("box"), _el$33 = createElement("text");
2181
+ insertNode(_el$32, _el$33);
2182
+ setProp(_el$32, "onMouseDown", () => props.onJumpTab?.(index()));
2183
+ setProp(_el$32, "paddingLeft", 1);
2184
+ setProp(_el$32, "paddingRight", 1);
2185
+ setProp(_el$32, "flexShrink", 0);
2186
+ spread(_el$32, mergeProps(() => isActive() ? { backgroundColor: "#262626" } : {}), true);
2187
+ setProp(_el$33, "wrapMode", "none");
2188
+ spread(_el$33, mergeProps({ get fg() {
2189
+ return memo(() => !!isActive())() ? props.warn ?? "#fba970" : props.muted;
2190
+ } }, () => isActive() ? { attributes: 1 } : {}), true);
2191
+ insert(_el$33, () => `${t.title}${tabDirty(props.draft(), t) ? " ●" : ""}`);
2192
+ return _el$32;
2193
+ })();
2194
+ }
2195
+ }));
2196
+ insertNode(_el$9, _el$0);
2197
+ setProp(_el$9, "onMouseDown", () => props.onClose?.());
2198
+ setProp(_el$9, "paddingLeft", 1);
2199
+ setProp(_el$9, "flexShrink", 0);
2200
+ insertNode(_el$0, createTextNode(`esc`));
2201
+ setProp(_el$0, "wrapMode", "none");
2202
+ insertNode(_el$10, _el$11);
2203
+ setProp(_el$10, "flexDirection", "column");
2204
+ setProp(_el$10, "flexGrow", 1);
2205
+ setProp(_el$10, "flexBasis", 0);
2206
+ setProp(_el$10, "minHeight", 0);
2207
+ setProp(_el$10, "overflow", "hidden");
2208
+ setProp(_el$11, "flexGrow", 1);
2209
+ setProp(_el$11, "flexBasis", 0);
2210
+ setProp(_el$11, "minHeight", 0);
2211
+ spread(_el$11, mergeProps(() => props.maxHeight !== void 0 ? { maxHeight: props.maxHeight } : {}), true);
2212
+ insert(_el$11, createComponent(For, {
1488
2213
  get each() {
1489
2214
  return tab().groups;
1490
2215
  },
1491
2216
  children: (group) => (() => {
1492
- var _el$12 = createElement("box"), _el$14 = createElement("box");
1493
- insertNode(_el$12, _el$14);
1494
- setProp(_el$12, "flexDirection", "column");
1495
- insert(_el$12, createComponent(Show, {
2217
+ var _el$34 = createElement("box");
2218
+ setProp(_el$34, "flexDirection", "column");
2219
+ setProp(_el$34, "marginBottom", 1);
2220
+ insert(_el$34, createComponent(Show, {
1496
2221
  get when() {
1497
2222
  return group.title !== void 0;
1498
2223
  },
1499
2224
  get children() {
1500
- var _el$13 = createElement("text");
1501
- setProp(_el$13, "attributes", 1);
1502
- insert(_el$13, () => group.title);
1503
- effect((_$p) => setProp(_el$13, "fg", props.fg, _$p));
1504
- return _el$13;
2225
+ var _el$35 = createElement("text");
2226
+ setProp(_el$35, "attributes", 1);
2227
+ insert(_el$35, () => group.title);
2228
+ effect((_$p) => setProp(_el$35, "fg", props.warn ?? props.fg, _$p));
2229
+ return _el$35;
1505
2230
  }
1506
- }), _el$14);
1507
- insert(_el$12, createComponent(For, {
2231
+ }), null);
2232
+ insert(_el$34, createComponent(For, {
1508
2233
  get each() {
1509
2234
  return group.rows;
1510
2235
  },
1511
2236
  children: (row) => {
1512
- const isSelected = () => rows()[props.selected()]?.id === row.id;
2237
+ const isSelected = () => row.id === props.selectedId();
1513
2238
  const display = () => props.draft()[row.id] ?? row.value;
1514
2239
  const staged = () => props.draft()[row.id] !== void 0;
1515
2240
  const gutter = () => isSelected() ? "▸ " : " ";
1516
- const valueCell = () => row.cycle !== void 0 ? `< ${display()} >` : display();
2241
+ const valueCell = () => {
2242
+ if (row.cycle !== void 0) return `< ${display()} >`;
2243
+ if (row.action !== void 0) return `[ ${display()} ]`;
2244
+ if (row.id.startsWith("autonomy.gradient.")) return `[ref] ${display()}`;
2245
+ return display();
2246
+ };
1517
2247
  return (() => {
1518
- var _el$15 = createElement("box"), _el$16 = createElement("box"), _el$17 = createElement("text"), _el$18 = createElement("box"), _el$19 = createElement("text");
1519
- insertNode(_el$15, _el$16);
1520
- insertNode(_el$15, _el$18);
1521
- setProp(_el$15, "flexDirection", "row");
1522
- insertNode(_el$16, _el$17);
1523
- setProp(_el$16, "width", 30);
1524
- spread(_el$17, mergeProps({ get fg() {
1525
- return props.fg;
1526
- } }, () => isSelected() ? { attributes: 1 } : {}), true);
1527
- insert(_el$17, () => `${gutter()}${row.name}`.padEnd(30));
1528
- insertNode(_el$18, _el$19);
1529
- setProp(_el$18, "width", 22);
1530
- spread(_el$19, mergeProps({ get fg() {
1531
- return memo(() => !!(isSelected() || staged()))() ? props.fg : props.muted;
2248
+ var _el$36 = createElement("box"), _el$37 = createElement("box"), _el$38 = createElement("text"), _el$39 = createElement("box"), _el$40 = createElement("text");
2249
+ insertNode(_el$36, _el$37);
2250
+ insertNode(_el$36, _el$39);
2251
+ setProp(_el$36, "flexDirection", "row");
2252
+ spread(_el$36, mergeProps(() => isSelected() ? { backgroundColor: "#262626" } : {}, { "onMouseDown": () => {
2253
+ props.onSelectRow?.(row.id);
2254
+ } }), true);
2255
+ insertNode(_el$37, _el$38);
2256
+ setProp(_el$37, "width", 28);
2257
+ spread(_el$38, mergeProps({ get fg() {
2258
+ return memo(() => !!isSelected())() ? props.warn ?? "#fba970" : props.fg;
1532
2259
  } }, () => isSelected() ? { attributes: 1 } : {}), true);
1533
- insert(_el$19, () => `${valueCell()}${staged() ? " ●" : ""}`.padEnd(VALUE_WIDTH));
1534
- insert(_el$15, createComponent(Show, {
2260
+ insert(_el$38, () => `${gutter()}${row.name}`.padEnd(28));
2261
+ insertNode(_el$39, _el$40);
2262
+ setProp(_el$39, "width", 24);
2263
+ setProp(_el$39, "onMouseDown", () => {
2264
+ props.onSelectRow?.(row.id);
2265
+ props.onCycleValue?.(row.id, 1);
2266
+ });
2267
+ spread(_el$40, mergeProps({ get fg() {
2268
+ return memo(() => !!isSelected())() ? "#ffffff" : memo(() => !!staged())() ? props.warn ?? props.fg : props.muted;
2269
+ } }, () => isSelected() || staged() ? { attributes: 1 } : {}), true);
2270
+ insert(_el$40, () => `${valueCell()}${staged() ? " ●" : ""}`.padEnd(VALUE_WIDTH));
2271
+ insert(_el$36, createComponent(Show, {
1535
2272
  get when() {
1536
2273
  return row.note !== void 0;
1537
2274
  },
1538
2275
  get children() {
1539
- var _el$20 = createElement("box"), _el$21 = createElement("text");
1540
- insertNode(_el$20, _el$21);
1541
- setProp(_el$20, "flexGrow", 1);
1542
- setProp(_el$20, "flexShrink", 1);
1543
- insert(_el$21, () => row.note);
1544
- effect((_$p) => setProp(_el$21, "fg", props.muted, _$p));
1545
- return _el$20;
2276
+ var _el$41 = createElement("box"), _el$42 = createElement("text");
2277
+ insertNode(_el$41, _el$42);
2278
+ setProp(_el$41, "flexGrow", 1);
2279
+ setProp(_el$41, "flexShrink", 1);
2280
+ insert(_el$42, () => row.note);
2281
+ effect((_$p) => setProp(_el$42, "fg", isSelected() ? "#e5e7eb" : props.muted, _$p));
2282
+ return _el$41;
1546
2283
  }
1547
2284
  }), null);
1548
- return _el$15;
2285
+ return _el$36;
1549
2286
  })();
1550
2287
  }
1551
- }), _el$14);
1552
- setProp(_el$14, "height", 1);
1553
- return _el$12;
2288
+ }), null);
2289
+ return _el$34;
1554
2290
  })()
1555
- }), _el$0);
2291
+ }));
1556
2292
  insert(_el$, createComponent(Show, {
1557
2293
  get when() {
1558
2294
  return props.notice() !== void 0;
1559
2295
  },
1560
2296
  get children() {
1561
- var _el$9 = createElement("text");
1562
- insert(_el$9, (() => {
1563
- var _c$ = memo(() => !!props.notice()?.startsWith("saved"));
1564
- return () => _c$() ? props.notice() : `⚠ ${props.notice()}`;
2297
+ var _el$12 = createElement("text");
2298
+ insert(_el$12, (() => {
2299
+ var _c$ = memo(() => !!(props.notice()?.startsWith("[OK]") || props.notice()?.startsWith("saved")));
2300
+ return () => _c$() ? props.notice() : `[WARN] ${props.notice()}`;
1565
2301
  })());
1566
- effect((_$p) => setProp(_el$9, "fg", props.notice()?.startsWith("saved") ? props.muted : props.warn ?? props.muted, _$p));
1567
- return _el$9;
2302
+ effect((_$p) => setProp(_el$12, "fg", props.notice()?.startsWith("[OK]") || props.notice()?.startsWith("saved") ? props.fg : props.warn ?? props.muted, _$p));
2303
+ return _el$12;
2304
+ }
2305
+ }), null);
2306
+ insert(_el$, createComponent(Show, {
2307
+ get when() {
2308
+ return props.confirmExit?.();
2309
+ },
2310
+ get fallback() {
2311
+ return (() => {
2312
+ var _el$43 = createElement("box"), _el$61 = createElement("text");
2313
+ insertNode(_el$43, _el$61);
2314
+ setProp(_el$43, "flexDirection", "column");
2315
+ insert(_el$43, createComponent(Show, {
2316
+ get when() {
2317
+ return draftDirty(props.draft());
2318
+ },
2319
+ get fallback() {
2320
+ return (() => {
2321
+ var _el$62 = createElement("box"), _el$63 = createElement("box"), _el$64 = createElement("text"), _el$66 = createElement("text"), _el$68 = createElement("box"), _el$69 = createElement("text"), _el$71 = createElement("text"), _el$73 = createElement("box"), _el$74 = createElement("text"), _el$76 = createElement("box"), _el$77 = createElement("text");
2322
+ insertNode(_el$62, _el$63);
2323
+ insertNode(_el$62, _el$66);
2324
+ insertNode(_el$62, _el$68);
2325
+ insertNode(_el$62, _el$71);
2326
+ insertNode(_el$62, _el$73);
2327
+ insertNode(_el$62, _el$76);
2328
+ insertNode(_el$62, _el$77);
2329
+ setProp(_el$62, "flexDirection", "row");
2330
+ setProp(_el$62, "flexWrap", "wrap");
2331
+ setProp(_el$62, "alignItems", "center");
2332
+ setProp(_el$62, "flexShrink", 0);
2333
+ setProp(_el$62, "rowGap", 1);
2334
+ insertNode(_el$63, _el$64);
2335
+ setProp(_el$63, "backgroundColor", "#262626");
2336
+ setProp(_el$63, "flexShrink", 0);
2337
+ setProp(_el$63, "onMouseDown", () => props.onClose?.());
2338
+ insertNode(_el$64, createTextNode(` Close `));
2339
+ setProp(_el$64, "fg", "#ffffff");
2340
+ insertNode(_el$66, createTextNode(` `));
2341
+ setProp(_el$66, "flexShrink", 0);
2342
+ insertNode(_el$68, _el$69);
2343
+ setProp(_el$68, "backgroundColor", "#262626");
2344
+ setProp(_el$68, "flexShrink", 0);
2345
+ setProp(_el$68, "onMouseDown", () => props.onResetPage?.());
2346
+ insertNode(_el$69, createTextNode(` Reset page `));
2347
+ setProp(_el$69, "fg", "#ffffff");
2348
+ insertNode(_el$71, createTextNode(` `));
2349
+ setProp(_el$71, "flexShrink", 0);
2350
+ insertNode(_el$73, _el$74);
2351
+ setProp(_el$73, "backgroundColor", "#262626");
2352
+ setProp(_el$73, "flexShrink", 0);
2353
+ setProp(_el$73, "onMouseDown", () => props.onStageDefaults?.());
2354
+ insertNode(_el$74, createTextNode(` Defaults `));
2355
+ setProp(_el$74, "fg", "#ffffff");
2356
+ setProp(_el$76, "flexGrow", 1);
2357
+ setProp(_el$76, "minWidth", 1);
2358
+ insertNode(_el$77, createTextNode(`no staged changes`));
2359
+ setProp(_el$77, "flexShrink", 0);
2360
+ effect((_p$) => {
2361
+ var _v$1 = props.muted, _v$10 = props.muted, _v$11 = props.muted;
2362
+ _v$1 !== _p$.e && (_p$.e = setProp(_el$66, "fg", _v$1, _p$.e));
2363
+ _v$10 !== _p$.t && (_p$.t = setProp(_el$71, "fg", _v$10, _p$.t));
2364
+ _v$11 !== _p$.a && (_p$.a = setProp(_el$77, "fg", _v$11, _p$.a));
2365
+ return _p$;
2366
+ }, {
2367
+ e: void 0,
2368
+ t: void 0,
2369
+ a: void 0
2370
+ });
2371
+ return _el$62;
2372
+ })();
2373
+ },
2374
+ get children() {
2375
+ var _el$44 = createElement("box"), _el$45 = createElement("box"), _el$46 = createElement("text"), _el$48 = createElement("text"), _el$50 = createElement("box"), _el$51 = createElement("text"), _el$53 = createElement("text"), _el$55 = createElement("box"), _el$56 = createElement("text"), _el$58 = createElement("box"), _el$59 = createElement("text");
2376
+ insertNode(_el$44, _el$45);
2377
+ insertNode(_el$44, _el$48);
2378
+ insertNode(_el$44, _el$50);
2379
+ insertNode(_el$44, _el$53);
2380
+ insertNode(_el$44, _el$55);
2381
+ insertNode(_el$44, _el$58);
2382
+ insertNode(_el$44, _el$59);
2383
+ setProp(_el$44, "flexDirection", "row");
2384
+ setProp(_el$44, "flexWrap", "wrap");
2385
+ setProp(_el$44, "alignItems", "center");
2386
+ setProp(_el$44, "flexShrink", 0);
2387
+ setProp(_el$44, "rowGap", 1);
2388
+ insertNode(_el$45, _el$46);
2389
+ setProp(_el$45, "backgroundColor", "#fba970");
2390
+ setProp(_el$45, "flexShrink", 0);
2391
+ setProp(_el$45, "onMouseDown", () => props.onSave?.());
2392
+ insertNode(_el$46, createTextNode(` Save `));
2393
+ setProp(_el$46, "fg", "#000000");
2394
+ insertNode(_el$48, createTextNode(` `));
2395
+ setProp(_el$48, "flexShrink", 0);
2396
+ insertNode(_el$50, _el$51);
2397
+ setProp(_el$50, "backgroundColor", "#262626");
2398
+ setProp(_el$50, "flexShrink", 0);
2399
+ setProp(_el$50, "onMouseDown", () => props.onDiscard?.());
2400
+ insertNode(_el$51, createTextNode(` Discard `));
2401
+ setProp(_el$51, "fg", "#ffffff");
2402
+ insertNode(_el$53, createTextNode(` `));
2403
+ setProp(_el$53, "flexShrink", 0);
2404
+ insertNode(_el$55, _el$56);
2405
+ setProp(_el$55, "backgroundColor", "#262626");
2406
+ setProp(_el$55, "flexShrink", 0);
2407
+ setProp(_el$55, "onMouseDown", () => props.onResetPage?.());
2408
+ insertNode(_el$56, createTextNode(` Reset page `));
2409
+ setProp(_el$56, "fg", "#ffffff");
2410
+ setProp(_el$58, "flexGrow", 1);
2411
+ setProp(_el$58, "minWidth", 1);
2412
+ insertNode(_el$59, createTextNode(`unsaved changes`));
2413
+ setProp(_el$59, "flexShrink", 0);
2414
+ effect((_p$) => {
2415
+ var _v$8 = props.muted, _v$9 = props.muted, _v$0 = props.warn ?? "#f59e0b";
2416
+ _v$8 !== _p$.e && (_p$.e = setProp(_el$48, "fg", _v$8, _p$.e));
2417
+ _v$9 !== _p$.t && (_p$.t = setProp(_el$53, "fg", _v$9, _p$.t));
2418
+ _v$0 !== _p$.a && (_p$.a = setProp(_el$59, "fg", _v$0, _p$.a));
2419
+ return _p$;
2420
+ }, {
2421
+ e: void 0,
2422
+ t: void 0,
2423
+ a: void 0
2424
+ });
2425
+ return _el$44;
2426
+ }
2427
+ }), _el$61);
2428
+ insert(_el$61, () => {
2429
+ const currentRow = findRow(tab(), props.selectedId() ?? "");
2430
+ if (currentRow?.cycle !== void 0) return "click or ›/←/→ change · ↑↓ select · tab next tab · ctrl+s save · ctrl+r reset page · esc close";
2431
+ if (currentRow?.action !== void 0) return "enter or space run action · ↑↓ select · tab next tab · ctrl+s save · ctrl+r reset page · esc close";
2432
+ return "[ref] documented reference (read-only) · ↑↓ select · tab next tab · esc close";
2433
+ });
2434
+ effect((_$p) => setProp(_el$61, "fg", props.muted, _$p));
2435
+ return _el$43;
2436
+ })();
2437
+ },
2438
+ get children() {
2439
+ var _el$13 = createElement("box"), _el$14 = createElement("box"), _el$15 = createElement("text"), _el$17 = createElement("box"), _el$18 = createElement("text"), _el$20 = createElement("text"), _el$22 = createElement("box"), _el$23 = createElement("text"), _el$25 = createElement("text"), _el$27 = createElement("box"), _el$28 = createElement("text"), _el$30 = createElement("text");
2440
+ insertNode(_el$13, _el$14);
2441
+ insertNode(_el$13, _el$30);
2442
+ setProp(_el$13, "flexDirection", "column");
2443
+ insertNode(_el$14, _el$15);
2444
+ insertNode(_el$14, _el$17);
2445
+ insertNode(_el$14, _el$20);
2446
+ insertNode(_el$14, _el$22);
2447
+ insertNode(_el$14, _el$25);
2448
+ insertNode(_el$14, _el$27);
2449
+ setProp(_el$14, "flexDirection", "row");
2450
+ insertNode(_el$15, createTextNode(`Keep your changes? `));
2451
+ setProp(_el$15, "attributes", 1);
2452
+ insertNode(_el$17, _el$18);
2453
+ setProp(_el$17, "backgroundColor", "#fba970");
2454
+ setProp(_el$17, "onMouseDown", () => props.onSave?.());
2455
+ insertNode(_el$18, createTextNode(` Save `));
2456
+ setProp(_el$18, "fg", "#000000");
2457
+ insertNode(_el$20, createTextNode(` `));
2458
+ insertNode(_el$22, _el$23);
2459
+ setProp(_el$22, "backgroundColor", "#262626");
2460
+ setProp(_el$22, "onMouseDown", () => props.onDiscard?.());
2461
+ insertNode(_el$23, createTextNode(` Discard `));
2462
+ setProp(_el$23, "fg", "#ffffff");
2463
+ insertNode(_el$25, createTextNode(` `));
2464
+ insertNode(_el$27, _el$28);
2465
+ setProp(_el$27, "backgroundColor", "#262626");
2466
+ setProp(_el$27, "onMouseDown", () => props.onCancelExit?.());
2467
+ insertNode(_el$28, createTextNode(` Keep editing `));
2468
+ setProp(_el$28, "fg", "#ffffff");
2469
+ insertNode(_el$30, createTextNode(`ctrl+s save · d discard the changes · esc keep editing`));
2470
+ effect((_p$) => {
2471
+ var _v$ = props.warn ?? "#f59e0b", _v$2 = props.muted, _v$3 = props.muted, _v$4 = props.muted;
2472
+ _v$ !== _p$.e && (_p$.e = setProp(_el$15, "fg", _v$, _p$.e));
2473
+ _v$2 !== _p$.t && (_p$.t = setProp(_el$20, "fg", _v$2, _p$.t));
2474
+ _v$3 !== _p$.a && (_p$.a = setProp(_el$25, "fg", _v$3, _p$.a));
2475
+ _v$4 !== _p$.o && (_p$.o = setProp(_el$30, "fg", _v$4, _p$.o));
2476
+ return _p$;
2477
+ }, {
2478
+ e: void 0,
2479
+ t: void 0,
2480
+ a: void 0,
2481
+ o: void 0
2482
+ });
2483
+ return _el$13;
1568
2484
  }
1569
- }), _el$0);
1570
- insert(_el$0, (() => {
1571
- var _c$2 = memo(() => !!draftDirty(props.draft()));
1572
- return () => _c$2() ? `● unsaved (${draftCount(props.draft())}) — ctrl+s save · ctrl+r reset page` : "no staged changes";
1573
- })());
1574
- insertNode(_el$1, createTextNode(`1-9 tab · ←/→ change value · enter apply · tab next tab · ctrl+s save · ctrl+r reset page · esc/q close`));
2485
+ }), null);
1575
2486
  effect((_p$) => {
1576
- var _v$ = props.fg, _v$2 = props.muted, _v$3 = props.muted, _v$4 = draftDirty(props.draft()) ? props.warn ?? props.fg : props.muted, _v$5 = props.muted;
1577
- _v$ !== _p$.e && (_p$.e = setProp(_el$3, "fg", _v$, _p$.e));
1578
- _v$2 !== _p$.t && (_p$.t = setProp(_el$5, "fg", _v$2, _p$.t));
1579
- _v$3 !== _p$.a && (_p$.a = setProp(_el$7, "fg", _v$3, _p$.a));
1580
- _v$4 !== _p$.o && (_p$.o = setProp(_el$0, "fg", _v$4, _p$.o));
1581
- _v$5 !== _p$.i && (_p$.i = setProp(_el$1, "fg", _v$5, _p$.i));
2487
+ var _v$5 = props.fg, _v$6 = { fg: props.muted }, _v$7 = props.muted;
2488
+ _v$5 !== _p$.e && (_p$.e = setProp(_el$3, "fg", _v$5, _p$.e));
2489
+ _v$6 !== _p$.t && (_p$.t = setProp(_el$6, "style", _v$6, _p$.t));
2490
+ _v$7 !== _p$.a && (_p$.a = setProp(_el$0, "fg", _v$7, _p$.a));
1582
2491
  return _p$;
1583
2492
  }, {
1584
2493
  e: void 0,
1585
2494
  t: void 0,
1586
- a: void 0,
1587
- o: void 0,
1588
- i: void 0
2495
+ a: void 0
1589
2496
  });
1590
2497
  return _el$;
1591
2498
  })();
1592
2499
  }
1593
2500
  let pageApi;
1594
2501
  function createWindowController(context, exit) {
2502
+ const currentVersion = resolveRunningVersion();
1595
2503
  const [page, setPage] = createSignal(0);
1596
2504
  const [selected, setSelected] = createSignal(0);
1597
2505
  const [load, setLoad] = createSignal(readOverridesLoad());
@@ -1600,11 +2508,34 @@ function createWindowController(context, exit) {
1600
2508
  const [budgets, setBudgets] = createSignal(readDecisionBudgets());
1601
2509
  const [autonomyRestartPending, setAutonomyRestartPending] = createSignal(false);
1602
2510
  const [presetTick, setPresetTick] = createSignal(0);
2511
+ const [selectedChannel, setSelectedChannel] = createSignal(updateChannelFor(currentVersion));
1603
2512
  const [lastChecked, setLastChecked] = createSignal(void 0);
1604
2513
  const [checking, setChecking] = createSignal(false);
2514
+ const [updating, setUpdating] = createSignal(false);
2515
+ const [changelogItems, setChangelogItems] = createSignal([]);
1605
2516
  const [draft, setDraft] = createSignal({});
1606
2517
  const [notice, setNotice] = createSignal(void 0);
1607
- const currentVersion = resolveRunningVersion$1();
2518
+ const [confirmExit, setConfirmExit] = createSignal(false);
2519
+ createEffect(() => {
2520
+ setTuiDraftPreview(draft());
2521
+ });
2522
+ readChangelogForBundle(import.meta.url).then((text) => {
2523
+ if (!text) return;
2524
+ const hl = extractHighlights(text, currentVersion);
2525
+ if (hl.found) {
2526
+ const items = [];
2527
+ for (const group of hl.groups) for (const item of group.items) {
2528
+ const dash = item.indexOf("—");
2529
+ const title = dash !== -1 ? item.slice(0, dash).trim() : item.slice(0, 26);
2530
+ items.push({
2531
+ title,
2532
+ detail: item,
2533
+ group: group.heading ?? void 0
2534
+ });
2535
+ }
2536
+ setChangelogItems(items);
2537
+ }
2538
+ });
1608
2539
  const presetInput = () => {
1609
2540
  presetTick();
1610
2541
  return {
@@ -1616,7 +2547,9 @@ function createWindowController(context, exit) {
1616
2547
  const input = {
1617
2548
  currentVersion,
1618
2549
  state: readUpdateCheckState(),
2550
+ selectedChannel: selectedChannel(),
1619
2551
  checking: checking(),
2552
+ updating: updating(),
1620
2553
  nowMs: Date.now()
1621
2554
  };
1622
2555
  const seen = lastChecked();
@@ -1625,9 +2558,9 @@ function createWindowController(context, exit) {
1625
2558
  };
1626
2559
  const tabs = () => [
1627
2560
  buildGatesTab(load()),
1628
- buildDecisionTab(decision()),
2561
+ buildDecisionTab(decision(), process.env, readAuthProviders(), readConfigProviders()),
1629
2562
  buildPresetTab(presetInput()),
1630
- buildTuiTab(tuiPrefs()),
2563
+ buildTuiTab(savedTuiPrefs()),
1631
2564
  buildAutonomyTab({
1632
2565
  goalLoop: goalLoop(),
1633
2566
  budgets: budgets(),
@@ -1635,6 +2568,7 @@ function createWindowController(context, exit) {
1635
2568
  }),
1636
2569
  buildJ1Tab(process.env, false),
1637
2570
  buildUpdatesTab(updatesInput()),
2571
+ buildChangelogTab(currentVersion, changelogItems()),
1638
2572
  buildDoctorTab({
1639
2573
  runningVersion: currentVersion,
1640
2574
  nodeVersion: process.versions.node,
@@ -1644,26 +2578,70 @@ function createWindowController(context, exit) {
1644
2578
  ];
1645
2579
  const rows = () => tabRows(tabs()[page()] ?? tabs()[0] ?? EMPTY_TAB);
1646
2580
  const move = (delta) => {
2581
+ if (confirmExit()) setConfirmExit(false);
1647
2582
  const list = rows();
1648
2583
  if (list.length === 0) return;
1649
2584
  setSelected((current) => Math.min(Math.max(current + delta, 0), list.length - 1));
1650
2585
  };
1651
2586
  const step = (direction) => {
2587
+ if (confirmExit()) setConfirmExit(false);
1652
2588
  const row = rows()[selected()];
1653
2589
  if (row === void 0) return;
1654
2590
  setNotice(void 0);
1655
2591
  setDraft(stageValue(draft(), row, direction));
1656
2592
  };
1657
- const checkUpdatesNow = () => {
2593
+ const checkUpdatesNow = (targetChannel = selectedChannel()) => {
1658
2594
  if (checking()) return;
1659
2595
  setChecking(true);
1660
2596
  setNotice(void 0);
1661
- fetchLatestForChannel(currentVersion).then((latest) => {
1662
- if (latest) setLastChecked(latest);
1663
- persistUpdateCheckState(readUpdateCheckState(), latest);
2597
+ fetchLatestForChannel(targetChannel).then((latest) => {
2598
+ if (latest) {
2599
+ setLastChecked(latest);
2600
+ persistUpdateCheckState(readUpdateCheckState(), latest);
2601
+ }
1664
2602
  }).catch(() => {}).finally(() => setChecking(false));
1665
2603
  };
2604
+ const runUpdateNow = () => {
2605
+ if (updating()) return;
2606
+ setUpdating(true);
2607
+ setNotice(`updating to ${selectedChannel()} channel…`);
2608
+ execFile("npm", [
2609
+ "install",
2610
+ "-g",
2611
+ `pantheon-opencode@${selectedChannel()}`
2612
+ ], { timeout: 6e4 }, (err) => {
2613
+ setUpdating(false);
2614
+ if (err) {
2615
+ setNotice("run in terminal: pantheon-opencode update");
2616
+ try {
2617
+ context.ui.toast?.show?.({
2618
+ variant: "warning",
2619
+ message: "Update requires terminal permissions: run `pantheon-opencode update`"
2620
+ });
2621
+ } catch {}
2622
+ } else {
2623
+ setNotice("[OK] update complete — restart OpenCode or run `npx pantheon-opencode init`");
2624
+ try {
2625
+ context.ui.toast?.show?.({
2626
+ variant: "info",
2627
+ message: "Pantheon updated successfully!"
2628
+ });
2629
+ } catch {}
2630
+ }
2631
+ });
2632
+ };
1666
2633
  const dispatchWrite = (id, value) => {
2634
+ if (id === "update.channel") {
2635
+ if (value === "stable" || value === "beta") {
2636
+ setSelectedChannel(value);
2637
+ checkUpdatesNow(value);
2638
+ return { ok: true };
2639
+ }
2640
+ return {
2641
+ ok: false,
2642
+ reason: "unknown channel"
2643
+ };
2644
+ }
1667
2645
  if (id.startsWith("gate.")) {
1668
2646
  if (!canWriteOverrides(load())) return {
1669
2647
  ok: false,
@@ -1828,21 +2806,38 @@ function createWindowController(context, exit) {
1828
2806
  setPresetTick((tick) => tick + 1);
1829
2807
  }
1830
2808
  if (failed.length > 0) setNotice(`${failed.map((f) => `${f.id}: ${f.reason}`).join(" · ")} — staged changes kept`);
1831
- else setNotice(`saved ${applied.length} change${applied.length === 1 ? "" : "s"}`);
2809
+ else {
2810
+ setNotice(`saved ${applied.length} change${applied.length === 1 ? "" : "s"}`);
2811
+ if (confirmExit()) exit();
2812
+ }
1832
2813
  };
1833
2814
  const resetPage = () => {
2815
+ if (confirmExit()) setConfirmExit(false);
1834
2816
  const tab = tabs()[page()];
1835
2817
  if (tab === void 0) return;
1836
2818
  setDraft(resetTab(draft(), tab));
1837
2819
  setNotice(void 0);
1838
2820
  };
2821
+ const stageDefaultsPage = () => {
2822
+ if (confirmExit()) setConfirmExit(false);
2823
+ const tab = tabs()[page()];
2824
+ if (tab === void 0) return;
2825
+ setNotice(void 0);
2826
+ setDraft(stageDefaults(draft(), tab));
2827
+ };
1839
2828
  const nextTab = () => {
2829
+ if (confirmExit()) setConfirmExit(false);
1840
2830
  setPage((current) => (current + 1) % tabs().length);
1841
2831
  setSelected(0);
1842
2832
  };
1843
2833
  const close = () => {
1844
2834
  const staged = draftCount(draft());
2835
+ if (staged > 0 && !confirmExit()) {
2836
+ setConfirmExit(true);
2837
+ return;
2838
+ }
1845
2839
  if (staged > 0) {
2840
+ clearTuiDraftPreview();
1846
2841
  setDraft({});
1847
2842
  try {
1848
2843
  context.ui.toast?.show?.({
@@ -1853,21 +2848,73 @@ function createWindowController(context, exit) {
1853
2848
  }
1854
2849
  exit();
1855
2850
  };
2851
+ const discard = () => {
2852
+ const staged = draftCount(draft());
2853
+ clearTuiDraftPreview();
2854
+ setDraft({});
2855
+ setConfirmExit(false);
2856
+ if (staged > 0) try {
2857
+ context.ui.toast?.show?.({
2858
+ variant: "info",
2859
+ message: `settings: ${staged} staged change${staged === 1 ? "" : "s"} discarded`
2860
+ });
2861
+ } catch {}
2862
+ exit();
2863
+ };
2864
+ const cancelExit = () => {
2865
+ setConfirmExit(false);
2866
+ };
2867
+ const selectedId = () => rows()[selected()]?.id;
2868
+ const selectById = (id) => {
2869
+ if (confirmExit()) setConfirmExit(false);
2870
+ const index = rows().findIndex((r) => r.id === id);
2871
+ if (index !== -1) setSelected(index);
2872
+ };
2873
+ const cycleRowById = (id, direction) => {
2874
+ if (confirmExit()) setConfirmExit(false);
2875
+ const list = rows();
2876
+ const index = list.findIndex((r) => r.id === id);
2877
+ if (index !== -1) {
2878
+ setSelected(index);
2879
+ const row = list[index];
2880
+ if (row?.action === "update-check") checkUpdatesNow();
2881
+ else if (row?.action === "update-run") runUpdateNow();
2882
+ else if (row) {
2883
+ setNotice(void 0);
2884
+ setDraft(stageValue(draft(), row, direction));
2885
+ }
2886
+ }
2887
+ };
1856
2888
  return {
1857
2889
  tabs,
1858
2890
  page,
1859
- selected,
2891
+ selectedId,
1860
2892
  draft,
1861
2893
  notice,
2894
+ confirmExit: () => confirmExit(),
1862
2895
  api: {
1863
2896
  move,
1864
2897
  step,
2898
+ selectById,
2899
+ cycleRowById,
1865
2900
  actuate: () => {
1866
- if (rows()[selected()]?.action === "update-check") checkUpdatesNow();
2901
+ if (confirmExit()) setConfirmExit(false);
2902
+ const row = rows()[selected()];
2903
+ if (row?.action === "update-check") checkUpdatesNow();
2904
+ else if (row?.action === "update-run") runUpdateNow();
1867
2905
  else step(1);
1868
2906
  },
1869
2907
  nextTab,
2908
+ prevTab: () => {
2909
+ if (confirmExit()) setConfirmExit(false);
2910
+ const count = tabs().length;
2911
+ if (count > 0) {
2912
+ setPage((current) => (current - 1 + count) % count);
2913
+ setSelected(0);
2914
+ }
2915
+ },
1870
2916
  jumpTab: (index) => {
2917
+ if (confirmExit()) setConfirmExit(false);
1871
2918
  if (index >= 0 && index < tabs().length) {
1872
2919
  setPage(index);
1873
2920
  setSelected(0);
@@ -1875,9 +2922,14 @@ function createWindowController(context, exit) {
1875
2922
  },
1876
2923
  save,
1877
2924
  resetPage,
1878
- close
2925
+ stageDefaults: stageDefaultsPage,
2926
+ close,
2927
+ discard,
2928
+ cancelExit,
2929
+ confirmExit: () => confirmExit()
1879
2930
  },
1880
2931
  cleanup: () => {
2932
+ clearTuiDraftPreview();
1881
2933
  pageApi = void 0;
1882
2934
  setBlocking(false);
1883
2935
  }
@@ -1898,7 +2950,7 @@ function SettingsPage(props) {
1898
2950
  pageApi = controller.api;
1899
2951
  return createComponent(SettingsWindow, {
1900
2952
  get version() {
1901
- return resolveRunningVersion$1();
2953
+ return resolveRunningVersion();
1902
2954
  },
1903
2955
  get tabs() {
1904
2956
  return controller.tabs;
@@ -1906,8 +2958,8 @@ function SettingsPage(props) {
1906
2958
  get page() {
1907
2959
  return controller.page;
1908
2960
  },
1909
- get selected() {
1910
- return controller.selected;
2961
+ get selectedId() {
2962
+ return controller.selectedId;
1911
2963
  },
1912
2964
  get draft() {
1913
2965
  return controller.draft;
@@ -1915,23 +2967,30 @@ function SettingsPage(props) {
1915
2967
  get notice() {
1916
2968
  return controller.notice;
1917
2969
  },
2970
+ get confirmExit() {
2971
+ return controller.confirmExit;
2972
+ },
1918
2973
  get fg() {
1919
2974
  return theme.base;
1920
2975
  },
1921
2976
  get muted() {
1922
2977
  return theme.muted;
1923
2978
  },
1924
- warn
2979
+ warn,
2980
+ onJumpTab: (idx) => controller.api.jumpTab(idx),
2981
+ onSelectRow: (id) => controller.api.selectById?.(id),
2982
+ onCycleValue: (id, dir) => controller.api.cycleRowById?.(id, dir),
2983
+ onSave: () => controller.api.save(),
2984
+ onResetPage: () => controller.api.resetPage(),
2985
+ onStageDefaults: () => controller.api.stageDefaults(),
2986
+ onClose: () => controller.api.close(),
2987
+ onDiscard: () => controller.api.discard?.(),
2988
+ onCancelExit: () => controller.api.cancelExit?.()
1925
2989
  });
1926
2990
  }
1927
2991
  function navigateBack(context, data) {
1928
2992
  try {
1929
- const destination = data?.returnRoute ?? { type: "home" };
1930
- context.ui.toast?.show?.({
1931
- variant: "info",
1932
- message: `settings: navigating ${JSON.stringify(destination)}`
1933
- });
1934
- context.ui.router.navigate(destination);
2993
+ context.ui.router.navigate(data?.returnRoute ?? { type: "home" });
1935
2994
  } catch {}
1936
2995
  }
1937
2996
  const [dialogOpen, setDialogOpen] = createSignal(false);
@@ -1957,10 +3016,12 @@ function openSettingsDialog(context) {
1957
3016
  setBlocking(true);
1958
3017
  setDialogOpen(true);
1959
3018
  pageApi = controller.api;
3019
+ const rendererHeight = () => context.renderer?.height ?? 30;
3020
+ const maxHeight = () => Math.min(16, Math.max(8, Math.floor(rendererHeight() * .55)));
1960
3021
  try {
1961
3022
  context.ui.dialog.show(() => createComponent(SettingsWindow, {
1962
3023
  get version() {
1963
- return resolveRunningVersion$1();
3024
+ return resolveRunningVersion();
1964
3025
  },
1965
3026
  get tabs() {
1966
3027
  return controller.tabs;
@@ -1968,8 +3029,8 @@ function openSettingsDialog(context) {
1968
3029
  get page() {
1969
3030
  return controller.page;
1970
3031
  },
1971
- get selected() {
1972
- return controller.selected;
3032
+ get selectedId() {
3033
+ return controller.selectedId;
1973
3034
  },
1974
3035
  get draft() {
1975
3036
  return controller.draft;
@@ -1977,16 +3038,180 @@ function openSettingsDialog(context) {
1977
3038
  get notice() {
1978
3039
  return controller.notice;
1979
3040
  },
3041
+ get confirmExit() {
3042
+ return controller.confirmExit;
3043
+ },
1980
3044
  get fg() {
1981
3045
  return theme.base;
1982
3046
  },
1983
3047
  get muted() {
1984
3048
  return theme.muted;
1985
3049
  },
1986
- warn
3050
+ warn,
3051
+ isDialog: true,
3052
+ get maxHeight() {
3053
+ return maxHeight();
3054
+ },
3055
+ onJumpTab: (idx) => controller.api.jumpTab(idx),
3056
+ onSelectRow: (id) => controller.api.selectById?.(id),
3057
+ onCycleValue: (id, dir) => controller.api.cycleRowById?.(id, dir),
3058
+ onSave: () => controller.api.save(),
3059
+ onResetPage: () => controller.api.resetPage(),
3060
+ onStageDefaults: () => controller.api.stageDefaults(),
3061
+ onClose: () => controller.api.close(),
3062
+ onDiscard: () => controller.api.discard?.(),
3063
+ onCancelExit: () => controller.api.cancelExit?.()
1987
3064
  }), close);
3065
+ context.ui.dialog.set({ size: "large" });
1988
3066
  } catch {}
1989
3067
  }
3068
+ const [settingsOpen, setSettingsOpen] = createSignal(false);
3069
+ const [activeSessionId, setActiveSessionId] = createSignal();
3070
+ function routeSessionID(context) {
3071
+ try {
3072
+ const route = context?.ui?.router?.current?.();
3073
+ return route?.type === "session" ? route?.sessionID : void 0;
3074
+ } catch {
3075
+ return;
3076
+ }
3077
+ }
3078
+ function closePantheonSettings() {
3079
+ if (pageApi) {
3080
+ pageApi.close();
3081
+ if (pageApi.confirmExit?.()) return;
3082
+ }
3083
+ setSettingsOpen(false);
3084
+ setBlocking(false);
3085
+ }
3086
+ function PantheonSettingsSlot(props) {
3087
+ onMount(() => {
3088
+ setActiveSessionId(props.sessionID);
3089
+ });
3090
+ onCleanup(() => {
3091
+ if (activeSessionId() === props.sessionID) setActiveSessionId(void 0);
3092
+ });
3093
+ return createComponent(Show, {
3094
+ get when() {
3095
+ return memo(() => !!settingsOpen())() && (activeSessionId() === props.sessionID || !activeSessionId());
3096
+ },
3097
+ get children() {
3098
+ return createComponent(InSessionSettingsWindow, {
3099
+ get context() {
3100
+ return props.context;
3101
+ },
3102
+ get sessionID() {
3103
+ return props.sessionID;
3104
+ }
3105
+ });
3106
+ }
3107
+ });
3108
+ }
3109
+ function InSessionSettingsWindow(props) {
3110
+ let windowBox;
3111
+ const context = props.context;
3112
+ const initialRoom = () => Math.max(14, (context.renderer?.height ?? 30) - 10);
3113
+ const [roomHeight, setRoomHeight] = createSignal(initialRoom());
3114
+ const [hasKeyboard, setHasKeyboard] = createSignal(false);
3115
+ function measureRoom() {
3116
+ const box = windowBox;
3117
+ if (!box || box.isDestroyed) return;
3118
+ let child = box;
3119
+ for (let parent = box.parent; parent; child = parent, parent = parent.parent) {
3120
+ const siblings = parent.getChildren?.() ?? [];
3121
+ const messages = siblings[0];
3122
+ if (messages === child || !messages?.getChildren?.().some((item) => "scrollChildIntoView" in item)) continue;
3123
+ const otherRows = siblings.filter((item) => item !== child && item !== messages).reduce((total, item) => total + (item.height ?? 0), 0);
3124
+ const room = Math.max(12, (parent.height ?? 24) - 1 - otherRows - ((child.height ?? 0) - (box.height ?? 0)));
3125
+ if (room !== roomHeight()) queueMicrotask(() => setRoomHeight(room));
3126
+ return;
3127
+ }
3128
+ }
3129
+ onMount(() => {
3130
+ try {
3131
+ context.renderer?.root?.on?.("layout-changed", measureRoom);
3132
+ context.renderer?.on?.("resize", measureRoom);
3133
+ onCleanup(() => {
3134
+ try {
3135
+ context.renderer?.root?.off?.("layout-changed", measureRoom);
3136
+ context.renderer?.off?.("resize", measureRoom);
3137
+ } catch {}
3138
+ });
3139
+ } catch {}
3140
+ measureRoom();
3141
+ setTimeout(() => {
3142
+ try {
3143
+ windowBox?.focus?.();
3144
+ } catch {}
3145
+ }, 50);
3146
+ });
3147
+ try {
3148
+ const popMode = context.keymap?.mode?.push?.(ROUTE_MODE);
3149
+ if (popMode !== void 0) onCleanup(() => popMode());
3150
+ } catch {}
3151
+ const controller = createWindowController(context, () => {
3152
+ setSettingsOpen(false);
3153
+ setBlocking(false);
3154
+ });
3155
+ onCleanup(controller.cleanup);
3156
+ pageApi = controller.api;
3157
+ const theme = context.theme?.text ?? {};
3158
+ const warn = theme?.feedback?.warning?.base ?? "#fba970";
3159
+ return createComponent(SettingsWindow, {
3160
+ boxRef: (el) => {
3161
+ windowBox = el;
3162
+ if (el) {
3163
+ el.on?.("focused", () => setHasKeyboard(true));
3164
+ el.on?.("blurred", () => setHasKeyboard(false));
3165
+ }
3166
+ },
3167
+ get height() {
3168
+ return roomHeight();
3169
+ },
3170
+ get version() {
3171
+ return resolveRunningVersion();
3172
+ },
3173
+ get tabs() {
3174
+ return controller.tabs;
3175
+ },
3176
+ get page() {
3177
+ return controller.page;
3178
+ },
3179
+ get selectedId() {
3180
+ return controller.selectedId;
3181
+ },
3182
+ get draft() {
3183
+ return controller.draft;
3184
+ },
3185
+ get notice() {
3186
+ return controller.notice;
3187
+ },
3188
+ get confirmExit() {
3189
+ return controller.confirmExit;
3190
+ },
3191
+ get fg() {
3192
+ return theme.base;
3193
+ },
3194
+ get muted() {
3195
+ return theme.muted;
3196
+ },
3197
+ warn,
3198
+ hasKeyboard,
3199
+ onJumpTab: (idx) => controller.api.jumpTab(idx),
3200
+ onSelectRow: (id) => controller.api.selectById?.(id),
3201
+ onCycleValue: (id, dir) => controller.api.cycleRowById?.(id, dir),
3202
+ onSave: () => controller.api.save(),
3203
+ onResetPage: () => controller.api.resetPage(),
3204
+ onStageDefaults: () => controller.api.stageDefaults(),
3205
+ onClose: () => closePantheonSettings(),
3206
+ onDiscard: () => controller.api.discard?.(),
3207
+ onCancelExit: () => controller.api.cancelExit?.(),
3208
+ onMouseDown: () => {
3209
+ try {
3210
+ windowBox?.focus?.();
3211
+ } catch {}
3212
+ }
3213
+ });
3214
+ }
1990
3215
  function setupPantheonSettings(context) {
1991
3216
  try {
1992
3217
  context.ui.router?.register?.({
@@ -2014,22 +3239,26 @@ function setupPantheonSettings(context) {
2014
3239
  title: "Close settings",
2015
3240
  bind: "escape,q",
2016
3241
  run: () => {
2017
- try {
2018
- context.ui.toast?.show?.({
2019
- variant: "info",
2020
- message: "settings: close command fired"
2021
- });
2022
- } catch {}
2023
3242
  if (pageApi === void 0) {
2024
- try {
2025
- context.ui.toast?.show?.({
2026
- variant: "warning",
2027
- message: "settings: no window controller bound"
2028
- });
2029
- } catch {}
3243
+ closePantheonSettings();
3244
+ return;
3245
+ }
3246
+ if (pageApi.confirmExit?.()) {
3247
+ pageApi.cancelExit?.();
3248
+ return;
3249
+ }
3250
+ closePantheonSettings();
3251
+ }
3252
+ },
3253
+ {
3254
+ id: "pantheon.settings.discard",
3255
+ title: "Discard staged changes and exit",
3256
+ bind: "d",
3257
+ run: () => {
3258
+ if (pageApi?.confirmExit?.()) {
3259
+ pageApi.discard?.();
2030
3260
  return;
2031
3261
  }
2032
- pageApi.close();
2033
3262
  }
2034
3263
  },
2035
3264
  {
@@ -2080,6 +3309,14 @@ function setupPantheonSettings(context) {
2080
3309
  pageApi?.nextTab();
2081
3310
  }
2082
3311
  },
3312
+ {
3313
+ id: "pantheon.settings.prev.tab",
3314
+ title: "Previous settings tab",
3315
+ bind: "shift+tab",
3316
+ run: () => {
3317
+ pageApi?.prevTab?.();
3318
+ }
3319
+ },
2083
3320
  {
2084
3321
  id: "pantheon.settings.save",
2085
3322
  title: "Save staged changes",
@@ -2096,6 +3333,14 @@ function setupPantheonSettings(context) {
2096
3333
  pageApi?.resetPage();
2097
3334
  }
2098
3335
  },
3336
+ {
3337
+ id: "pantheon.settings.defaults",
3338
+ title: "Stage defaults for this tab",
3339
+ bind: "ctrl+d",
3340
+ run: () => {
3341
+ pageApi?.stageDefaults();
3342
+ }
3343
+ },
2099
3344
  ...Array.from({ length: 9 }, (_, index) => ({
2100
3345
  id: `pantheon.settings.tab.${index + 1}`,
2101
3346
  title: `Jump to tab ${index + 1}`,
@@ -2109,7 +3354,7 @@ function setupPantheonSettings(context) {
2109
3354
  context.keymap.layer(() => ({
2110
3355
  mode: ROUTE_MODE,
2111
3356
  priority: 1,
2112
- enabled: () => routeGated(),
3357
+ enabled: () => routeGated() || settingsOpen(),
2113
3358
  commands
2114
3359
  }));
2115
3360
  } catch {}
@@ -2117,14 +3362,15 @@ function setupPantheonSettings(context) {
2117
3362
  context.keymap.layer(() => ({
2118
3363
  mode: "global",
2119
3364
  priority: 1,
2120
- enabled: () => dialogOpen(),
3365
+ enabled: () => dialogOpen() || settingsOpen(),
2121
3366
  commands
2122
3367
  }));
2123
3368
  } catch {}
2124
3369
  }
2125
3370
  async function openPantheonSettings(context) {
2126
3371
  try {
2127
- if (routerAvailable && context.ui?.router?.navigate) {
3372
+ const viewMode = tuiPrefs().layout?.settingsView ?? "docked";
3373
+ if (viewMode === "fullscreen" && routerAvailable && context.ui?.router?.navigate) {
2128
3374
  let returnRoute;
2129
3375
  try {
2130
3376
  const current = context.ui.router.current();
@@ -2139,8 +3385,27 @@ async function openPantheonSettings(context) {
2139
3385
  });
2140
3386
  return;
2141
3387
  }
3388
+ if (viewMode === "dialog") {
3389
+ openSettingsDialog(context);
3390
+ return;
3391
+ }
2142
3392
  } catch {}
2143
- openSettingsDialog(context);
3393
+ if (!(context?.sessionID ?? routeSessionID(context) ?? activeSessionId())) {
3394
+ try {
3395
+ context.ui?.toast?.show?.({
3396
+ variant: "info",
3397
+ title: "Pantheon",
3398
+ message: "Open a session first: Pantheon settings opens above the prompt box."
3399
+ });
3400
+ } catch {}
3401
+ return;
3402
+ }
3403
+ if (settingsOpen()) {
3404
+ closePantheonSettings();
3405
+ return;
3406
+ }
3407
+ setSettingsOpen(true);
3408
+ setBlocking(true);
2144
3409
  }
2145
3410
  //#endregion
2146
3411
  //#region src/sidebar-width.ts
@@ -2264,214 +3529,6 @@ function cellWidth(value) {
2264
3529
  for (const { segment } of GRAPHEMES.segment(value)) width += graphemeWidth(segment);
2265
3530
  return width;
2266
3531
  }
2267
- /** Prefix of the "+N more" line appended when the bullet budget is exceeded. */
2268
- const WHATS_NEW_MORE_PREFIX = "… +";
2269
- const EMPTY_HIGHLIGHTS = {
2270
- version: null,
2271
- found: false,
2272
- groups: [],
2273
- totalItems: 0,
2274
- truncated: false
2275
- };
2276
- /** Escape regex metacharacters so a version like 1.0.0 matches literally. */
2277
- function escapeRegExp(text) {
2278
- return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2279
- }
2280
- /**
2281
- * Extract the body of a version section from changelog text — inline replica
2282
- * of scripts/changelog-extract.mjs `extractSection` (see that file for the
2283
- * full contract: `## [<version>] - YYYY-MM-DD`, leading `v` and the date
2284
- * optional, `## [Unreleased]` never matched).
2285
- */
2286
- function extractSection(changelogText, version) {
2287
- const normalized = String(version).trim().replace(/^v/i, "");
2288
- if (!normalized || /^unreleased$/i.test(normalized)) return {
2289
- found: false,
2290
- body: null
2291
- };
2292
- const escaped = escapeRegExp(normalized);
2293
- const match = new RegExp(`^##[ \\t]+\\[v?${escaped}\\](?:[ \\t]*-[ \\t]*\\d{4}-\\d{2}-\\d{2})?(?=[ \\t]|$)`, "m").exec(changelogText);
2294
- if (!match) return {
2295
- found: false,
2296
- body: null
2297
- };
2298
- const newline = changelogText.indexOf("\n", match.index);
2299
- const start = newline === -1 ? changelogText.length : newline + 1;
2300
- const nextHeading = /^##[ \t]+\[/m.exec(changelogText.slice(start));
2301
- const end = nextHeading ? start + nextHeading.index : changelogText.length;
2302
- return {
2303
- found: true,
2304
- body: changelogText.slice(start, end).trim()
2305
- };
2306
- }
2307
- /**
2308
- * Reduce one markdown line to plain text: links keep their label, emphasis
2309
- * and inline-code markers are dropped, HTML comment fragments are removed,
2310
- * and whitespace collapses. Deliberately simple — the input is our own
2311
- * CHANGELOG (lint-capped at 200 chars per bullet), not hostile input.
2312
- */
2313
- function stripMarkdown(text) {
2314
- return text.replace(/<!--[\s\S]*?-->/g, " ").replace(/\[([^\]]+)\]\([^)]*\)/g, "$1").replace(/(\*\*|__)/g, "").replace(/`/g, "").replace(/\s+/g, " ").trim();
2315
- }
2316
- /** Strip the leading H3 marker (`### Added` → `Added`). */
2317
- function stripHeading(text) {
2318
- return text.replace(/^#{1,6}[ \t]+/, "").trim();
2319
- }
2320
- /**
2321
- * Extract the curated summary block (`### 🆕 What's New` or `## 🆕 What's New`)
2322
- * from a section body: its bullets only, each truncated to
2323
- * WHATS_NEW_ITEM_MAX_CHARS, capped to WHATS_NEW_SUMMARY_MAX_ITEMS. Null when
2324
- * the section carries no summary block (the full-section fallback applies).
2325
- */
2326
- function extractWhatsNewSummary(body) {
2327
- const lines = body.split("\n");
2328
- const start = lines.findIndex((line) => /^#{2,3}[ \t]+.*What'?s New/i.test(line.trim()));
2329
- if (start === -1) return null;
2330
- const items = [];
2331
- for (const rawLine of lines.slice(start + 1)) {
2332
- const line = rawLine.trim();
2333
- if (line === "" || line.startsWith("<!--")) continue;
2334
- if (/^#{1,6}[ \t]/.test(line)) break;
2335
- if (!/^[-*][ \t]/.test(line)) continue;
2336
- if (items.length >= 6) break;
2337
- const content = stripMarkdown(line.replace(/^[-*][ \t]+/, ""));
2338
- if (content === "") continue;
2339
- items.push(content.length > 140 ? `${content.slice(0, 139)}…` : content);
2340
- }
2341
- return items.length > 0 ? items : null;
2342
- }
2343
- /**
2344
- * Extract the release highlights for `version`. When the section carries a
2345
- * curated `🆕 What's New` summary block, THE WINDOW SHOWS ONLY THAT (the
2346
- * full Added/Changed/Fixed walls are for the CHANGELOG readers, not the
2347
- * dialog); otherwise it falls back to the H3-group extraction bounded to
2348
- * WHATS_NEW_MAX_ITEMS bullets. A missing section, a bullet-less section or a
2349
- * blank changelog all return EMPTY_HIGHLIGHTS (no window).
2350
- */
2351
- function extractHighlights(changelogText, version) {
2352
- const { found, body } = extractSection(changelogText ?? "", version ?? "");
2353
- if (!found || !body) return { ...EMPTY_HIGHLIGHTS };
2354
- const summary = extractWhatsNewSummary(body);
2355
- if (summary !== null) return {
2356
- version: String(version).trim().replace(/^v/i, ""),
2357
- found: true,
2358
- groups: [{
2359
- heading: null,
2360
- items: summary
2361
- }],
2362
- totalItems: summary.length,
2363
- truncated: false
2364
- };
2365
- const groups = [];
2366
- let totalItems = 0;
2367
- let truncated = false;
2368
- for (const rawLine of body.split("\n")) {
2369
- const line = rawLine.trim();
2370
- if (line === "" || line.startsWith("<!--")) continue;
2371
- if (/^#{1,6}[ \t]/.test(line)) {
2372
- const heading = stripMarkdown(stripHeading(line));
2373
- if (heading === "") continue;
2374
- if (groups.at(-1)?.items.length === 0) groups.pop();
2375
- groups.push({
2376
- heading,
2377
- items: []
2378
- });
2379
- continue;
2380
- }
2381
- if (totalItems >= 12) {
2382
- if (/^[-*][ \t]/.test(line)) totalItems += 1;
2383
- continue;
2384
- }
2385
- const isBullet = /^[-*][ \t]/.test(line);
2386
- const continuation = (groups.at(-1)?.items.length ?? 0) > 0;
2387
- if (!isBullet && !continuation) continue;
2388
- const content = stripMarkdown(isBullet ? line.replace(/^[-*][ \t]+/, "") : line);
2389
- if (content === "") continue;
2390
- const bounded = content.length > 140 ? `${content.slice(0, 139)}…` : content;
2391
- const group = groups.at(-1);
2392
- if (group === void 0) groups.push({
2393
- heading: null,
2394
- items: [bounded]
2395
- });
2396
- else if (isBullet || group.items.length === 0) group.items.push(bounded);
2397
- else group.items[group.items.length - 1] = `${group.items.at(-1)} ${bounded}`.trim();
2398
- if (isBullet) totalItems += 1;
2399
- }
2400
- const kept = groups.filter((group) => group.items.length > 0);
2401
- truncated = totalItems > 12;
2402
- return {
2403
- version: found ? String(version).trim().replace(/^v/i, "") : null,
2404
- found,
2405
- groups: kept,
2406
- totalItems,
2407
- truncated
2408
- };
2409
- }
2410
- /** Window title — mirrors the sidebar's `Pantheon v<version>` convention. */
2411
- function whatsNewTitle(version) {
2412
- return `O que há de novo — Pantheon v${String(version).trim().replace(/^v/i, "")}`;
2413
- }
2414
- /** Flat display lines for the window: group headings, `• ` bullets, `+N more`. */
2415
- function whatsNewLines(highlights) {
2416
- const lines = [];
2417
- for (const group of highlights.groups) {
2418
- if (group.heading !== null) lines.push(group.heading);
2419
- for (const item of group.items) lines.push(`• ${item}`);
2420
- }
2421
- if (highlights.truncated) {
2422
- const hidden = Math.max(0, highlights.totalItems - 12);
2423
- if (hidden > 0) lines.push(`${WHATS_NEW_MORE_PREFIX}${hidden} mais`);
2424
- }
2425
- return lines;
2426
- }
2427
- /**
2428
- * Candidate CHANGELOG.md locations for a bundle, first readable wins:
2429
- * 1. the plugin copy root (`<configDir>/plugins/pantheon-tui/CHANGELOG.md`,
2430
- * shipped by both installers next to package.json);
2431
- * 2. the package root (dev checkout; also an npm-package install when the
2432
- * bundle runs from `<pkg>/src/plugins/tui/dist/`).
2433
- */
2434
- function changelogCandidates(bundlePath) {
2435
- const dist = dirname(bundlePath);
2436
- const copyRoot = dirname(dist);
2437
- const packageRoot = dirname(dirname(dirname(copyRoot)));
2438
- return [join(copyRoot, "CHANGELOG.md"), join(packageRoot, "CHANGELOG.md")];
2439
- }
2440
- /** Read the first existing candidate; null when none is readable (no window). */
2441
- async function readChangelogForBundle(bundleUrl) {
2442
- try {
2443
- const bundlePath = fileURLToPath(bundleUrl);
2444
- for (const candidate of changelogCandidates(bundlePath)) try {
2445
- return await readFile(candidate, "utf8");
2446
- } catch {}
2447
- return null;
2448
- } catch {
2449
- return null;
2450
- }
2451
- }
2452
- /** The ambient build-time version, or null outside a tsdown build. */
2453
- function embeddedVersion() {
2454
- return "2.0.0-beta.6";
2455
- }
2456
- /**
2457
- * Resolve the running Pantheon version for the what's-new window: the plugin
2458
- * copy's own package.json first (the copy root two levels above the bundle,
2459
- * then the package root four levels above — the same legs as the V1 sidebar's
2460
- * detectVersion try 0a/0b), falling back to the tsdown build embed. Null when
2461
- * nothing resolves → no window (fail-open).
2462
- */
2463
- async function resolveRunningVersion(bundleUrl, embedded = embeddedVersion()) {
2464
- try {
2465
- const bundlePath = fileURLToPath(bundleUrl);
2466
- const dist = dirname(bundlePath);
2467
- for (const root of [dirname(dist), dirname(dirname(dirname(dist)))]) try {
2468
- const raw = await readFile(join(root, "package.json"), "utf8");
2469
- const parsed = JSON.parse(raw);
2470
- if (typeof parsed.version === "string" && parsed.version.trim() !== "") return parsed.version;
2471
- } catch {}
2472
- } catch {}
2473
- return embedded;
2474
- }
2475
3532
  //#endregion
2476
3533
  //#region src/whats-new-state.ts
2477
3534
  /**
@@ -2598,10 +3655,10 @@ async function defaultWhatsNewStatePath(env = process.env, home = homedir()) {
2598
3655
  * - never throws on its own inputs; I/O failures inside the state module
2599
3656
  * are fail-open there.
2600
3657
  */
2601
- /** Muted footer hint teaching the dismiss bind (Portuguese, like the sidebar). */
2602
- const WHATS_NEW_CLOSE_HINT = "esc/q fechar";
3658
+ /** Muted footer hint teaching the dismiss bind. */
3659
+ const WHATS_NEW_CLOSE_HINT = "esc/q close";
2603
3660
  /** Hint variant when the highlights span more than one page. */
2604
- const WHATS_NEW_PAGES_HINT = "esc/q fechar · n próxima · p volta";
3661
+ const WHATS_NEW_PAGES_HINT = "esc/q close · n next · p back";
2605
3662
  /** Hard-wrap one display line into rows of at most `width` columns (>= 10). */
2606
3663
  function wrapWhatsNewLine(line, width) {
2607
3664
  const bounded = Number.isInteger(width) && width > 10 ? width : 76;
@@ -2680,54 +3737,154 @@ async function openWhatsNew(input) {
2680
3737
  * CHANGELOG.md, unreadable state, a host API that throws — the window simply
2681
3738
  * does not show (fail-open, like the rest of the plugin).
2682
3739
  */
2683
- /** Window body: title, rule, the current page (wrapped), footer hint. */
3740
+ /** Window body: title, rule, the current page (wrapped), footer action bar with OK button. */
2684
3741
  function WhatsNewContent(props) {
2685
3742
  const rows = () => {
2686
3743
  const current = props.data.pages[Math.min(props.page(), props.pageCount() - 1)] ?? [];
2687
3744
  const wrapped = [];
2688
- for (const line of current) wrapped.push(...wrapWhatsNewLine(line, 76));
3745
+ for (const line of current) wrapped.push(...wrapWhatsNewLine(line, 72));
2689
3746
  return wrapped;
2690
3747
  };
2691
3748
  return (() => {
2692
- var _el$ = createElement("box"), _el$2 = createElement("text"), _el$3 = createElement("text"), _el$5 = createElement("box"), _el$6 = createElement("text");
3749
+ var _el$ = createElement("box"), _el$2 = createElement("box"), _el$3 = createElement("box"), _el$4 = createElement("box"), _el$5 = createElement("text"), _el$7 = createElement("text"), _el$8 = createElement("box"), _el$9 = createElement("text"), _el$1 = createElement("box"), _el$10 = createElement("text"), _el$12 = createElement("box"), _el$13 = createElement("box"), _el$14 = createElement("text"), _el$16 = createElement("box"), _el$17 = createElement("box"), _el$25 = createElement("text"), _el$27 = createElement("box"), _el$28 = createElement("text");
2693
3750
  insertNode(_el$, _el$2);
2694
- insertNode(_el$, _el$3);
2695
- insertNode(_el$, _el$5);
2696
- insertNode(_el$, _el$6);
3751
+ insertNode(_el$, _el$1);
3752
+ insertNode(_el$, _el$12);
3753
+ insertNode(_el$, _el$13);
3754
+ insertNode(_el$, _el$16);
2697
3755
  setProp(_el$, "flexDirection", "column");
2698
- setProp(_el$, "paddingLeft", 1);
2699
- setProp(_el$, "paddingRight", 1);
3756
+ setProp(_el$, "borderStyle", "rounded");
3757
+ setProp(_el$, "paddingLeft", 2);
3758
+ setProp(_el$, "paddingRight", 2);
2700
3759
  setProp(_el$, "paddingTop", 1);
2701
- setProp(_el$2, "attributes", 1);
2702
- insert(_el$2, () => props.data.title);
2703
- insertNode(_el$3, createTextNode(`──────────────────────────────────────`));
2704
- insert(_el$, createComponent(For, {
3760
+ setProp(_el$, "paddingBottom", 1);
3761
+ insertNode(_el$2, _el$3);
3762
+ insertNode(_el$2, _el$8);
3763
+ setProp(_el$2, "flexDirection", "row");
3764
+ setProp(_el$2, "alignItems", "center");
3765
+ setProp(_el$2, "justifyContent", "space-between");
3766
+ insertNode(_el$3, _el$4);
3767
+ insertNode(_el$3, _el$7);
3768
+ setProp(_el$3, "flexDirection", "row");
3769
+ setProp(_el$3, "alignItems", "center");
3770
+ insertNode(_el$4, _el$5);
3771
+ setProp(_el$4, "paddingLeft", 1);
3772
+ setProp(_el$4, "paddingRight", 1);
3773
+ setProp(_el$4, "marginRight", 1);
3774
+ insertNode(_el$5, createTextNode(`NOVIDADES`));
3775
+ setProp(_el$5, "fg", "#000000");
3776
+ setProp(_el$5, "attributes", 1);
3777
+ setProp(_el$7, "attributes", 1);
3778
+ insert(_el$7, () => props.data.title);
3779
+ insertNode(_el$8, _el$9);
3780
+ setProp(_el$8, "onMouseDown", () => props.onClose?.());
3781
+ insertNode(_el$9, createTextNode(`[ Esc / Q ]`));
3782
+ insertNode(_el$1, _el$10);
3783
+ setProp(_el$1, "flexDirection", "row");
3784
+ setProp(_el$1, "height", 1);
3785
+ setProp(_el$1, "marginTop", 1);
3786
+ setProp(_el$1, "marginBottom", 1);
3787
+ insertNode(_el$10, createTextNode(`────────────────────────────────────────────────────────────────────────`));
3788
+ setProp(_el$12, "flexDirection", "column");
3789
+ setProp(_el$12, "minHeight", 8);
3790
+ insert(_el$12, createComponent(For, {
2705
3791
  get each() {
2706
3792
  return rows();
2707
3793
  },
2708
- children: (line) => (() => {
2709
- var _el$7 = createElement("text");
2710
- insert(_el$7, line);
2711
- effect((_$p) => setProp(_el$7, "fg", line.startsWith("• ") ? props.fg : props.muted, _$p));
2712
- return _el$7;
2713
- })()
2714
- }), _el$5);
2715
- setProp(_el$5, "height", 1);
2716
- insert(_el$6, (() => {
2717
- var _c$ = memo(() => props.pageCount() > 1);
2718
- return () => _c$() ? `${props.page() + 1}/${props.pageCount()} · ` : "";
2719
- })(), null);
2720
- insert(_el$6, () => props.data.hint, null);
3794
+ children: (line) => {
3795
+ const isBullet = line.startsWith("• ");
3796
+ return (() => {
3797
+ var _el$30 = createElement("text");
3798
+ spread(_el$30, mergeProps({ get fg() {
3799
+ return isBullet ? props.fg : props.muted;
3800
+ } }, isBullet ? { attributes: 1 } : {}), true);
3801
+ insert(_el$30, line);
3802
+ return _el$30;
3803
+ })();
3804
+ }
3805
+ }));
3806
+ insertNode(_el$13, _el$14);
3807
+ setProp(_el$13, "flexDirection", "row");
3808
+ setProp(_el$13, "height", 1);
3809
+ setProp(_el$13, "marginTop", 1);
3810
+ insertNode(_el$14, createTextNode(`────────────────────────────────────────────────────────────────────────`));
3811
+ insertNode(_el$16, _el$17);
3812
+ insertNode(_el$16, _el$27);
3813
+ setProp(_el$16, "flexDirection", "row");
3814
+ setProp(_el$16, "alignItems", "center");
3815
+ setProp(_el$16, "justifyContent", "space-between");
3816
+ setProp(_el$16, "marginTop", 1);
3817
+ insertNode(_el$17, _el$25);
3818
+ setProp(_el$17, "flexDirection", "row");
3819
+ setProp(_el$17, "alignItems", "center");
3820
+ insert(_el$17, createComponent(Show, {
3821
+ get when() {
3822
+ return props.pageCount() > 1;
3823
+ },
3824
+ get children() {
3825
+ return [
3826
+ (() => {
3827
+ var _el$18 = createElement("box"), _el$19 = createElement("text");
3828
+ insertNode(_el$18, _el$19);
3829
+ setProp(_el$18, "backgroundColor", "#262626");
3830
+ setProp(_el$18, "paddingLeft", 1);
3831
+ setProp(_el$18, "paddingRight", 1);
3832
+ setProp(_el$18, "marginRight", 1);
3833
+ setProp(_el$18, "onMouseDown", () => props.onPrev?.());
3834
+ insertNode(_el$19, createTextNode(`‹ Prev`));
3835
+ setProp(_el$19, "fg", "#ffffff");
3836
+ return _el$18;
3837
+ })(),
3838
+ (() => {
3839
+ var _el$21 = createElement("text");
3840
+ setProp(_el$21, "marginRight", 1);
3841
+ insert(_el$21, () => `${props.page() + 1} / ${props.pageCount()}`);
3842
+ effect((_$p) => setProp(_el$21, "fg", props.muted, _$p));
3843
+ return _el$21;
3844
+ })(),
3845
+ (() => {
3846
+ var _el$22 = createElement("box"), _el$23 = createElement("text");
3847
+ insertNode(_el$22, _el$23);
3848
+ setProp(_el$22, "backgroundColor", "#262626");
3849
+ setProp(_el$22, "paddingLeft", 1);
3850
+ setProp(_el$22, "paddingRight", 1);
3851
+ setProp(_el$22, "marginRight", 1);
3852
+ setProp(_el$22, "onMouseDown", () => props.onNext?.());
3853
+ insertNode(_el$23, createTextNode(`Next ›`));
3854
+ setProp(_el$23, "fg", "#ffffff");
3855
+ return _el$22;
3856
+ })()
3857
+ ];
3858
+ }
3859
+ }), _el$25);
3860
+ insertNode(_el$25, createTextNode(`Enter / Esc / Q close`));
3861
+ insertNode(_el$27, _el$28);
3862
+ setProp(_el$27, "paddingLeft", 2);
3863
+ setProp(_el$27, "paddingRight", 2);
3864
+ setProp(_el$27, "onMouseDown", () => props.onClose?.());
3865
+ insertNode(_el$28, createTextNode(`OK, Got it`));
3866
+ setProp(_el$28, "fg", "#000000");
3867
+ setProp(_el$28, "attributes", 1);
2721
3868
  effect((_p$) => {
2722
- var _v$ = props.fg, _v$2 = props.muted, _v$3 = props.muted;
2723
- _v$ !== _p$.e && (_p$.e = setProp(_el$2, "fg", _v$, _p$.e));
2724
- _v$2 !== _p$.t && (_p$.t = setProp(_el$3, "fg", _v$2, _p$.t));
2725
- _v$3 !== _p$.a && (_p$.a = setProp(_el$6, "fg", _v$3, _p$.a));
3869
+ var _v$ = props.warn ?? "#fba970", _v$2 = props.warn ?? "#fba970", _v$3 = props.fg, _v$4 = props.muted, _v$5 = props.muted, _v$6 = props.muted, _v$7 = props.muted, _v$8 = props.warn ?? "#fba970";
3870
+ _v$ !== _p$.e && (_p$.e = setProp(_el$, "borderColor", _v$, _p$.e));
3871
+ _v$2 !== _p$.t && (_p$.t = setProp(_el$4, "backgroundColor", _v$2, _p$.t));
3872
+ _v$3 !== _p$.a && (_p$.a = setProp(_el$7, "fg", _v$3, _p$.a));
3873
+ _v$4 !== _p$.o && (_p$.o = setProp(_el$9, "fg", _v$4, _p$.o));
3874
+ _v$5 !== _p$.i && (_p$.i = setProp(_el$10, "fg", _v$5, _p$.i));
3875
+ _v$6 !== _p$.n && (_p$.n = setProp(_el$14, "fg", _v$6, _p$.n));
3876
+ _v$7 !== _p$.s && (_p$.s = setProp(_el$25, "fg", _v$7, _p$.s));
3877
+ _v$8 !== _p$.h && (_p$.h = setProp(_el$27, "backgroundColor", _v$8, _p$.h));
2726
3878
  return _p$;
2727
3879
  }, {
2728
3880
  e: void 0,
2729
3881
  t: void 0,
2730
- a: void 0
3882
+ a: void 0,
3883
+ o: void 0,
3884
+ i: void 0,
3885
+ n: void 0,
3886
+ s: void 0,
3887
+ h: void 0
2731
3888
  });
2732
3889
  return _el$;
2733
3890
  })();
@@ -2738,7 +3895,7 @@ function WhatsNewContent(props) {
2738
3895
  */
2739
3896
  async function maybeShowWhatsNewV2(context) {
2740
3897
  try {
2741
- const version = await resolveRunningVersion(import.meta.url);
3898
+ const version = await resolveRunningVersion$1(import.meta.url);
2742
3899
  if (!version) return;
2743
3900
  const statePath = await defaultWhatsNewStatePath();
2744
3901
  const changelogText = await readChangelogForBundle(import.meta.url);
@@ -2752,9 +3909,18 @@ async function maybeShowWhatsNewV2(context) {
2752
3909
  mode: "global",
2753
3910
  enabled: () => open(),
2754
3911
  commands: [
3912
+ {
3913
+ id: "pantheon.whats-new.confirm",
3914
+ title: "Confirm and close what is new",
3915
+ bind: "enter,space",
3916
+ run: () => {
3917
+ if (!open()) return false;
3918
+ dismiss();
3919
+ }
3920
+ },
2755
3921
  {
2756
3922
  id: "pantheon.whats-new.close",
2757
- title: "Fechar o que há de novo",
3923
+ title: "Close what is new",
2758
3924
  bind: "escape,q",
2759
3925
  run: () => {
2760
3926
  if (!open()) return false;
@@ -2802,6 +3968,7 @@ async function maybeShowWhatsNewV2(context) {
2802
3968
  setOpen(true);
2803
3969
  try {
2804
3970
  const theme = context.theme?.text ?? {};
3971
+ const warn = theme?.feedback?.warning?.base ?? "#fba970";
2805
3972
  context.ui.dialog.show(() => createComponent(WhatsNewContent, {
2806
3973
  data: viewData,
2807
3974
  page,
@@ -2811,7 +3978,11 @@ async function maybeShowWhatsNewV2(context) {
2811
3978
  },
2812
3979
  get muted() {
2813
3980
  return theme.muted;
2814
- }
3981
+ },
3982
+ warn,
3983
+ onClose: dismiss,
3984
+ onNext: () => setPage((current) => Math.min(current + 1, pageCount() - 1)),
3985
+ onPrev: () => setPage((current) => Math.max(current - 1, 0))
2815
3986
  }), close);
2816
3987
  } catch {}
2817
3988
  }
@@ -2830,7 +4001,7 @@ const SPINNER_INTERVAL_MS = 80;
2830
4001
  /** Bounded warm-up: sync at most this many sessions at plugin load. */
2831
4002
  const WARMUP_SESSION_LIMIT = 24;
2832
4003
  /** Sidebar body shown while the host has not published a session yet. */
2833
- const SIDEBAR_WAITING_LABEL = "Aguardando sessão…";
4004
+ const SIDEBAR_WAITING_LABEL = "Waiting for session…";
2834
4005
  /** Delegate-completion toast title. */
2835
4006
  const TOAST_TITLE = "Pantheon";
2836
4007
  /** Marker before the preset label (fixed header, home status, prompt footer).
@@ -3300,13 +4471,13 @@ function turnTokensPerSecond(messages, position) {
3300
4471
  * unavailable (never `undefined%`). A block with neither tokens nor cost
3301
4472
  * yields null. `gaugeStyle` (the TUI tab's pref) picks the percent-row
3302
4473
  * shape: `both` (default), `bar`, `percent`, or `off` (row omitted). Pure. */
3303
- function contextBlockRows(usage, cost, gaugeStyle = "both") {
4474
+ function contextBlockRows(usage, cost, gaugeStyle = "both", barOptions) {
3304
4475
  const spentValue = formatSpent(cost);
3305
4476
  const spent = spentValue === null ? null : {
3306
4477
  lead: null,
3307
4478
  value: spentValue,
3308
4479
  tail: null,
3309
- suffix: " gasto na sessão",
4480
+ suffix: " spent in session",
3310
4481
  tone: null
3311
4482
  };
3312
4483
  if (usage === null) return spent === null ? null : {
@@ -3324,7 +4495,7 @@ function contextBlockRows(usage, cost, gaugeStyle = "both") {
3324
4495
  };
3325
4496
  const percentValue = numberOrNull(usage.percent);
3326
4497
  const window = formatContextWindow(usage.limit);
3327
- const bar = contextBar(percentValue);
4498
+ const bar = contextBar(percentValue, barOptions ?? 12);
3328
4499
  let percent = null;
3329
4500
  if (gaugeStyle !== "off" && bar !== null && percentValue !== null) {
3330
4501
  const suffix = window === null ? null : ` of ${window}`;
@@ -4530,7 +5701,7 @@ function buildDispatchBlock(views, now = Date.now(), frame = 0, max = 34) {
4530
5701
  const DISPATCH_PANEL_NAME = "pantheon.dispatch";
4531
5702
  /** Toast shown when `ui.panel.open` refuses (no session route is active). The
4532
5703
  * panel only exists inside a session, so there is no alternative route. */
4533
- const DISPATCH_PANEL_TOAST = "Abra uma sessão para ver o Dispatch";
5704
+ const DISPATCH_PANEL_TOAST = "Open a session to view Dispatch";
4534
5705
  /** Panel title marker — the same glyph the sidebar block header uses. */
4535
5706
  const DISPATCH_PANEL_HEADER_MARKER = "◈";
4536
5707
  /** Selected-row gutter marker (`▸`, one cell). */
@@ -4542,7 +5713,7 @@ const DISPATCH_PANEL_RULE_CHAR = "─";
4542
5713
  /** Em dash for any datum the host did not publish. */
4543
5714
  const DISPATCH_PANEL_DASH = "—";
4544
5715
  /** Body of an empty panel (the claim still renders, the list is just empty). */
4545
- const DISPATCH_PANEL_EMPTY_TEXT = "Nenhuma sessão delegada";
5716
+ const DISPATCH_PANEL_EMPTY_TEXT = "No delegated sessions";
4546
5717
  /** Width at or above which the list and the detail sit side by side. */
4547
5718
  const DISPATCH_PANEL_WIDE_MIN_WIDTH = 72;
4548
5719
  /** Rows the viewport holds; pageup/pagedown move by exactly this many rows. */
@@ -4754,55 +5925,55 @@ const DISPATCH_PANEL_COMMANDS = [
4754
5925
  {
4755
5926
  action: "up",
4756
5927
  id: "pantheon.dispatch.up",
4757
- title: "Dispatch: selecionar anterior",
5928
+ title: "Dispatch: select previous",
4758
5929
  bind: "k,up"
4759
5930
  },
4760
5931
  {
4761
5932
  action: "down",
4762
5933
  id: "pantheon.dispatch.down",
4763
- title: "Dispatch: selecionar próxima",
5934
+ title: "Dispatch: select next",
4764
5935
  bind: "j,down"
4765
5936
  },
4766
5937
  {
4767
5938
  action: "home",
4768
5939
  id: "pantheon.dispatch.home",
4769
- title: "Dispatch: primeira",
5940
+ title: "Dispatch: first",
4770
5941
  bind: "home"
4771
5942
  },
4772
5943
  {
4773
5944
  action: "end",
4774
5945
  id: "pantheon.dispatch.end",
4775
- title: "Dispatch: última",
5946
+ title: "Dispatch: last",
4776
5947
  bind: "end"
4777
5948
  },
4778
5949
  {
4779
5950
  action: "pageup",
4780
5951
  id: "pantheon.dispatch.pageup",
4781
- title: "Dispatch: página acima",
5952
+ title: "Dispatch: page up",
4782
5953
  bind: "pageup"
4783
5954
  },
4784
5955
  {
4785
5956
  action: "pagedown",
4786
5957
  id: "pantheon.dispatch.pagedown",
4787
- title: "Dispatch: página abaixo",
5958
+ title: "Dispatch: page down",
4788
5959
  bind: "pagedown"
4789
5960
  },
4790
5961
  {
4791
5962
  action: "toggle",
4792
5963
  id: "pantheon.dispatch.toggle",
4793
- title: "Dispatch: expandir detalhe",
5964
+ title: "Dispatch: expand detail",
4794
5965
  bind: "enter"
4795
5966
  },
4796
5967
  {
4797
5968
  action: "fullscreen",
4798
5969
  id: "pantheon.dispatch.fullscreen",
4799
- title: "Dispatch: tela cheia",
5970
+ title: "Dispatch: fullscreen",
4800
5971
  bind: "f"
4801
5972
  },
4802
5973
  {
4803
5974
  action: "close",
4804
5975
  id: "pantheon.dispatch.close",
4805
- title: "Dispatch: fechar",
5976
+ title: "Dispatch: close",
4806
5977
  bind: "escape,q"
4807
5978
  }
4808
5979
  ];
@@ -4857,10 +6028,10 @@ function dispatchPanelFooter(shortcutsOf) {
4857
6028
  return text === "" ? "—" : text;
4858
6029
  };
4859
6030
  return [
4860
- `${keys("pantheon.dispatch.up")} ${keys("pantheon.dispatch.down")} mover`,
4861
- `${keys("pantheon.dispatch.toggle")} detalhe`,
6031
+ `${keys("pantheon.dispatch.up")} ${keys("pantheon.dispatch.down")} move`,
6032
+ `${keys("pantheon.dispatch.toggle")} detail`,
4862
6033
  `${keys("pantheon.dispatch.fullscreen")} fullscreen`,
4863
- `${keys("pantheon.dispatch.close")} fechar`
6034
+ `${keys("pantheon.dispatch.close")} close`
4864
6035
  ].join(SPEND_LINE_SEPARATOR);
4865
6036
  }
4866
6037
  /** The subset of `PanelInput` the model reads, so tests can drive it with a
@@ -5109,7 +6280,7 @@ async function checkForPantheonUpdate(context) {
5109
6280
  const latest = String((await response.json())?.version ?? "");
5110
6281
  if (!latest) return;
5111
6282
  const notice = pickUpdateNotice({
5112
- currentVersion: "2.0.0-beta.6",
6283
+ currentVersion: "2.0.0",
5113
6284
  latestVersion: latest,
5114
6285
  state: readState(),
5115
6286
  nowMs: Date.now()
@@ -5173,8 +6344,19 @@ function useActivePreset(context) {
5173
6344
  clearInterval(timer);
5174
6345
  });
5175
6346
  });
6347
+ const effectivePreset = () => {
6348
+ const preview = tuiDraftPreview();
6349
+ if (preview && "preset" in preview) {
6350
+ const stagedName = preview.preset;
6351
+ return {
6352
+ ...preset(),
6353
+ name: stagedName === "none" ? null : stagedName
6354
+ };
6355
+ }
6356
+ return preset();
6357
+ };
5176
6358
  return {
5177
- preset,
6359
+ preset: effectivePreset,
5178
6360
  overrides
5179
6361
  };
5180
6362
  }
@@ -5732,7 +6914,7 @@ function ContextRowView(props) {
5732
6914
  const fullWidth = () => cellWidth(`${props.row.lead ?? ""}${props.row.tail ?? ""}${props.row.value}${props.row.suffix ?? ""}`);
5733
6915
  return createComponent(Show, {
5734
6916
  get when() {
5735
- return props.row.suffix !== " gasto na sessão";
6917
+ return props.row.suffix !== " spent in session";
5736
6918
  },
5737
6919
  get fallback() {
5738
6920
  return (() => {
@@ -5740,7 +6922,7 @@ function ContextRowView(props) {
5740
6922
  setProp(_el$3, "flexDirection", "column");
5741
6923
  insert(_el$3, createComponent(For, {
5742
6924
  get each() {
5743
- return sidebarMoneyLines("gasto na sessão", props.row.value);
6925
+ return sidebarMoneyLines("spent in session", props.row.value);
5744
6926
  },
5745
6927
  children: (line) => (() => {
5746
6928
  var _el$4 = createElement("text");
@@ -5873,7 +7055,12 @@ function Sidebar(props) {
5873
7055
  const usageHidden = () => hiddenModelUsageText(model.modelUsage().hidden, model.modelUsage().hiddenCost);
5874
7056
  const contextRows = () => {
5875
7057
  const prefs = tuiPrefs();
5876
- const rows = contextBlockRows(model.contextUsage(), model.cost(), prefs.sidebar.context.gauge);
7058
+ const barCells = prefs.sidebar.context.barWidth === "compact" ? 8 : prefs.sidebar.context.barWidth === "wide" ? 16 : prefs.sidebar.context.barWidth === "full" ? 20 : 12;
7059
+ const rows = contextBlockRows(model.contextUsage(), model.cost(), prefs.sidebar.context.gauge, {
7060
+ shape: prefs.sidebar.context.barShape,
7061
+ cells: barCells,
7062
+ evenMark: prefs.sidebar.context.evenMark
7063
+ });
5877
7064
  if (rows === null) return null;
5878
7065
  return {
5879
7066
  tokens: prefs.sidebar.context.tokens ? rows.tokens : null,
@@ -5896,7 +7083,8 @@ function Sidebar(props) {
5896
7083
  var _el$12 = createElement("box");
5897
7084
  setProp(_el$12, "flexDirection", "column");
5898
7085
  setProp(_el$12, "width", "100%");
5899
- setProp(_el$12, "padding", 1);
7086
+ setProp(_el$12, "paddingLeft", 1);
7087
+ setProp(_el$12, "paddingRight", 1);
5900
7088
  insert(_el$12, createComponent(Show, {
5901
7089
  get when() {
5902
7090
  return header().version;
@@ -5904,7 +7092,7 @@ function Sidebar(props) {
5904
7092
  get children() {
5905
7093
  var _el$13 = createElement("text");
5906
7094
  setProp(_el$13, "attributes", 1);
5907
- insert(_el$13, `Pantheon v2.0.0-beta.6`);
7095
+ insert(_el$13, `Pantheon v2.0.0`);
5908
7096
  effect((_$p) => setProp(_el$13, "fg", text(), _$p));
5909
7097
  return _el$13;
5910
7098
  }
@@ -5946,7 +7134,7 @@ function Sidebar(props) {
5946
7134
  },
5947
7135
  children: (current) => (() => {
5948
7136
  var _el$27 = createElement("text");
5949
- insert(_el$27, () => `Sessão: ${truncateLabel(current().title || current().id)}`);
7137
+ insert(_el$27, () => `Session: ${truncateLabel(current().title || current().id)}`);
5950
7138
  effect((_$p) => setProp(_el$27, "fg", text(), _$p));
5951
7139
  return _el$27;
5952
7140
  })()
@@ -6052,12 +7240,12 @@ function Sidebar(props) {
6052
7240
  get children() {
6053
7241
  return [(() => {
6054
7242
  var _el$29 = createElement("text");
6055
- insertNode(_el$29, createTextNode(`Sessão · custo reportado`));
7243
+ insertNode(_el$29, createTextNode(`Session · reported cost`));
6056
7244
  effect((_$p) => setProp(_el$29, "fg", muted(), _$p));
6057
7245
  return _el$29;
6058
7246
  })(), (() => {
6059
7247
  var _el$31 = createElement("text");
6060
- insertNode(_el$31, createTextNode(`Modelo Tokens USD`));
7248
+ insertNode(_el$31, createTextNode(`Model Tokens USD`));
6061
7249
  effect((_$p) => setProp(_el$31, "fg", muted(), _$p));
6062
7250
  return _el$31;
6063
7251
  })()];
@@ -6174,9 +7362,9 @@ function Sidebar(props) {
6174
7362
  insertNode(_el$39, createTextNode(`⎇ `));
6175
7363
  insert(_el$41, () => truncateLabel(value(), 32));
6176
7364
  effect((_p$) => {
6177
- var _v$3 = muted(), _v$4 = text();
6178
- _v$3 !== _p$.e && (_p$.e = setProp(_el$39, "fg", _v$3, _p$.e));
6179
- _v$4 !== _p$.t && (_p$.t = setProp(_el$41, "fg", _v$4, _p$.t));
7365
+ var _v$5 = muted(), _v$6 = text();
7366
+ _v$5 !== _p$.e && (_p$.e = setProp(_el$39, "fg", _v$5, _p$.e));
7367
+ _v$6 !== _p$.t && (_p$.t = setProp(_el$41, "fg", _v$6, _p$.t));
6180
7368
  return _p$;
6181
7369
  }, {
6182
7370
  e: void 0,
@@ -6312,9 +7500,9 @@ function Sidebar(props) {
6312
7500
  setProp(_el$47, "flexShrink", 0);
6313
7501
  insert(_el$48, () => row.text);
6314
7502
  effect((_p$) => {
6315
- var _v$5 = open(row.id), _v$6 = tone("success");
6316
- _v$5 !== _p$.e && (_p$.e = setProp(_el$47, "onMouseDown", _v$5, _p$.e));
6317
- _v$6 !== _p$.t && (_p$.t = setProp(_el$48, "fg", _v$6, _p$.t));
7503
+ var _v$7 = open(row.id), _v$8 = tone("success");
7504
+ _v$7 !== _p$.e && (_p$.e = setProp(_el$47, "onMouseDown", _v$7, _p$.e));
7505
+ _v$8 !== _p$.t && (_p$.t = setProp(_el$48, "fg", _v$8, _p$.t));
6318
7506
  return _p$;
6319
7507
  }, {
6320
7508
  e: void 0,
@@ -6387,6 +7575,15 @@ function Sidebar(props) {
6387
7575
  return _el$23;
6388
7576
  }
6389
7577
  }), null);
7578
+ effect((_p$) => {
7579
+ var _v$3 = tuiPrefs().layout.preset === "compact" ? 0 : 1, _v$4 = tuiPrefs().layout.preset === "compact" ? 0 : 1;
7580
+ _v$3 !== _p$.e && (_p$.e = setProp(_el$12, "paddingTop", _v$3, _p$.e));
7581
+ _v$4 !== _p$.t && (_p$.t = setProp(_el$12, "paddingBottom", _v$4, _p$.t));
7582
+ return _p$;
7583
+ }, {
7584
+ e: void 0,
7585
+ t: void 0
7586
+ });
6390
7587
  return _el$12;
6391
7588
  })();
6392
7589
  }
@@ -6464,10 +7661,10 @@ function DispatchPanel(props) {
6464
7661
  insert(_el$55, () => selected(row.id) ? `▸ ` : " ");
6465
7662
  insert(_el$56, () => row.text);
6466
7663
  effect((_p$) => {
6467
- var _v$7 = selected(row.id) ? text() : muted(), _v$8 = rowFg(row.state), _v$9 = selected(row.id) ? 1 : 0;
6468
- _v$7 !== _p$.e && (_p$.e = setProp(_el$55, "fg", _v$7, _p$.e));
6469
- _v$8 !== _p$.t && (_p$.t = setProp(_el$56, "fg", _v$8, _p$.t));
6470
- _v$9 !== _p$.a && (_p$.a = setProp(_el$56, "attributes", _v$9, _p$.a));
7664
+ var _v$9 = selected(row.id) ? text() : muted(), _v$0 = rowFg(row.state), _v$1 = selected(row.id) ? 1 : 0;
7665
+ _v$9 !== _p$.e && (_p$.e = setProp(_el$55, "fg", _v$9, _p$.e));
7666
+ _v$0 !== _p$.t && (_p$.t = setProp(_el$56, "fg", _v$0, _p$.t));
7667
+ _v$1 !== _p$.a && (_p$.a = setProp(_el$56, "attributes", _v$1, _p$.a));
6471
7668
  return _p$;
6472
7669
  }, {
6473
7670
  e: void 0,
@@ -6490,7 +7687,7 @@ function DispatchPanel(props) {
6490
7687
  });
6491
7688
  const empty = () => (() => {
6492
7689
  var _el$58 = createElement("text");
6493
- insertNode(_el$58, createTextNode(`Nenhuma sessão delegada`));
7690
+ insertNode(_el$58, createTextNode(`No delegated sessions`));
6494
7691
  effect((_$p) => setProp(_el$58, "fg", muted(), _$p));
6495
7692
  return _el$58;
6496
7693
  })();
@@ -6599,10 +7796,10 @@ function DispatchPanel(props) {
6599
7796
  setProp(_el$66, "height", 1);
6600
7797
  insert(_el$67, () => model.footer());
6601
7798
  effect((_p$) => {
6602
- var _v$0 = text(), _v$1 = muted(), _v$10 = muted();
6603
- _v$0 !== _p$.e && (_p$.e = setProp(_el$61, "fg", _v$0, _p$.e));
6604
- _v$1 !== _p$.t && (_p$.t = setProp(_el$62, "fg", _v$1, _p$.t));
6605
- _v$10 !== _p$.a && (_p$.a = setProp(_el$67, "fg", _v$10, _p$.a));
7799
+ var _v$10 = text(), _v$11 = muted(), _v$12 = muted();
7800
+ _v$10 !== _p$.e && (_p$.e = setProp(_el$61, "fg", _v$10, _p$.e));
7801
+ _v$11 !== _p$.t && (_p$.t = setProp(_el$62, "fg", _v$11, _p$.t));
7802
+ _v$12 !== _p$.a && (_p$.a = setProp(_el$67, "fg", _v$12, _p$.a));
6606
7803
  return _p$;
6607
7804
  }, {
6608
7805
  e: void 0,
@@ -6667,7 +7864,7 @@ function HomeStatus(props) {
6667
7864
  },
6668
7865
  get children() {
6669
7866
  var _el$73 = createElement("text");
6670
- insert(_el$73, () => `Pantheon v2.0.0-beta.6${preset().name ? ` ▸ ${preset().name}` : ""}`);
7867
+ insert(_el$73, () => `Pantheon v2.0.0${preset().name ? ` ▸ ${preset().name}` : ""}`);
6671
7868
  effect((_$p) => setProp(_el$73, "fg", muted(), _$p));
6672
7869
  return _el$73;
6673
7870
  }
@@ -6786,6 +7983,13 @@ const plugin = Plugin.define({
6786
7983
  try {
6787
7984
  setupPantheonSettings(context);
6788
7985
  } catch {}
7986
+ const unregisterSettingsSlot = context.ui.slot({
7987
+ append: "session.composer.top",
7988
+ render: ({ sessionID }) => createComponent(PantheonSettingsSlot, {
7989
+ context,
7990
+ sessionID
7991
+ })
7992
+ });
6789
7993
  maybeShowWhatsNewV2(context);
6790
7994
  return () => {
6791
7995
  clearTimeout(updateNoticeTimer);
@@ -6793,6 +7997,7 @@ const plugin = Plugin.define({
6793
7997
  if (typeof unregisterHome === "function") unregisterHome();
6794
7998
  if (typeof unregisterPromptFooter === "function") unregisterPromptFooter();
6795
7999
  if (typeof unregisterPanel === "function") unregisterPanel();
8000
+ if (typeof unregisterSettingsSlot === "function") unregisterSettingsSlot();
6796
8001
  if (typeof unregisterCommands === "function") unregisterCommands();
6797
8002
  if (typeof unregisterSettingsCommands === "function") unregisterSettingsCommands();
6798
8003
  delete globalState[SINGLETON];