pantheon-opencode 2.0.0-rc.1 → 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 (70) hide show
  1. package/AGENTS.global.md +2 -2
  2. package/AGENTS.md +8 -8
  3. package/CHANGELOG.md +54 -0
  4. package/README.md +2 -0
  5. package/README.pt-BR.md +2 -0
  6. package/bin/pantheon-init.mjs +13 -0
  7. package/commands/pantheon-audit.md +1 -1
  8. package/commands/pantheon-deepwork.md +1 -1
  9. package/commands/pantheon-optimize.md +41 -63
  10. package/package.json +4 -3
  11. package/plugin.json +1 -1
  12. package/prompts/optimize-database.prompt.md +5 -5
  13. package/prompts/plan-architecture.prompt.md +6 -6
  14. package/pyproject.toml +1 -1
  15. package/scripts/build-agents-md.mjs +10 -10
  16. package/scripts/build-plugin.mjs +26 -0
  17. package/scripts/install/opencode-version.mjs +17 -5
  18. package/scripts/install/opencode.mjs +8 -1
  19. package/scripts/optimize.mjs +322 -0
  20. package/scripts/prune.mjs +105 -14
  21. package/scripts/update.mjs +20 -15
  22. package/skills-lock.json +11 -11
  23. package/src/agents/aphrodite.md +15 -14
  24. package/src/agents/apollo.md +2 -1
  25. package/src/agents/athena.md +5 -5
  26. package/src/agents/demeter.md +2 -0
  27. package/src/agents/hephaestus.md +1 -0
  28. package/src/agents/hermes.md +19 -95
  29. package/src/agents/iris.md +3 -0
  30. package/src/agents/nyx.md +1 -0
  31. package/src/agents/prometheus.md +2 -0
  32. package/src/agents/talos.md +3 -0
  33. package/src/agents/themis.md +91 -87
  34. package/src/agents/zeus.md +41 -266
  35. package/src/instructions/agent-return-format.instructions.md +1 -1
  36. package/src/instructions/memory-protocol.instructions.md +1 -1
  37. package/src/instructions/zeus-anti-stall.instructions.md +3 -3
  38. package/src/instructions/zeus-communication-rules.instructions.md +1 -1
  39. package/src/instructions/zeus-council-synthesis.instructions.md +2 -2
  40. package/src/instructions/zeus-timeout-retry.instructions.md +10 -10
  41. package/src/pantheon/model-command.ts +12 -12
  42. package/src/pantheon/tools.ts +4 -0
  43. package/src/pantheon/tui-version-check.ts +1 -1
  44. package/src/pantheon/update-notifier.ts +13 -8
  45. package/src/pantheon/vision.ts +20 -20
  46. package/src/plugin/index.js +14594 -0
  47. package/src/plugins/tui/dist/tui.d.ts +3 -3
  48. package/src/plugins/tui/dist/tui.d.ts.map +1 -1
  49. package/src/plugins/tui/dist/tui.js +923 -340
  50. package/src/plugins/tui/dist/tui.js.map +1 -1
  51. package/src/plugins/tui/package-lock.json +2 -2
  52. package/src/plugins/tui/package.json +1 -1
  53. package/src/plugins/tui/src/autonomy-state.ts +27 -15
  54. package/src/plugins/tui/src/index.tsx +44 -23
  55. package/src/plugins/tui/src/pantheon-settings.tsx +461 -105
  56. package/src/plugins/tui/src/tui-prefs.ts +106 -4
  57. package/src/plugins/tui/src/update-notice.ts +9 -6
  58. package/src/plugins/tui/src/whats-new-open.ts +4 -4
  59. package/src/plugins/tui/src/whats-new.tsx +119 -17
  60. package/src/skills/agent-coordination/SKILL.md +6 -6
  61. package/src/skills/artifact-management/SKILL.md +43 -39
  62. package/src/skills/artifact-management/references/artifact-templates.md +103 -48
  63. package/src/skills/auto-continue/references/auto-continue-details.md +13 -13
  64. package/src/skills/code-review-checklist/SKILL.md +6 -6
  65. package/src/skills/incremental-implementation/SKILL.md +13 -13
  66. package/src/skills/memory-bank/references/anti-patterns.md +3 -3
  67. package/src/skills/spec-driven-development/SKILL.md +12 -14
  68. package/src/skills/tdd-with-agents/SKILL.md +6 -5
  69. package/src/skills/visual-review-pipeline/SKILL.md +1 -1
  70. package/src/skills/visual-review-pipeline/references/workflow-steps.md +1 -1
@@ -27,7 +27,7 @@ import { execFile } from 'node:child_process'
27
27
  import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'
28
28
  import { join } from 'node:path'
29
29
  import type { Context } from '@opencode/plugin/tui/context'
30
- import { createSignal, For, onCleanup, Show } from 'solid-js'
30
+ import { createEffect, createSignal, For, onCleanup, onMount, Show } from 'solid-js'
31
31
  import {
32
32
  buildAutonomyTab,
33
33
  DEFAULT_DECISION_BUDGETS,
@@ -59,6 +59,7 @@ import {
59
59
  draftDirty,
60
60
  type EffectiveOverrides,
61
61
  EMPTY_TAB,
62
+ findRow,
62
63
  type OverridesLoad,
63
64
  resetTab,
64
65
  type SettingsDraft,
@@ -81,7 +82,15 @@ import {
81
82
  readActivePresetMarker,
82
83
  writeActivePreset,
83
84
  } from './preset-state.ts'
84
- import { applyTuiRow, buildTuiTab, mutateTuiPrefs, tuiPrefs } from './tui-prefs.ts'
85
+ import {
86
+ applyTuiRow,
87
+ buildTuiTab,
88
+ clearTuiDraftPreview,
89
+ mutateTuiPrefs,
90
+ savedTuiPrefs,
91
+ setTuiDraftPreview,
92
+ tuiPrefs,
93
+ } from './tui-prefs.ts'
85
94
  import { nextCheckState, type UpdateCheckState } from './update-notice.ts'
86
95
  import {
87
96
  buildUpdatesTab,
@@ -365,8 +374,8 @@ function resolveRunningVersion(): string {
365
374
 
366
375
  // ── The window view (presentational; both surfaces render it) ──────────
367
376
 
368
- const NAME_WIDTH = 28
369
- const VALUE_WIDTH = 22
377
+ const NAME_WIDTH = 26
378
+ const VALUE_WIDTH = 24
370
379
 
371
380
  export function SettingsWindow(props: {
372
381
  version: string
@@ -379,73 +388,108 @@ export function SettingsWindow(props: {
379
388
  fg?: any
380
389
  muted?: any
381
390
  warn?: any
391
+ hasKeyboard?: () => boolean
392
+ onJumpTab?: (index: number) => void
393
+ onSelectRow?: (id: string) => void
394
+ onCycleValue?: (id: string, direction: 1 | -1) => void
395
+ onSave?: () => void
396
+ onResetPage?: () => void
397
+ onStageDefaults?: () => void
398
+ onClose?: () => void
399
+ onDiscard?: () => void
400
+ onCancelExit?: () => void
401
+ isDialog?: boolean
402
+ maxHeight?: number
403
+ height?: number
404
+ boxRef?: (el: any) => void
405
+ onMouseDown?: () => void
382
406
  }) {
383
407
  const tab = () => props.tabs()[props.page()] ?? props.tabs()[0] ?? EMPTY_TAB
384
408
  return (
385
- <box flexDirection="column" paddingLeft={1} paddingRight={1} paddingTop={1}>
386
- {/* ── Top Header bar: Title + Horizontal Tabs + ESC (matching image.png) ── */}
387
- <box flexDirection="row" alignItems="center">
388
- <text attributes={1} fg={props.fg}>
389
- {`Pantheon v${props.version}`}
409
+ <box
410
+ {...(props.boxRef !== undefined ? { ref: props.boxRef } : {})}
411
+ focusable
412
+ flexDirection="column"
413
+ {...(props.height !== undefined ? { height: props.height } : { flexGrow: 1, flexBasis: 0 })}
414
+ minHeight={0}
415
+ border={!props.isDialog}
416
+ {...(props.isDialog ? {} : { borderStyle: 'rounded' as const })}
417
+ borderColor={
418
+ props.isDialog
419
+ ? undefined
420
+ : props.hasKeyboard?.()
421
+ ? (props.warn ?? '#fba970')
422
+ : (props.muted ?? '#52525b')
423
+ }
424
+ paddingLeft={1}
425
+ paddingRight={1}
426
+ paddingTop={0}
427
+ paddingBottom={0}
428
+ {...(props.onMouseDown !== undefined ? { onMouseDown: props.onMouseDown } : {})}
429
+ >
430
+ {/* ── Top Header bar: Title + Horizontal Clickable Tabs + ESC (matching opencode-quota) ── */}
431
+ <box
432
+ flexDirection="row"
433
+ flexWrap="wrap"
434
+ alignItems="center"
435
+ flexShrink={0}
436
+ marginBottom={1}
437
+ rowGap={1}
438
+ >
439
+ <text fg={props.fg} attributes={1} wrapMode="none">
440
+ <b>{'Pantheon'}</b>
441
+ <span style={{ fg: props.muted }}>{` v${props.version}`}</span>
390
442
  </text>
391
443
  <box width={2} />
392
- <box flexDirection="row" flexGrow={1} flexShrink={1}>
444
+ <box
445
+ flexDirection="row"
446
+ flexWrap="wrap"
447
+ flexGrow={1}
448
+ flexShrink={0}
449
+ columnGap={1}
450
+ rowGap={1}
451
+ >
393
452
  <For each={props.tabs()}>
394
453
  {(t, index) => {
395
454
  const isActive = () => index() === props.page()
396
455
  return (
397
- <text
456
+ <box
457
+ onMouseDown={() => props.onJumpTab?.(index())}
458
+ paddingLeft={1}
459
+ paddingRight={1}
398
460
  flexShrink={0}
399
- fg={isActive() ? (props.warn ?? props.fg) : props.muted}
400
- {...(isActive() ? { attributes: 1 } : {})}
461
+ {...(isActive() ? { backgroundColor: '#262626' } : {})}
401
462
  >
402
- {`${t.title}${tabDirty(props.draft(), t) ? ' ●' : ''} `}
403
- </text>
463
+ <text
464
+ wrapMode="none"
465
+ fg={isActive() ? (props.warn ?? '#fba970') : props.muted}
466
+ {...(isActive() ? { attributes: 1 } : {})}
467
+ >
468
+ {`${t.title}${tabDirty(props.draft(), t) ? ' ●' : ''}`}
469
+ </text>
470
+ </box>
404
471
  )
405
472
  }}
406
473
  </For>
407
474
  </box>
408
- <text fg={props.muted}>{'esc'}</text>
409
- </box>
410
-
411
- {/* ── Thin divider under header ── */}
412
- <box flexDirection="row" height={1}>
413
- <box flexGrow={1}>
414
- <text fg={props.muted}>{'─'.repeat(78)}</text>
475
+ <box onMouseDown={() => props.onClose?.()} paddingLeft={1} flexShrink={0}>
476
+ <text fg={props.muted} wrapMode="none">
477
+ {'esc'}
478
+ </text>
415
479
  </box>
416
480
  </box>
417
481
 
418
- {/* ── Main Body: Left Rail + Content (matching image.png & image_2.png) ── */}
419
- <box flexDirection="row">
420
- {/* Left Rail: Tab list with active indicator */}
421
- <box width={18} flexDirection="column">
422
- <For each={props.tabs()}>
423
- {(t, index) => {
424
- const isActive = () => index() === props.page()
425
- return (
426
- <text
427
- fg={isActive() ? (props.warn ?? props.fg) : props.muted}
428
- {...(isActive() ? { attributes: 1 } : {})}
429
- >
430
- {`${isActive() ? '▸ ' : ' '}${t.title}${tabDirty(props.draft(), t) ? ' ●' : ''}`}
431
- </text>
432
- )
433
- }}
434
- </For>
435
- <box height={1} />
436
- <text fg={props.muted}>{'1-9: tab'}</text>
437
- <text fg={props.muted}>{'tab: next'}</text>
438
- </box>
439
-
440
- {/* Content panel */}
441
- <box flexGrow={1} flexShrink={1} flexDirection="column" paddingLeft={1}>
442
- <text attributes={1} fg={props.warn ?? props.fg}>
443
- {tab().title}
444
- </text>
445
- <text fg={props.muted}>{'─'.repeat(40)}</text>
482
+ {/* ── Main Body: Scrollable content panel ── */}
483
+ <box flexDirection="column" flexGrow={1} flexBasis={0} minHeight={0} overflow="hidden">
484
+ <scrollbox
485
+ flexGrow={1}
486
+ flexBasis={0}
487
+ minHeight={0}
488
+ {...(props.maxHeight !== undefined ? { maxHeight: props.maxHeight } : {})}
489
+ >
446
490
  <For each={tab().groups}>
447
491
  {(group) => (
448
- <box flexDirection="column">
492
+ <box flexDirection="column" marginBottom={1}>
449
493
  <Show when={group.title !== undefined}>
450
494
  <text attributes={1} fg={props.warn ?? props.fg}>
451
495
  {group.title}
@@ -456,27 +500,40 @@ export function SettingsWindow(props: {
456
500
  const isSelected = () => row.id === props.selectedId()
457
501
  const display = () => props.draft()[row.id] ?? row.value
458
502
  const staged = () => props.draft()[row.id] !== undefined
459
- const gutter = () => (isSelected() ? ' ' : ' ')
460
- const valueCell = () =>
461
- row.cycle !== undefined ? `< ${display()} >` : display()
503
+ const gutter = () => (isSelected() ? '▸ ' : ' ')
504
+ const valueCell = () => {
505
+ if (row.cycle !== undefined) return `< ${display()} >`
506
+ if (row.action !== undefined) return `[ ${display()} ]`
507
+ if (row.id.startsWith('autonomy.gradient.')) return `[ref] ${display()}`
508
+ return display()
509
+ }
462
510
  return (
463
511
  <box
464
512
  flexDirection="row"
465
- backgroundColor={isSelected() ? (props.warn ?? '#f59e0b') : undefined}
513
+ {...(isSelected() ? { backgroundColor: '#262626' } : {})}
514
+ onMouseDown={() => {
515
+ props.onSelectRow?.(row.id)
516
+ }}
466
517
  >
467
518
  <box width={NAME_WIDTH + 2}>
468
519
  <text
469
- fg={isSelected() ? '#000000' : props.fg}
520
+ fg={isSelected() ? (props.warn ?? '#fba970') : props.fg}
470
521
  {...(isSelected() ? { attributes: 1 } : {})}
471
522
  >
472
523
  {`${gutter()}${row.name}`.padEnd(NAME_WIDTH + 2)}
473
524
  </text>
474
525
  </box>
475
- <box width={VALUE_WIDTH}>
526
+ <box
527
+ width={VALUE_WIDTH}
528
+ onMouseDown={() => {
529
+ props.onSelectRow?.(row.id)
530
+ props.onCycleValue?.(row.id, 1)
531
+ }}
532
+ >
476
533
  <text
477
534
  fg={
478
535
  isSelected()
479
- ? '#000000'
536
+ ? '#ffffff'
480
537
  : staged()
481
538
  ? (props.warn ?? props.fg)
482
539
  : props.muted
@@ -488,26 +545,31 @@ export function SettingsWindow(props: {
488
545
  </box>
489
546
  <Show when={row.note !== undefined}>
490
547
  <box flexGrow={1} flexShrink={1}>
491
- <text fg={isSelected() ? '#111827' : props.muted}>{row.note}</text>
548
+ <text fg={isSelected() ? '#e5e7eb' : props.muted}>{row.note}</text>
492
549
  </box>
493
550
  </Show>
494
551
  </box>
495
552
  )
496
553
  }}
497
554
  </For>
498
- <box height={1} />
499
555
  </box>
500
556
  )}
501
557
  </For>
502
- </box>
558
+ </scrollbox>
503
559
  </box>
504
560
 
505
561
  {/* ── Footer: notice + botões (chips) + keys (matching image.png & image_2.png) ── */}
506
562
  <Show when={props.notice() !== undefined}>
507
- <text fg={props.notice()?.startsWith('✅') ? props.fg : (props.warn ?? props.muted)}>
508
- {props.notice()?.startsWith('✅') || props.notice()?.startsWith('saved')
563
+ <text
564
+ fg={
565
+ props.notice()?.startsWith('[OK]') || props.notice()?.startsWith('saved')
566
+ ? props.fg
567
+ : (props.warn ?? props.muted)
568
+ }
569
+ >
570
+ {props.notice()?.startsWith('[OK]') || props.notice()?.startsWith('saved')
509
571
  ? props.notice()
510
- : `⚠ ${props.notice()}`}
572
+ : `[WARN] ${props.notice()}`}
511
573
  </text>
512
574
  </Show>
513
575
 
@@ -518,43 +580,94 @@ export function SettingsWindow(props: {
518
580
  <Show
519
581
  when={draftDirty(props.draft())}
520
582
  fallback={
521
- <box flexDirection="row">
522
- <box backgroundColor="#262626">
583
+ <box
584
+ flexDirection="row"
585
+ flexWrap="wrap"
586
+ alignItems="center"
587
+ flexShrink={0}
588
+ rowGap={1}
589
+ >
590
+ <box
591
+ backgroundColor="#262626"
592
+ flexShrink={0}
593
+ onMouseDown={() => props.onClose?.()}
594
+ >
523
595
  <text fg="#ffffff">{' Close '}</text>
524
596
  </box>
525
- <text fg={props.muted}>{' '}</text>
526
- <box backgroundColor="#262626">
597
+ <text fg={props.muted} flexShrink={0}>
598
+ {' '}
599
+ </text>
600
+ <box
601
+ backgroundColor="#262626"
602
+ flexShrink={0}
603
+ onMouseDown={() => props.onResetPage?.()}
604
+ >
527
605
  <text fg="#ffffff">{' Reset page '}</text>
528
606
  </box>
529
- <text fg={props.muted}>{' '}</text>
530
- <box backgroundColor="#262626">
607
+ <text fg={props.muted} flexShrink={0}>
608
+ {' '}
609
+ </text>
610
+ <box
611
+ backgroundColor="#262626"
612
+ flexShrink={0}
613
+ onMouseDown={() => props.onStageDefaults?.()}
614
+ >
531
615
  <text fg="#ffffff">{' Defaults '}</text>
532
616
  </box>
533
- <box flexGrow={1} />
534
- <text fg={props.muted}>{'no staged changes'}</text>
617
+ <box flexGrow={1} minWidth={1} />
618
+ <text fg={props.muted} flexShrink={0}>
619
+ {'no staged changes'}
620
+ </text>
535
621
  </box>
536
622
  }
537
623
  >
538
- <box flexDirection="row">
539
- <box backgroundColor="#fba970">
624
+ <box
625
+ flexDirection="row"
626
+ flexWrap="wrap"
627
+ alignItems="center"
628
+ flexShrink={0}
629
+ rowGap={1}
630
+ >
631
+ <box backgroundColor="#fba970" flexShrink={0} onMouseDown={() => props.onSave?.()}>
540
632
  <text fg="#000000">{' Save '}</text>
541
633
  </box>
542
- <text fg={props.muted}>{' '}</text>
543
- <box backgroundColor="#262626">
634
+ <text fg={props.muted} flexShrink={0}>
635
+ {' '}
636
+ </text>
637
+ <box
638
+ backgroundColor="#262626"
639
+ flexShrink={0}
640
+ onMouseDown={() => props.onDiscard?.()}
641
+ >
544
642
  <text fg="#ffffff">{' Discard '}</text>
545
643
  </box>
546
- <text fg={props.muted}>{' '}</text>
547
- <box backgroundColor="#262626">
644
+ <text fg={props.muted} flexShrink={0}>
645
+ {' '}
646
+ </text>
647
+ <box
648
+ backgroundColor="#262626"
649
+ flexShrink={0}
650
+ onMouseDown={() => props.onResetPage?.()}
651
+ >
548
652
  <text fg="#ffffff">{' Reset page '}</text>
549
653
  </box>
550
- <box flexGrow={1} />
551
- <text fg={props.warn ?? '#f59e0b'}>{'unsaved changes'}</text>
654
+ <box flexGrow={1} minWidth={1} />
655
+ <text fg={props.warn ?? '#f59e0b'} flexShrink={0}>
656
+ {'unsaved changes'}
657
+ </text>
552
658
  </box>
553
659
  </Show>
554
660
  <text fg={props.muted}>
555
- {
556
- '› or ←/→ change · ↑↓ select · tab next tab · ctrl+s save · ctrl+r reset page · esc close'
557
- }
661
+ {(() => {
662
+ const currentRow = findRow(tab(), props.selectedId() ?? '')
663
+ if (currentRow?.cycle !== undefined) {
664
+ return 'click or ›/←/→ change · ↑↓ select · tab next tab · ctrl+s save · ctrl+r reset page · esc close'
665
+ }
666
+ if (currentRow?.action !== undefined) {
667
+ return 'enter or space run action · ↑↓ select · tab next tab · ctrl+s save · ctrl+r reset page · esc close'
668
+ }
669
+ return '[ref] documented reference (read-only) · ↑↓ select · tab next tab · esc close'
670
+ })()}
558
671
  </text>
559
672
  </box>
560
673
  }
@@ -564,15 +677,15 @@ export function SettingsWindow(props: {
564
677
  <text fg={props.warn ?? '#f59e0b'} attributes={1}>
565
678
  {'Keep your changes? '}
566
679
  </text>
567
- <box backgroundColor="#fba970">
680
+ <box backgroundColor="#fba970" onMouseDown={() => props.onSave?.()}>
568
681
  <text fg="#000000">{' Save '}</text>
569
682
  </box>
570
683
  <text fg={props.muted}>{' '}</text>
571
- <box backgroundColor="#262626">
684
+ <box backgroundColor="#262626" onMouseDown={() => props.onDiscard?.()}>
572
685
  <text fg="#ffffff">{' Discard '}</text>
573
686
  </box>
574
687
  <text fg={props.muted}>{' '}</text>
575
- <box backgroundColor="#262626">
688
+ <box backgroundColor="#262626" onMouseDown={() => props.onCancelExit?.()}>
576
689
  <text fg="#ffffff">{' Keep editing '}</text>
577
690
  </box>
578
691
  </box>
@@ -588,8 +701,11 @@ export function SettingsWindow(props: {
588
701
  interface PageApi {
589
702
  move: (delta: number) => void
590
703
  step: (direction: 1 | -1) => void
704
+ selectById?: (id: string) => void
705
+ cycleRowById?: (id: string, direction: 1 | -1) => void
591
706
  actuate: () => void
592
707
  nextTab: () => void
708
+ prevTab?: () => void
593
709
  jumpTab: (index: number) => void
594
710
  save: () => void
595
711
  resetPage: () => void
@@ -635,6 +751,11 @@ function createWindowController(
635
751
  const [notice, setNotice] = createSignal<string | undefined>(undefined)
636
752
  const [confirmExit, setConfirmExit] = createSignal(false)
637
753
 
754
+ // Real-time preview of staged draft preferences across open TUI views
755
+ createEffect(() => {
756
+ setTuiDraftPreview(draft())
757
+ })
758
+
638
759
  // Load changelog highlights asynchronously
639
760
  void readChangelogForBundle(import.meta.url).then((text) => {
640
761
  if (!text) return
@@ -678,7 +799,7 @@ function createWindowController(
678
799
  buildGatesTab(load()),
679
800
  buildDecisionTab(decision(), process.env, readAuthProviders(), readConfigProviders()),
680
801
  buildPresetTab(presetInput()),
681
- buildTuiTab(tuiPrefs()),
802
+ buildTuiTab(savedTuiPrefs()),
682
803
  buildAutonomyTab({
683
804
  goalLoop: goalLoop(),
684
805
  budgets: budgets(),
@@ -748,7 +869,7 @@ function createWindowController(
748
869
  })
749
870
  } catch {}
750
871
  } else {
751
- setNotice('✅ update complete — restart OpenCode or run `npx pantheon-opencode init`')
872
+ setNotice('[OK] update complete — restart OpenCode or run `npx pantheon-opencode init`')
752
873
  try {
753
874
  context.ui.toast?.show?.({
754
875
  variant: 'info',
@@ -948,6 +1069,7 @@ function createWindowController(
948
1069
  return
949
1070
  }
950
1071
  if (staged > 0) {
1072
+ clearTuiDraftPreview()
951
1073
  setDraft({})
952
1074
  try {
953
1075
  context.ui.toast?.show?.({
@@ -963,6 +1085,7 @@ function createWindowController(
963
1085
 
964
1086
  const discard = () => {
965
1087
  const staged = draftCount(draft())
1088
+ clearTuiDraftPreview()
966
1089
  setDraft({})
967
1090
  setConfirmExit(false)
968
1091
  if (staged > 0) {
@@ -984,9 +1107,34 @@ function createWindowController(
984
1107
 
985
1108
  const selectedId = () => rows()[selected()]?.id
986
1109
 
1110
+ const selectById = (id: string) => {
1111
+ if (confirmExit()) setConfirmExit(false)
1112
+ const list = rows()
1113
+ const index = list.findIndex((r) => r.id === id)
1114
+ if (index !== -1) setSelected(index)
1115
+ }
1116
+
1117
+ const cycleRowById = (id: string, direction: 1 | -1) => {
1118
+ if (confirmExit()) setConfirmExit(false)
1119
+ const list = rows()
1120
+ const index = list.findIndex((r) => r.id === id)
1121
+ if (index !== -1) {
1122
+ setSelected(index)
1123
+ const row = list[index]
1124
+ if (row?.action === 'update-check') checkUpdatesNow()
1125
+ else if (row?.action === 'update-run') runUpdateNow()
1126
+ else if (row) {
1127
+ setNotice(undefined)
1128
+ setDraft(stageValue(draft(), row, direction))
1129
+ }
1130
+ }
1131
+ }
1132
+
987
1133
  const api: PageApi = {
988
1134
  move,
989
1135
  step,
1136
+ selectById,
1137
+ cycleRowById,
990
1138
  actuate: () => {
991
1139
  if (confirmExit()) setConfirmExit(false)
992
1140
  const row = rows()[selected()]
@@ -995,6 +1143,14 @@ function createWindowController(
995
1143
  else step(1)
996
1144
  },
997
1145
  nextTab,
1146
+ prevTab: () => {
1147
+ if (confirmExit()) setConfirmExit(false)
1148
+ const count = tabs().length
1149
+ if (count > 0) {
1150
+ setPage((current) => (current - 1 + count) % count)
1151
+ setSelected(0)
1152
+ }
1153
+ },
998
1154
  jumpTab: (index) => {
999
1155
  if (confirmExit()) setConfirmExit(false)
1000
1156
  if (index >= 0 && index < tabs().length) {
@@ -1020,6 +1176,7 @@ function createWindowController(
1020
1176
  confirmExit: () => confirmExit(),
1021
1177
  api,
1022
1178
  cleanup: () => {
1179
+ clearTuiDraftPreview()
1023
1180
  pageApi = undefined
1024
1181
  setBlocking(false)
1025
1182
  },
@@ -1062,6 +1219,15 @@ function SettingsPage(props: { context: Context; data: Record<string, any> | und
1062
1219
  fg={theme.base}
1063
1220
  muted={theme.muted}
1064
1221
  warn={warn}
1222
+ onJumpTab={(idx) => controller.api.jumpTab(idx)}
1223
+ onSelectRow={(id) => controller.api.selectById?.(id)}
1224
+ onCycleValue={(id, dir) => controller.api.cycleRowById?.(id, dir)}
1225
+ onSave={() => controller.api.save()}
1226
+ onResetPage={() => controller.api.resetPage()}
1227
+ onStageDefaults={() => controller.api.stageDefaults()}
1228
+ onClose={() => controller.api.close()}
1229
+ onDiscard={() => controller.api.discard?.()}
1230
+ onCancelExit={() => controller.api.cancelExit?.()}
1065
1231
  />
1066
1232
  )
1067
1233
  }
@@ -1105,6 +1271,8 @@ function openSettingsDialog(context: Context): void {
1105
1271
  setBlocking(true)
1106
1272
  setDialogOpen(true)
1107
1273
  pageApi = controller.api
1274
+ const rendererHeight = () => (context as any).renderer?.height ?? 30
1275
+ const maxHeight = () => Math.min(16, Math.max(8, Math.floor(rendererHeight() * 0.55)))
1108
1276
  try {
1109
1277
  context.ui.dialog.show(
1110
1278
  () => (
@@ -1119,15 +1287,178 @@ function openSettingsDialog(context: Context): void {
1119
1287
  fg={theme.base}
1120
1288
  muted={theme.muted}
1121
1289
  warn={warn}
1290
+ isDialog={true}
1291
+ maxHeight={maxHeight()}
1292
+ onJumpTab={(idx) => controller.api.jumpTab(idx)}
1293
+ onSelectRow={(id) => controller.api.selectById?.(id)}
1294
+ onCycleValue={(id, dir) => controller.api.cycleRowById?.(id, dir)}
1295
+ onSave={() => controller.api.save()}
1296
+ onResetPage={() => controller.api.resetPage()}
1297
+ onStageDefaults={() => controller.api.stageDefaults()}
1298
+ onClose={() => controller.api.close()}
1299
+ onDiscard={() => controller.api.discard?.()}
1300
+ onCancelExit={() => controller.api.cancelExit?.()}
1122
1301
  />
1123
1302
  ),
1124
1303
  close,
1125
1304
  )
1305
+ context.ui.dialog.set({ size: 'large' })
1126
1306
  } catch {
1127
1307
  /* dialog stack unavailable — fail-open */
1128
1308
  }
1129
1309
  }
1130
1310
 
1311
+ // ── In-session docked window (session.composer.top) ─────────────────────
1312
+
1313
+ const [settingsOpen, setSettingsOpen] = createSignal(false)
1314
+ const [activeSessionId, setActiveSessionId] = createSignal<string | undefined>()
1315
+
1316
+ export function isPantheonSettingsOpen(): boolean {
1317
+ return settingsOpen()
1318
+ }
1319
+
1320
+ export function routeSessionID(context: any): string | undefined {
1321
+ try {
1322
+ const route = context?.ui?.router?.current?.()
1323
+ return route?.type === 'session' ? route?.sessionID : undefined
1324
+ } catch {
1325
+ return undefined
1326
+ }
1327
+ }
1328
+
1329
+ export function closePantheonSettings(): void {
1330
+ if (pageApi) {
1331
+ pageApi.close()
1332
+ if (pageApi.confirmExit?.()) {
1333
+ return
1334
+ }
1335
+ }
1336
+ setSettingsOpen(false)
1337
+ setBlocking(false)
1338
+ }
1339
+
1340
+ export function PantheonSettingsSlot(props: { context: Context; sessionID: string }) {
1341
+ onMount(() => {
1342
+ setActiveSessionId(props.sessionID)
1343
+ })
1344
+ onCleanup(() => {
1345
+ if (activeSessionId() === props.sessionID) {
1346
+ setActiveSessionId(undefined)
1347
+ }
1348
+ })
1349
+ return (
1350
+ <Show when={settingsOpen() && (activeSessionId() === props.sessionID || !activeSessionId())}>
1351
+ <InSessionSettingsWindow context={props.context} sessionID={props.sessionID} />
1352
+ </Show>
1353
+ )
1354
+ }
1355
+
1356
+ function InSessionSettingsWindow(props: { context: Context; sessionID: string }) {
1357
+ let windowBox: any
1358
+ const context = props.context
1359
+ const initialRoom = () => Math.max(14, ((context as any).renderer?.height ?? 30) - 10)
1360
+ const [roomHeight, setRoomHeight] = createSignal<number>(initialRoom())
1361
+ const [hasKeyboard, setHasKeyboard] = createSignal(false)
1362
+
1363
+ function measureRoom(): void {
1364
+ const box = windowBox
1365
+ if (!box || box.isDestroyed) return
1366
+ let child = box
1367
+ for (let parent = box.parent; parent; child = parent, parent = parent.parent) {
1368
+ const siblings = parent.getChildren?.() ?? []
1369
+ const messages = siblings[0]
1370
+ if (
1371
+ messages === child ||
1372
+ !messages?.getChildren?.().some((item: any) => 'scrollChildIntoView' in item)
1373
+ ) {
1374
+ continue
1375
+ }
1376
+ const otherRows = siblings
1377
+ .filter((item: any) => item !== child && item !== messages)
1378
+ .reduce((total: number, item: any) => total + (item.height ?? 0), 0)
1379
+ const room = Math.max(
1380
+ 12,
1381
+ (parent.height ?? 24) - 1 - otherRows - ((child.height ?? 0) - (box.height ?? 0)),
1382
+ )
1383
+ if (room !== roomHeight()) queueMicrotask(() => setRoomHeight(room))
1384
+ return
1385
+ }
1386
+ }
1387
+
1388
+ onMount(() => {
1389
+ try {
1390
+ ;(context as any).renderer?.root?.on?.('layout-changed', measureRoom)
1391
+ ;(context as any).renderer?.on?.('resize', measureRoom)
1392
+ onCleanup(() => {
1393
+ try {
1394
+ ;(context as any).renderer?.root?.off?.('layout-changed', measureRoom)
1395
+ ;(context as any).renderer?.off?.('resize', measureRoom)
1396
+ } catch {}
1397
+ })
1398
+ } catch {}
1399
+ measureRoom()
1400
+ setTimeout(() => {
1401
+ try {
1402
+ windowBox?.focus?.()
1403
+ } catch {}
1404
+ }, 50)
1405
+ })
1406
+
1407
+ try {
1408
+ const popMode = (context as any).keymap?.mode?.push?.(ROUTE_MODE)
1409
+ if (popMode !== undefined) onCleanup(() => popMode())
1410
+ } catch {}
1411
+
1412
+ const controller = createWindowController(context, () => {
1413
+ setSettingsOpen(false)
1414
+ setBlocking(false)
1415
+ })
1416
+
1417
+ onCleanup(controller.cleanup)
1418
+ pageApi = controller.api
1419
+
1420
+ const theme = (context as any).theme?.text ?? {}
1421
+ const warn = (theme?.feedback as any)?.warning?.base ?? '#fba970'
1422
+
1423
+ return (
1424
+ <SettingsWindow
1425
+ boxRef={(el: any) => {
1426
+ windowBox = el
1427
+ if (el) {
1428
+ el.on?.('focused', () => setHasKeyboard(true))
1429
+ el.on?.('blurred', () => setHasKeyboard(false))
1430
+ }
1431
+ }}
1432
+ height={roomHeight()}
1433
+ version={resolveRunningVersion()}
1434
+ tabs={controller.tabs}
1435
+ page={controller.page}
1436
+ selectedId={controller.selectedId}
1437
+ draft={controller.draft}
1438
+ notice={controller.notice}
1439
+ confirmExit={controller.confirmExit}
1440
+ fg={theme.base}
1441
+ muted={theme.muted}
1442
+ warn={warn}
1443
+ hasKeyboard={hasKeyboard}
1444
+ onJumpTab={(idx) => controller.api.jumpTab(idx)}
1445
+ onSelectRow={(id) => controller.api.selectById?.(id)}
1446
+ onCycleValue={(id, dir) => controller.api.cycleRowById?.(id, dir)}
1447
+ onSave={() => controller.api.save()}
1448
+ onResetPage={() => controller.api.resetPage()}
1449
+ onStageDefaults={() => controller.api.stageDefaults()}
1450
+ onClose={() => closePantheonSettings()}
1451
+ onDiscard={() => controller.api.discard?.()}
1452
+ onCancelExit={() => controller.api.cancelExit?.()}
1453
+ onMouseDown={() => {
1454
+ try {
1455
+ windowBox?.focus?.()
1456
+ } catch {}
1457
+ }}
1458
+ />
1459
+ )
1460
+ }
1461
+
1131
1462
  // ── Setup: register once, gate once, priority 1 (anti-theft) ───────────
1132
1463
 
1133
1464
  export function setupPantheonSettings(context: Context): void {
@@ -1155,25 +1486,15 @@ export function setupPantheonSettings(context: Context): void {
1155
1486
  title: 'Close settings',
1156
1487
  bind: 'escape,q',
1157
1488
  run: () => {
1158
- try {
1159
- context.ui.toast?.show?.({ variant: 'info', message: 'settings: close command fired' })
1160
- } catch {}
1161
1489
  if (pageApi === undefined) {
1162
- try {
1163
- context.ui.toast?.show?.({
1164
- variant: 'warning',
1165
- message: 'settings: no window controller bound',
1166
- })
1167
- } catch {
1168
- /* toast unavailable */
1169
- }
1490
+ closePantheonSettings()
1170
1491
  return undefined
1171
1492
  }
1172
1493
  if (pageApi.confirmExit?.()) {
1173
1494
  pageApi.cancelExit?.()
1174
1495
  return undefined
1175
1496
  }
1176
- pageApi.close()
1497
+ closePantheonSettings()
1177
1498
  return undefined
1178
1499
  },
1179
1500
  },
@@ -1243,6 +1564,15 @@ export function setupPantheonSettings(context: Context): void {
1243
1564
  return undefined
1244
1565
  },
1245
1566
  },
1567
+ {
1568
+ id: 'pantheon.settings.prev.tab',
1569
+ title: 'Previous settings tab',
1570
+ bind: 'shift+tab',
1571
+ run: () => {
1572
+ pageApi?.prevTab?.()
1573
+ return undefined
1574
+ },
1575
+ },
1246
1576
  {
1247
1577
  id: 'pantheon.settings.save',
1248
1578
  title: 'Save staged changes',
@@ -1289,7 +1619,7 @@ export function setupPantheonSettings(context: Context): void {
1289
1619
  context.keymap.layer(() => ({
1290
1620
  mode: ROUTE_MODE,
1291
1621
  priority: 1,
1292
- enabled: () => routeGated(),
1622
+ enabled: () => routeGated() || settingsOpen(),
1293
1623
  commands,
1294
1624
  }))
1295
1625
  } catch {
@@ -1300,7 +1630,7 @@ export function setupPantheonSettings(context: Context): void {
1300
1630
  context.keymap.layer(() => ({
1301
1631
  mode: 'global' as const,
1302
1632
  priority: 1,
1303
- enabled: () => dialogOpen(),
1633
+ enabled: () => dialogOpen() || settingsOpen(),
1304
1634
  commands,
1305
1635
  }))
1306
1636
  } catch {
@@ -1312,7 +1642,9 @@ export function setupPantheonSettings(context: Context): void {
1312
1642
 
1313
1643
  export async function openPantheonSettings(context: Context): Promise<void> {
1314
1644
  try {
1315
- if (routerAvailable && context.ui?.router?.navigate) {
1645
+ const prefs = tuiPrefs()
1646
+ const viewMode = prefs.layout?.settingsView ?? 'docked'
1647
+ if (viewMode === 'fullscreen' && routerAvailable && context.ui?.router?.navigate) {
1316
1648
  let returnRoute: WindowRoute | undefined
1317
1649
  try {
1318
1650
  const current = context.ui.router.current()
@@ -1331,8 +1663,32 @@ export async function openPantheonSettings(context: Context): Promise<void> {
1331
1663
  })
1332
1664
  return
1333
1665
  }
1666
+ if (viewMode === 'dialog') {
1667
+ openSettingsDialog(context)
1668
+ return
1669
+ }
1334
1670
  } catch {
1335
- /* router unusable — fall through to the dialog */
1671
+ /* preferences check failed — fall through to docked */
1336
1672
  }
1337
- openSettingsDialog(context)
1673
+
1674
+ // Primary mode: docked in session.composer.top
1675
+ const sessionID = (context as any)?.sessionID ?? routeSessionID(context) ?? activeSessionId()
1676
+ if (!sessionID) {
1677
+ try {
1678
+ context.ui?.toast?.show?.({
1679
+ variant: 'info',
1680
+ title: 'Pantheon',
1681
+ message: 'Open a session first: Pantheon settings opens above the prompt box.',
1682
+ })
1683
+ } catch {}
1684
+ return
1685
+ }
1686
+
1687
+ if (settingsOpen()) {
1688
+ closePantheonSettings()
1689
+ return
1690
+ }
1691
+
1692
+ setSettingsOpen(true)
1693
+ setBlocking(true)
1338
1694
  }