@fbincon/claude-code-statusline 3.9.1 → 3.10.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 (217) hide show
  1. package/README.md +78 -78
  2. package/candidate.json +426 -344
  3. package/node_modules/@fbincon/statusline-cli/dist/src/config/profile-command.js +8 -4
  4. package/node_modules/@fbincon/statusline-cli/dist/src/config/profile-command.js.map +1 -1
  5. package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/command.js +7 -18
  6. package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/command.js.map +1 -1
  7. package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/input.d.ts +5 -0
  8. package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/input.js +36 -0
  9. package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/input.js.map +1 -0
  10. package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/service.js +17 -7
  11. package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/service.js.map +1 -1
  12. package/node_modules/@fbincon/statusline-cli/dist/src/integration/configure.js +2 -1
  13. package/node_modules/@fbincon/statusline-cli/dist/src/integration/configure.js.map +1 -1
  14. package/node_modules/@fbincon/statusline-cli/dist/src/integration/setup.js +1 -1
  15. package/node_modules/@fbincon/statusline-cli/dist/src/integration/setup.js.map +1 -1
  16. package/node_modules/@fbincon/statusline-cli/dist/src/management/service.js +7 -0
  17. package/node_modules/@fbincon/statusline-cli/dist/src/management/service.js.map +1 -1
  18. package/node_modules/@fbincon/statusline-cli/dist/src/rendering/preview.js +2 -2
  19. package/node_modules/@fbincon/statusline-cli/dist/src/rendering/preview.js.map +1 -1
  20. package/node_modules/@fbincon/statusline-cli/dist/src/sources/automatic-state.d.ts +1 -0
  21. package/node_modules/@fbincon/statusline-cli/dist/src/sources/automatic-state.js +3 -2
  22. package/node_modules/@fbincon/statusline-cli/dist/src/sources/automatic-state.js.map +1 -1
  23. package/node_modules/@fbincon/statusline-cli/dist/src/sources/command.js +14 -5
  24. package/node_modules/@fbincon/statusline-cli/dist/src/sources/command.js.map +1 -1
  25. package/node_modules/@fbincon/statusline-cli/dist/src/sources/service.d.ts +3 -1
  26. package/node_modules/@fbincon/statusline-cli/dist/src/sources/service.js +56 -22
  27. package/node_modules/@fbincon/statusline-cli/dist/src/sources/service.js.map +1 -1
  28. package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.d.ts +6 -5
  29. package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.js +21 -5
  30. package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.js.map +1 -1
  31. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/.claude-plugin/plugin.json +1 -1
  32. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/hooks/register.ts +103 -74
  33. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/backend.ts +13 -10
  34. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/keys.ts +11 -1
  35. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/settings.ts +7 -2
  36. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/alignment-manager.ts +2 -1
  37. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/color-manager.ts +177 -0
  38. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/diagnosis-view.ts +123 -0
  39. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/draft.ts +50 -0
  40. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/explanation.ts +2 -1
  41. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/forms.ts +1 -0
  42. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/gradients.ts +10 -0
  43. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/group-manager.ts +1 -0
  44. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/preview-settings.ts +8 -0
  45. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/profile-manager.ts +14 -5
  46. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/quick-setup.ts +1 -0
  47. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/setup.ts +7 -0
  48. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/source-manager.ts +15 -4
  49. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/source-validation.ts +2 -2
  50. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/themes.ts +40 -0
  51. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/generated-contracts.ts +17 -15
  52. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/generated-locales.ts +564 -6
  53. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/presentation.ts +3 -1
  54. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/resource-manifest.json +28 -24
  55. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/draw.ts +9 -3
  56. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/help.ts +4 -2
  57. package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/.claude-plugin/plugin.json +1 -1
  58. package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/resource-manifest.json +3 -3
  59. package/node_modules/@fbincon/statusline-core/dist/src/config/defaults.js +1 -1
  60. package/node_modules/@fbincon/statusline-core/dist/src/config/display.d.ts +1 -1
  61. package/node_modules/@fbincon/statusline-core/dist/src/config/display.js +6 -5
  62. package/node_modules/@fbincon/statusline-core/dist/src/config/display.js.map +1 -1
  63. package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.d.ts +23 -8
  64. package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.js +7 -9
  65. package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.js.map +1 -1
  66. package/node_modules/@fbincon/statusline-core/dist/src/editor/alignment-manager.js +3 -1
  67. package/node_modules/@fbincon/statusline-core/dist/src/editor/alignment-manager.js.map +1 -1
  68. package/node_modules/@fbincon/statusline-core/dist/src/editor/backend.js +12 -10
  69. package/node_modules/@fbincon/statusline-core/dist/src/editor/backend.js.map +1 -1
  70. package/node_modules/@fbincon/statusline-core/dist/src/editor/color-manager.d.ts +23 -0
  71. package/node_modules/@fbincon/statusline-core/dist/src/editor/color-manager.js +153 -0
  72. package/node_modules/@fbincon/statusline-core/dist/src/editor/color-manager.js.map +1 -0
  73. package/node_modules/@fbincon/statusline-core/dist/src/editor/diagnosis-view.d.ts +29 -0
  74. package/node_modules/@fbincon/statusline-core/dist/src/editor/diagnosis-view.js +107 -0
  75. package/node_modules/@fbincon/statusline-core/dist/src/editor/diagnosis-view.js.map +1 -0
  76. package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.d.ts +21 -1
  77. package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js +61 -0
  78. package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js.map +1 -1
  79. package/node_modules/@fbincon/statusline-core/dist/src/editor/explanation.js +3 -1
  80. package/node_modules/@fbincon/statusline-core/dist/src/editor/explanation.js.map +1 -1
  81. package/node_modules/@fbincon/statusline-core/dist/src/editor/forms.js +4 -0
  82. package/node_modules/@fbincon/statusline-core/dist/src/editor/forms.js.map +1 -1
  83. package/node_modules/@fbincon/statusline-core/dist/src/editor/gradients.d.ts +9 -0
  84. package/node_modules/@fbincon/statusline-core/dist/src/editor/gradients.js +9 -0
  85. package/node_modules/@fbincon/statusline-core/dist/src/editor/gradients.js.map +1 -1
  86. package/node_modules/@fbincon/statusline-core/dist/src/editor/group-manager.js +5 -0
  87. package/node_modules/@fbincon/statusline-core/dist/src/editor/group-manager.js.map +1 -1
  88. package/node_modules/@fbincon/statusline-core/dist/src/editor/preview-settings.d.ts +7 -0
  89. package/node_modules/@fbincon/statusline-core/dist/src/editor/preview-settings.js +7 -0
  90. package/node_modules/@fbincon/statusline-core/dist/src/editor/preview-settings.js.map +1 -0
  91. package/node_modules/@fbincon/statusline-core/dist/src/editor/profile-manager.js +32 -3
  92. package/node_modules/@fbincon/statusline-core/dist/src/editor/profile-manager.js.map +1 -1
  93. package/node_modules/@fbincon/statusline-core/dist/src/editor/quick-setup.js +2 -0
  94. package/node_modules/@fbincon/statusline-core/dist/src/editor/quick-setup.js.map +1 -1
  95. package/node_modules/@fbincon/statusline-core/dist/src/editor/setup.d.ts +4 -0
  96. package/node_modules/@fbincon/statusline-core/dist/src/editor/setup.js +17 -0
  97. package/node_modules/@fbincon/statusline-core/dist/src/editor/setup.js.map +1 -1
  98. package/node_modules/@fbincon/statusline-core/dist/src/editor/source-manager.d.ts +1 -0
  99. package/node_modules/@fbincon/statusline-core/dist/src/editor/source-manager.js +24 -4
  100. package/node_modules/@fbincon/statusline-core/dist/src/editor/source-manager.js.map +1 -1
  101. package/node_modules/@fbincon/statusline-core/dist/src/editor/source-validation.js +2 -2
  102. package/node_modules/@fbincon/statusline-core/dist/src/editor/source-validation.js.map +1 -1
  103. package/node_modules/@fbincon/statusline-core/dist/src/editor/themes.d.ts +17 -0
  104. package/node_modules/@fbincon/statusline-core/dist/src/editor/themes.js +30 -0
  105. package/node_modules/@fbincon/statusline-core/dist/src/editor/themes.js.map +1 -0
  106. package/node_modules/@fbincon/statusline-core/dist/src/extensions/model.d.ts +3 -1
  107. package/node_modules/@fbincon/statusline-core/dist/src/extensions/model.js +15 -1
  108. package/node_modules/@fbincon/statusline-core/dist/src/extensions/model.js.map +1 -1
  109. package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.d.ts +558 -0
  110. package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js +564 -6
  111. package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js.map +1 -1
  112. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/en.d.ts +2 -0
  113. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/en.js +3 -1
  114. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/en.js.map +1 -1
  115. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ja.d.ts +2 -0
  116. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ja.js +3 -1
  117. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ja.js.map +1 -1
  118. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ko.d.ts +2 -0
  119. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ko.js +3 -1
  120. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ko.js.map +1 -1
  121. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-CN.d.ts +2 -0
  122. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-CN.js +3 -1
  123. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-CN.js.map +1 -1
  124. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-HK.d.ts +2 -0
  125. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-HK.js +3 -1
  126. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-HK.js.map +1 -1
  127. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-TW.d.ts +2 -0
  128. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-TW.js +3 -1
  129. package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-TW.js.map +1 -1
  130. package/node_modules/@fbincon/statusline-core/dist/src/management/compatibility.js +4 -2
  131. package/node_modules/@fbincon/statusline-core/dist/src/management/compatibility.js.map +1 -1
  132. package/node_modules/@fbincon/statusline-core/dist/src/release.d.ts +1 -1
  133. package/node_modules/@fbincon/statusline-core/dist/src/release.js +1 -1
  134. package/node_modules/@fbincon/statusline-core/dist/src/release.js.map +1 -1
  135. package/node_modules/@fbincon/statusline-core/dist/src/rendering/appearance.d.ts +2 -1
  136. package/node_modules/@fbincon/statusline-core/dist/src/rendering/appearance.js +12 -13
  137. package/node_modules/@fbincon/statusline-core/dist/src/rendering/appearance.js.map +1 -1
  138. package/node_modules/@fbincon/statusline-core/dist/src/rendering/diagnose.js +1 -1
  139. package/node_modules/@fbincon/statusline-core/dist/src/rendering/diagnose.js.map +1 -1
  140. package/node_modules/@fbincon/statusline-core/dist/src/rendering/explain.js +2 -0
  141. package/node_modules/@fbincon/statusline-core/dist/src/rendering/explain.js.map +1 -1
  142. package/node_modules/@fbincon/statusline-core/dist/src/rendering/gradients.d.ts +1 -1
  143. package/node_modules/@fbincon/statusline-core/dist/src/rendering/gradients.js +2 -1
  144. package/node_modules/@fbincon/statusline-core/dist/src/rendering/gradients.js.map +1 -1
  145. package/node_modules/@fbincon/statusline-core/dist/src/rendering/groups.js +5 -2
  146. package/node_modules/@fbincon/statusline-core/dist/src/rendering/groups.js.map +1 -1
  147. package/node_modules/@fbincon/statusline-core/dist/src/rendering/indicators.js +5 -4
  148. package/node_modules/@fbincon/statusline-core/dist/src/rendering/indicators.js.map +1 -1
  149. package/node_modules/@fbincon/statusline-core/dist/src/rendering/items.js +4 -4
  150. package/node_modules/@fbincon/statusline-core/dist/src/rendering/items.js.map +1 -1
  151. package/node_modules/@fbincon/statusline-core/dist/src/rendering/powerline.d.ts +4 -1
  152. package/node_modules/@fbincon/statusline-core/dist/src/rendering/powerline.js +2 -2
  153. package/node_modules/@fbincon/statusline-core/dist/src/rendering/powerline.js.map +1 -1
  154. package/node_modules/@fbincon/statusline-core/dist/src/rendering/preferences.d.ts +6 -2
  155. package/node_modules/@fbincon/statusline-core/dist/src/rendering/preferences.js +14 -10
  156. package/node_modules/@fbincon/statusline-core/dist/src/rendering/preferences.js.map +1 -1
  157. package/node_modules/@fbincon/statusline-core/dist/src/rendering/preview.d.ts +11 -52
  158. package/node_modules/@fbincon/statusline-core/dist/src/rendering/preview.js +48 -7
  159. package/node_modules/@fbincon/statusline-core/dist/src/rendering/preview.js.map +1 -1
  160. package/node_modules/@fbincon/statusline-core/dist/src/rendering/sample-scenarios.d.ts +6 -0
  161. package/node_modules/@fbincon/statusline-core/dist/src/rendering/sample-scenarios.js +38 -0
  162. package/node_modules/@fbincon/statusline-core/dist/src/rendering/sample-scenarios.js.map +1 -0
  163. package/node_modules/@fbincon/statusline-core/dist/src/rendering/subagents.d.ts +2 -1
  164. package/node_modules/@fbincon/statusline-core/dist/src/rendering/subagents.js +15 -18
  165. package/node_modules/@fbincon/statusline-core/dist/src/rendering/subagents.js.map +1 -1
  166. package/node_modules/@fbincon/statusline-core/dist/src/rendering/trace.d.ts +2 -1
  167. package/node_modules/@fbincon/statusline-core/dist/src/rendering/trace.js +19 -1
  168. package/node_modules/@fbincon/statusline-core/dist/src/rendering/trace.js.map +1 -1
  169. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/en.json +94 -1
  170. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ja.json +94 -1
  171. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ko.json +94 -1
  172. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-CN.json +94 -1
  173. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-HK.json +94 -1
  174. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-TW.json +94 -1
  175. package/node_modules/@fbincon/statusline-platform/dist/src/darwin-process.d.ts +8 -0
  176. package/node_modules/@fbincon/statusline-platform/dist/src/darwin-process.js +33 -0
  177. package/node_modules/@fbincon/statusline-platform/dist/src/darwin-process.js.map +1 -0
  178. package/node_modules/@fbincon/statusline-platform/dist/src/diagnostic-files.js +3 -2
  179. package/node_modules/@fbincon/statusline-platform/dist/src/diagnostic-files.js.map +1 -1
  180. package/node_modules/@fbincon/statusline-platform/dist/src/npm.js +47 -16
  181. package/node_modules/@fbincon/statusline-platform/dist/src/npm.js.map +1 -1
  182. package/node_modules/@fbincon/statusline-platform/dist/src/package-copy.js +10 -0
  183. package/node_modules/@fbincon/statusline-platform/dist/src/package-copy.js.map +1 -1
  184. package/node_modules/@fbincon/statusline-platform/dist/src/performance.d.ts +2 -0
  185. package/node_modules/@fbincon/statusline-platform/dist/src/performance.js +17 -0
  186. package/node_modules/@fbincon/statusline-platform/dist/src/performance.js.map +1 -0
  187. package/node_modules/@fbincon/statusline-platform/dist/src/processes.js +7 -3
  188. package/node_modules/@fbincon/statusline-platform/dist/src/processes.js.map +1 -1
  189. package/node_modules/@fbincon/statusline-platform/dist/src/source-process.js +6 -12
  190. package/node_modules/@fbincon/statusline-platform/dist/src/source-process.js.map +1 -1
  191. package/node_modules/@fbincon/statusline-platform/dist/src/terminal/launchers.d.ts +1 -1
  192. package/node_modules/@fbincon/statusline-platform/dist/src/terminal/launchers.js +2 -5
  193. package/node_modules/@fbincon/statusline-platform/dist/src/terminal/launchers.js.map +1 -1
  194. package/node_modules/@fbincon/statusline-platform/dist/src/windows-command.d.ts +2 -0
  195. package/node_modules/@fbincon/statusline-platform/dist/src/windows-command.js +7 -0
  196. package/node_modules/@fbincon/statusline-platform/dist/src/windows-command.js.map +1 -0
  197. package/node_modules/@fbincon/statusline-platform/dist/src/windows-source-exec.d.ts +1 -0
  198. package/node_modules/@fbincon/statusline-platform/dist/src/windows-source-exec.js +65 -0
  199. package/node_modules/@fbincon/statusline-platform/dist/src/windows-source-exec.js.map +1 -0
  200. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/pages.js +12 -0
  201. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/pages.js.map +1 -1
  202. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/presentation.js +8 -0
  203. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/presentation.js.map +1 -1
  204. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/shortcuts.js +9 -0
  205. package/node_modules/@fbincon/statusline-tui/dist/src/drawing/shortcuts.js.map +1 -1
  206. package/node_modules/@fbincon/statusline-tui/dist/src/drawing.js +8 -5
  207. package/node_modules/@fbincon/statusline-tui/dist/src/drawing.js.map +1 -1
  208. package/node_modules/@fbincon/statusline-tui/dist/src/session.d.ts +1 -0
  209. package/node_modules/@fbincon/statusline-tui/dist/src/session.js +65 -10
  210. package/node_modules/@fbincon/statusline-tui/dist/src/session.js.map +1 -1
  211. package/node_modules/@fbincon/statusline-tui/dist/src/setup.d.ts +2 -1
  212. package/node_modules/@fbincon/statusline-tui/dist/src/setup.js +7 -5
  213. package/node_modules/@fbincon/statusline-tui/dist/src/setup.js.map +1 -1
  214. package/node_modules/@fbincon/statusline-tui/dist/src/state.d.ts +1 -1
  215. package/node_modules/@fbincon/statusline-tui/dist/src/state.js +55 -3
  216. package/node_modules/@fbincon/statusline-tui/dist/src/state.js.map +1 -1
  217. package/package.json +3 -3
@@ -0,0 +1,177 @@
1
+ // Generated by tools/generation/resources.ts; do not edit.
2
+ import type { Draft, Scope, Span } from '../generated-contracts.ts';
3
+ import type { Editor } from './draft.ts';
4
+ import { copyDraft } from './draft.ts';
5
+ import { THEME_IDS, ANSI_ROLES, ANSI_BLOCKS, themeDefinition } from './themes.ts';
6
+ import { GRADIENT_PRESETS, GRADIENT_SURFACES, parseGradient, gradientName } from './gradients.ts';
7
+ import { normalizeColor, validColor } from './appearance.ts';
8
+ import { inputKey, inputView, textInput, type TextInput, type TextKey } from './text-input.ts';
9
+ import { t, type Language } from '../i18n/index.ts';
10
+ export interface ColorManager {
11
+ kind: 'theme' | 'solid' | 'gradient';
12
+ key: string;
13
+ scope: Scope;
14
+ id: string;
15
+ cursor: number;
16
+ candidate: string | string[] | null;
17
+ generation: number;
18
+ input: TextInput | null;
19
+ editing: number | null;
20
+ error: boolean;
21
+ }
22
+ interface Choice {
23
+ id: string;
24
+ label: string;
25
+ value?: string | string[] | null;
26
+ colors?: readonly string[];
27
+ surface?: string;
28
+ }
29
+ export function openColors(e: Editor, key: string): boolean {
30
+ if (!['field:theme', 'item:foreground', 'item:background', 'item:foreground_gradient', 'item:background_gradient'].includes(key))
31
+ return false;
32
+ if (!e.canMutateDraft())
33
+ return true;
34
+ const kind = key === 'field:theme' ? 'theme' : key.endsWith('_gradient') ? 'gradient' : 'solid';
35
+ const detail = e.detail, node = detail ? e.instance(detail.scope, detail.id) : null;
36
+ const value = kind === 'theme' ? e.draft.display.theme : node?.options[key.slice(5) as 'foreground'] ?? null;
37
+ e.colors = { kind, key, scope: detail?.scope ?? 'main', id: detail?.id ?? '', cursor: 0, candidate: Array.isArray(value) ? [...value] : value, generation: e.mutationGeneration, input: null, editing: null, error: false };
38
+ return true;
39
+ }
40
+ function choices(e: Editor, language: Language): Choice[] {
41
+ const m = e.colors!, tr = (key: string) => t('colors.' + key, language);
42
+ let rows: Choice[];
43
+ if (m.kind === 'theme')
44
+ rows = THEME_IDS.map(id => ({ id, label: t('values.' + id, language), value: id, colors: id === 'terminal' ? (e.draft.display.separator_style === 'powerline' ? ANSI_BLOCKS : ANSI_ROLES).map(value => 'ansi:' + value) : e.draft.display.separator_style === 'powerline' ? themeDefinition(id).backgrounds : themeDefinition(id).foreground, surface: themeDefinition(id).surface }));
45
+ else if (m.kind === 'solid') {
46
+ const definition = themeDefinition(e.draft.display.theme);
47
+ const values = [...new Set([...definition.foreground, ...definition.backgrounds])];
48
+ rows = [{ id: 'inherit', label: tr('inherit'), value: null }, { id: 'default', label: tr('default'), value: 'default' },
49
+ ...Array.from({ length: 16 }, (_, i) => ({ id: 'ansi:' + i, label: 'ANSI ' + i, value: 'ansi:' + i, colors: ['ansi:' + i] })),
50
+ ...values.map(color => ({ id: color, label: color, value: color, colors: [color] })), { id: 'custom', label: tr('custom') }];
51
+ }
52
+ else {
53
+ rows = [{ id: 'off', label: tr('off'), value: null }, ...Object.entries(GRADIENT_PRESETS).map(([id, colors]) => ({ id, label: t('gradients.preset.' + id, language), value: [...colors], colors, surface: GRADIENT_SURFACES[id as keyof typeof GRADIENT_PRESETS] })),
54
+ { id: 'custom', label: tr('custom') }, { id: 'reverse', label: tr('reverse') },
55
+ ...(Array.isArray(m.candidate) ? m.candidate.map((color, i) => ({ id: 'stop:' + i, label: tr('stop') + ' ' + (i + 1) + ' ' + color, colors: [color] })) : []),
56
+ { id: 'add', label: tr('add') }, { id: 'remove', label: tr('remove') }];
57
+ }
58
+ return [...rows, { id: 'apply', label: tr('apply') }, { id: 'cancel', label: tr('cancel') }];
59
+ }
60
+ export function colorDraft(e: Editor): Draft {
61
+ const m = e.colors;
62
+ if (!m)
63
+ return e.draft;
64
+ const draft = copyDraft(e.draft);
65
+ if (m.kind === 'theme')
66
+ draft.display.theme = m.candidate as Draft['display']['theme'];
67
+ else {
68
+ const node = (m.scope === 'main' ? draft.display.instances : draft.display.subagents.instances).find(n => n.id === m.id);
69
+ if (node)
70
+ (node.options as unknown as Record<string, unknown>)[m.key.slice(5)] = Array.isArray(m.candidate) ? [...m.candidate] : m.candidate;
71
+ }
72
+ return draft;
73
+ }
74
+ export function colorsKey(e: Editor, event: TextKey, language: Language): null {
75
+ const m = e.colors!, key = event.key;
76
+ if ((e.saveState !== 'idle' || m.generation !== e.mutationGeneration) && !(key === 'escape' || event.ctrl && key.toLowerCase() === 'g' || ['up', 'down', 'home', 'end', 'pageup', 'pagedown'].includes(key))) {
77
+ e.canMutateDraft(m.generation);
78
+ return null;
79
+ }
80
+ if (m.input) {
81
+ if (key === 'escape' || event.ctrl && key.toLowerCase() === 'g') {
82
+ m.input = null;
83
+ m.error = false;
84
+ return null;
85
+ }
86
+ if (key === 'return' && !event.text && !event.paste) {
87
+ try {
88
+ if (m.kind === 'gradient' && m.editing === null)
89
+ m.candidate = parseGradient(m.input.value);
90
+ else if (m.kind === 'gradient') {
91
+ if (!/^#[0-9a-f]{6}$/iu.test(m.input.value))
92
+ throw new Error();
93
+ (m.candidate as string[])[m.editing!] = m.input.value.toLowerCase();
94
+ }
95
+ else {
96
+ const value = m.input.value === 'inherit' ? null : m.input.value;
97
+ if (!validColor(value))
98
+ throw new Error();
99
+ m.candidate = normalizeColor(value) as string | null;
100
+ }
101
+ m.input = null;
102
+ m.error = false;
103
+ }
104
+ catch {
105
+ m.error = true;
106
+ }
107
+ }
108
+ else {
109
+ const result = inputKey(m.input.value, m.input, event, 256);
110
+ m.input = result.state;
111
+ m.error = !!result.error;
112
+ }
113
+ return null;
114
+ }
115
+ if (event.text || event.paste || event.meta || event.overflow)
116
+ return null;
117
+ if (key === 'escape' || event.ctrl && key.toLowerCase() === 'g') {
118
+ e.colors = null;
119
+ return null;
120
+ }
121
+ const rows = choices(e, language);
122
+ if (['up', 'down', 'pageup', 'pagedown', 'tab'].includes(key))
123
+ m.cursor = Math.max(0, Math.min(rows.length - 1, m.cursor + (key === 'up' ? -1 : key === 'pageup' ? -5 : key === 'pagedown' ? 5 : 1)));
124
+ if (key === 'home')
125
+ m.cursor = 0;
126
+ if (key === 'end')
127
+ m.cursor = rows.length - 1;
128
+ const selected = rows[m.cursor]!;
129
+ if (event.ctrl && key.toLowerCase() === 's' || key === 'return' && selected.id === 'apply') {
130
+ if (e.canMutateDraft(m.generation)) {
131
+ e.draft = colorDraft(e);
132
+ e.colors = null;
133
+ }
134
+ return null;
135
+ }
136
+ if (event.ctrl)
137
+ return null;
138
+ if (key === 'return' || key === 'left' || key === 'right') {
139
+ if (selected.id === 'cancel') {
140
+ e.colors = null;
141
+ return null;
142
+ }
143
+ if (Object.hasOwn(selected, 'value'))
144
+ m.candidate = Array.isArray(selected.value) ? [...selected.value] : selected.value!;
145
+ else if (selected.id === 'custom' || selected.id.startsWith('stop:')) {
146
+ m.editing = selected.id.startsWith('stop:') ? Number(selected.id.slice(5)) : null;
147
+ m.input = textInput(m.editing === null ? (m.kind === 'gradient' ? gradientName(m.candidate) : m.candidate === null ? 'inherit' : String(m.candidate)) : (m.candidate as string[])[m.editing]!);
148
+ }
149
+ else if (selected.id === 'reverse' && Array.isArray(m.candidate))
150
+ m.candidate.reverse();
151
+ else if (selected.id === 'add') {
152
+ if (!Array.isArray(m.candidate))
153
+ m.candidate = [...GRADIENT_PRESETS.ocean];
154
+ else if (m.candidate.length < 5)
155
+ m.candidate.push(m.candidate.at(-1)!);
156
+ }
157
+ else if (selected.id === 'remove' && Array.isArray(m.candidate) && m.candidate.length > 2)
158
+ m.candidate.pop();
159
+ m.error = false;
160
+ }
161
+ return null;
162
+ }
163
+ const plain = (text: string): Span => ({ text, bold: false, foreground: null, background: null });
164
+ export function colorsView(e: Editor, language: Language, width: number, height: number): {
165
+ spans: Span[];
166
+ selected: boolean;
167
+ }[] {
168
+ const m = e.colors!, tr = (key: string) => t('colors.' + key, language);
169
+ if (m.input)
170
+ return [{ spans: [plain(tr('input'))], selected: false }, { spans: [plain(inputView(m.input, width))], selected: true }, { spans: [plain(m.error ? tr('invalid') : tr('input_help'))], selected: false }];
171
+ const rows = choices(e, language), capacity = Math.max(1, height - 2), start = Math.floor(m.cursor / capacity) * capacity;
172
+ return [{ spans: [plain(tr('help'))], selected: false }, ...rows.slice(start, start + capacity).map((row, index) => {
173
+ const selected = start + index === m.cursor;
174
+ const spans = [plain(selected ? '› ' : ' '), ...(row.colors ?? []).map(color => ({ ...plain('██'), foreground: color.startsWith('ansi:') ? { kind: 'ansi' as const, value: Number(color.slice(5)) } : { kind: 'rgb' as const, value: color } })), plain(' ' + row.label + (row.surface ? ' · ' + tr((m.kind === 'theme' ? 'theme_surface_' : 'surface_') + row.surface) : ''))];
175
+ return { spans, selected };
176
+ }), { spans: [plain(`${m.cursor + 1}/${rows.length} · ${e.saveState !== 'idle' || m.generation !== e.mutationGeneration ? t('editor.save_locked', language) : m.error ? tr('invalid') : tr('draft_only')}`)], selected: false }];
177
+ }
@@ -0,0 +1,123 @@
1
+ // Generated by tools/generation/resources.ts; do not edit.
2
+ import type { DiagnoseResult, Scope } from '../generated-contracts.ts';
3
+ import type { Editor } from './draft.ts';
4
+ import { copyDraft } from './draft.ts';
5
+ import { inputKey, inputView, textInput, type TextInput, type TextKey } from './text-input.ts';
6
+ import { t, type Language } from '../i18n/index.ts';
7
+ import { wrapText } from '../../ui/text.ts';
8
+ import { targetLabel } from './profile-manager.ts';
9
+ export interface DiagnosisView {
10
+ path: string;
11
+ scope: Scope;
12
+ observedAt: string;
13
+ includeLocal: boolean;
14
+ cursor: number;
15
+ input: TextInput | null;
16
+ result: DiagnoseResult | null;
17
+ error: string;
18
+ scroll: number;
19
+ busy: boolean;
20
+ report: boolean;
21
+ generation: number;
22
+ }
23
+ export function openDiagnosis(e: Editor): void { e.diagnosis = { path: '', scope: e.detail?.scope ?? (e.page === 'subagents' ? 'subagent' : 'main'), observedAt: '', includeLocal: false, cursor: 0, input: null, result: null, error: '', scroll: 0, busy: false, report: false, generation: 0 }; }
24
+ export function diagnosisRequest(e: Editor, width: number) { const v = e.diagnosis!; return { draft: copyDraft(e.draft), path: v.path, scope: v.scope, width, observed_at: v.observedAt || null, include_local: v.includeLocal }; }
25
+ export function diagnosisKey(e: Editor, event: TextKey): 'diagnoseFile' | null {
26
+ const v = e.diagnosis!, key = event.key, cancel = key === 'escape' || event.ctrl && key.toLowerCase() === 'g';
27
+ if (v.input) {
28
+ if (cancel) {
29
+ v.input = null;
30
+ return null;
31
+ }
32
+ if (key === 'return' && !event.text && !event.paste) {
33
+ v.generation++;
34
+ if (v.cursor === 0)
35
+ v.path = v.input.value;
36
+ else
37
+ v.observedAt = v.input.value;
38
+ v.input = null;
39
+ v.error = '';
40
+ }
41
+ else
42
+ v.input = inputKey(v.input.value, v.input, event, v.cursor === 0 ? 4096 : 128).state;
43
+ return null;
44
+ }
45
+ if (event.text || event.paste || event.meta)
46
+ return null;
47
+ if (cancel) {
48
+ if (v.report) {
49
+ v.report = false;
50
+ v.generation++;
51
+ }
52
+ else
53
+ e.diagnosis = null;
54
+ return null;
55
+ }
56
+ if (v.report) {
57
+ if (key === 'up' || key === 'pageup')
58
+ v.scroll = Math.max(0, v.scroll - (key === 'up' ? 1 : 8));
59
+ if (key === 'down' || key === 'pagedown')
60
+ v.scroll += key === 'down' ? 1 : 8;
61
+ if (key === 'home')
62
+ v.scroll = 0;
63
+ if (key === 'end')
64
+ v.scroll = 1000000;
65
+ return null;
66
+ }
67
+ if (event.ctrl)
68
+ return null;
69
+ if (['up', 'down', 'tab'].includes(key))
70
+ v.cursor = Math.max(0, Math.min(6, v.cursor + (key === 'up' ? -1 : 1)));
71
+ if (key === 'home')
72
+ v.cursor = 0;
73
+ if (key === 'end')
74
+ v.cursor = 6;
75
+ if (['return', 'left', 'right'].includes(key)) {
76
+ if (v.cursor === 0 || v.cursor === 2) {
77
+ v.generation++;
78
+ v.input = textInput(v.cursor === 0 ? v.path : v.observedAt);
79
+ }
80
+ if (v.cursor === 1) {
81
+ v.generation++;
82
+ v.scope = v.scope === 'main' ? 'subagent' : 'main';
83
+ }
84
+ if (v.cursor === 3) {
85
+ v.generation++;
86
+ v.includeLocal = !v.includeLocal;
87
+ }
88
+ if (v.cursor === 4 && !v.busy) {
89
+ v.generation++;
90
+ return 'diagnoseFile';
91
+ }
92
+ if (v.cursor === 5 && v.result)
93
+ v.report = true;
94
+ if (v.cursor === 6)
95
+ e.diagnosis = null;
96
+ }
97
+ return null;
98
+ }
99
+ export function diagnosisLines(e: Editor, language: Language, width: number): string[] {
100
+ const v = e.diagnosis!, r = v.result, tr = (key: string, params: Record<string, unknown> = {}) => t('diagnose.' + key, language, params);
101
+ if (!v.report || !r)
102
+ return wrapText([t('diagnosis.target', language, { target: targetLabel(e, language) }),
103
+ ...[t('diagnosis.path', language) + ': ' + v.path, t('diagnosis.scope', language) + ': ' + v.scope, t('diagnosis.time', language) + ': ' + (v.observedAt || tr('unknown')), t('diagnosis.local', language) + ': ' + t('values.' + (v.includeLocal ? 'on' : 'off'), language), t(v.busy ? 'diagnosis.busy' : 'diagnosis.run', language), t('diagnosis.previous', language), t('colors.cancel', language)].map((line, i) => (i === v.cursor ? '› ' : ' ') + line),
104
+ ...(v.input ? [inputView(v.input, width)] : []), v.error, t('diagnosis.help', language)], width);
105
+ const lines = [t('diagnosis.title', language), t('diagnosis.target', language, { target: targetLabel(e, language) }), tr('source', { value: r.source }), tr('times', { input: r.observed_at ?? tr('unknown'), now: r.diagnosed_at }), t(r.include_local ? 'diagnosis.with_local' : 'diagnosis.input_only', language), tr('identity', { session: r.session_id ?? tr('unknown'), prompt: r.prompt_id ?? tr('unknown') }), tr('output', { width: r.width }), ...r.output.map(row => row.spans.map(s => s.text).join(''))];
106
+ for (const item of r.instances) {
107
+ lines.push('', e.instanceLabel(r.scope, item.id, language) + ' (' + item.id + ')');
108
+ for (const reason of item.reasons)
109
+ lines.push(t('explain.reason.' + reason.code, language));
110
+ for (const evidence of item.evidence) {
111
+ lines.push(tr('evidence', { source: evidence.source, scope: evidence.scope, status: tr('status.' + evidence.status), time: evidence.observed_at ?? tr('unknown'), freshness: tr('freshness.' + evidence.freshness) }));
112
+ for (const field of evidence.fields)
113
+ lines.push(field.path + ': ' + tr('status.' + field.status));
114
+ }
115
+ for (const row of item.rows) {
116
+ lines.push(row.row_id + ': ' + tr('layout.' + row.outcome) + (row.truncated ? ' · ' + tr('layout.truncated') : ''));
117
+ for (const reason of row.style_reasons ?? [])
118
+ lines.push(t('explain.style.' + reason.code, language) + (reason.owner_id ? ' (' + reason.owner_id + ')' : ''));
119
+ }
120
+ }
121
+ lines.push('', tr('limits'));
122
+ return wrapText(lines, width);
123
+ }
@@ -16,6 +16,7 @@ import type {
16
16
  Draft,
17
17
  ReadResult,
18
18
  Scope,
19
+ ConfigTarget,
19
20
  } from '../generated-contracts.ts';
20
21
  import { NUMERIC_FIELDS, numericValue, numericDiagnostic } from './numeric.ts';
21
22
  import { bestMatch, fields, normalize } from './search.ts';
@@ -35,12 +36,19 @@ export function copyDraft(draft: Draft): Draft {
35
36
  export function sameDraft(left: Draft, right: Draft): boolean {
36
37
  return JSON.stringify(left) === JSON.stringify(right);
37
38
  }
39
+ export const definitiveSaveRefusal = (code: string): boolean => ['invalid_request','invalid_configuration','configuration_conflict','not_installed','ownership_mismatch','unsupported_protocol','unsupported_operation'].includes(code);
40
+ export interface PendingSave {
41
+ draft: Draft; revision: string; target?: ConfigTarget; installation: ReadResult['installation'];
42
+ }
38
43
 
39
44
  /** Pure tool draft. Persistence and host configuration calls live in the hook. */
40
45
  export class Editor {
41
46
  draft: Draft;
42
47
  baseline: ReadResult;
43
48
  page: Page = 'main';
49
+ previewScenario: import('./preview-settings.js').PreviewScenario = 'normal';
50
+ previewWidth = 'auto';
51
+ previewOffset = 0;
44
52
  advanced = false;
45
53
  adding = false;
46
54
  pickerSaved: {search:string;category:string;selected:string} | null = null;
@@ -48,6 +56,8 @@ export class Editor {
48
56
  guidanceScroll: number | null = null;
49
57
  review: ReviewState | null = null;
50
58
  quick: QuickSetup | null = null;
59
+ diagnosis: import('./diagnosis-view.js').DiagnosisView | null = null;
60
+ colors: import('./color-manager.js').ColorManager | null = null;
51
61
  explanation: ExplanationView | null = null;
52
62
  profiles: ProfileManager | null = null;
53
63
  sources: SourceManager | null = null;
@@ -66,6 +76,39 @@ export class Editor {
66
76
  buffers: Record<NumericField, string>;
67
77
  fieldErrors: Partial<Record<NumericField, string>> = {};
68
78
  fieldErrorMessages: Partial<Record<NumericField, LocalizedText>> = {};
79
+ saveState: 'idle' | 'pending' | 'unknown' = 'idle';
80
+ pendingSave: PendingSave | null = null;
81
+ mutationGeneration = 0;
82
+
83
+ canMutateDraft(generation = this.mutationGeneration): boolean {
84
+ if (this.saveState === 'idle' && generation === this.mutationGeneration) return true;
85
+ this.compositionError = text('editor.save_locked');
86
+ return false;
87
+ }
88
+ setSaveState(value: Editor['saveState']): void {
89
+ if (this.saveState !== value) this.mutationGeneration++;
90
+ this.saveState = value;
91
+ }
92
+ beginSave(): PendingSave {
93
+ if (!this.canMutateDraft()) throw new Error('A display save is already unresolved');
94
+ this.pendingSave = {draft:copyDraft(this.draft),revision:this.baseline.revision,installation:JSON.parse(JSON.stringify(this.baseline.installation)) as ReadResult['installation'],
95
+ ...(this.baseline.configuration ? {target:JSON.parse(JSON.stringify(this.baseline.configuration.target)) as ConfigTarget} : {})};
96
+ this.setSaveState('pending');
97
+ return this.pendingSave;
98
+ }
99
+ saveFailed(code: string): void {
100
+ const refused = definitiveSaveRefusal(code);
101
+ this.setSaveState(refused ? 'idle' : 'unknown');
102
+ if (refused) this.pendingSave = null;
103
+ }
104
+ reconcileSave(current: ReadResult): 'saved' | 'not_committed' | 'conflict' {
105
+ const submitted = this.pendingSave;
106
+ if (!submitted) throw new Error('No pending display save');
107
+ const outcome = sameDraft(current.draft,submitted.draft) && current.installed && JSON.stringify(current.installation) === JSON.stringify(submitted.installation) ? 'saved' : current.revision === submitted.revision ? 'not_committed' : 'conflict';
108
+ if (outcome === 'saved') this.committed(current);
109
+ else { this.pendingSave=null;this.setSaveState('idle'); }
110
+ return outcome;
111
+ }
69
112
 
70
113
  constructor(
71
114
  public readonly description: DescribeResult,
@@ -87,6 +130,7 @@ export class Editor {
87
130
  }
88
131
 
89
132
  replaceDraft(draft: Draft): void {
133
+ if (!this.canMutateDraft()) return;
90
134
  this.draft = copyDraft(draft);
91
135
  for (const scope of ['main', 'subagent'] as const) {
92
136
  this.order[scope] = nodes(this.draft,scope).map(i=>i.id);
@@ -157,6 +201,7 @@ export class Editor {
157
201
  this.adding=false;this.pickerSaved=null;
158
202
  }
159
203
  instanceAction(scope: Scope, action:'add'|'copy'|'remove', typeId?:string): boolean {
204
+ if (!this.canMutateDraft()) return false;
160
205
  this.compositionError = text('composition.invalid');
161
206
  const draft=copyDraft(this.draft), list=nodes(draft,scope);
162
207
  const selected=this.adding ? this.pickerSaved?.selected : this.selected[scope];
@@ -202,6 +247,7 @@ export class Editor {
202
247
  }
203
248
 
204
249
  toggle(scope: Scope, id: string): boolean {
250
+ if (!this.canMutateDraft()) return false;
205
251
  this.compositionError = text('composition.invalid');
206
252
  if(this.adding)return this.instanceAction(scope,'add',id);
207
253
  const draft=copyDraft(this.draft),node=nodes(draft,scope).find(i=>i.id===id);
@@ -212,6 +258,7 @@ export class Editor {
212
258
  }
213
259
 
214
260
  move(scope: Scope, delta: -1 | 1): boolean {
261
+ if (!this.canMutateDraft()) return false;
215
262
  this.compositionError = text('composition.invalid');
216
263
  if (this.adding || this.filtered(scope)) return false;
217
264
  const visible = this.visible(scope).map((item) => item.id as string);
@@ -238,6 +285,7 @@ export class Editor {
238
285
  }
239
286
 
240
287
  setBuffer(field: NumericField, value: string): void {
288
+ if (!this.canMutateDraft()) return;
241
289
  this.activeNumeric = field;
242
290
  this.buffers[field] = value;
243
291
  delete this.fieldErrors[field];
@@ -254,6 +302,7 @@ export class Editor {
254
302
  }
255
303
 
256
304
  acceptNumeric(field?: NumericField): boolean {
305
+ if (!this.canMutateDraft()) return false;
257
306
  const values: Partial<Record<NumericField, number | 'event'>> = {};
258
307
  const fields = field ? [field] : NUMERIC_FIELDS;
259
308
  for (const key of fields) {
@@ -273,6 +322,7 @@ export class Editor {
273
322
  }
274
323
 
275
324
  committed(current: ReadResult): void {
325
+ this.pendingSave=null;this.setSaveState('idle');
276
326
  this.baseline = { ...current, draft: copyDraft(current.draft) };
277
327
  this.draft = copyDraft(current.draft);
278
328
  this.cancelNumeric();
@@ -18,7 +18,7 @@ export function explanationLines(editor:Editor,language:Language,width:number):
18
18
  const view=editor.explanation!;
19
19
  const tr=(key:string,params:Record<string,unknown>={})=>t('explain.'+key,language,params);
20
20
  const item=view.result?.instances.find(item=>item.id===view.id);
21
- const lines=[tr('sample'),editor.instanceLabel(view.scope,view.id,language)+' ('+view.id+')'];
21
+ const lines=[tr('sample')+' · '+t('preview.scenario.'+(view.result?.preview.scenario??editor.previewScenario),language),editor.instanceLabel(view.scope,view.id,language)+' ('+view.id+')'];
22
22
  if(!item) return wrapText([...lines,view.error||tr('loading')],width);
23
23
  for(const [heading,origins] of [['configuration',['configuration']],['requirements',['local_configuration','host_capability','unknown']]] as const) {
24
24
  lines.push('',tr(heading));
@@ -29,6 +29,7 @@ export function explanationLines(editor:Editor,language:Language,width:number):
29
29
  for(const sample of item.samples) {
30
30
  lines.push(tr('row.'+sample.row_id)+': '+tr('reason.'+sample.outcome));
31
31
  if(sample.truncated) lines.push(tr('reason.sample_truncated'));
32
+ for(const reason of sample.style_reasons??[])lines.push(tr('style.'+reason.code)+(reason.owner_id?' ('+reason.owner_id+')':''));
32
33
  }
33
34
  lines.push('',tr('panel_note'));
34
35
  return wrapText(lines,width);
@@ -95,6 +95,7 @@ function options(draft: Draft, scope: 'main' | 'subagent', id: string) {
95
95
  }
96
96
  export function setFormValue(view: FormView, current: FormRow, raw: string | boolean): boolean {
97
97
  const e = view.editor!;
98
+ if (!e.canMutateDraft()) { setMessage(view, 'message', e.compositionError); return false; }
98
99
  const spec = current.spec;
99
100
  let value: unknown = raw;
100
101
  if (spec.kind === 'integer') {
@@ -5,6 +5,14 @@ export const GRADIENT_PRESETS = {
5
5
  ocean: ['#22d3ee', '#3b82f6'],
6
6
  sunset: ['#fb923c', '#f472b6', '#a78bfa'],
7
7
  aurora: ['#34d399', '#22d3ee', '#a78bfa'],
8
+ glacier: ['#67e8f9', '#60a5fa', '#818cf8'],
9
+ lagoon: ['#0c4a6e', '#164e63', '#1e3a8a'],
10
+ flame: ['#fbbf24', '#f97316', '#ef4444'],
11
+ copper: ['#7c2d12', '#78350f', '#831843'],
12
+ steel: ['#94a3b8', '#b8c4d1', '#cbd5e1'],
13
+ sage: ['#304c40', '#405647', '#455663'],
14
+ petal: ['#fbcfe8', '#e9d5ff', '#dbeafe'],
15
+ twilight: ['#c4b5fd', '#f9a8d4', '#fdba74'],
8
16
  } as const;
9
17
  export const GRADIENT_KEYS = ['foreground_gradient', 'background_gradient'] as const;
10
18
  export const GRADIENT_DEFAULTS = { foreground_gradient: null, background_gradient: null };
@@ -27,3 +35,5 @@ export function gradientName(value: unknown): string {
27
35
  if (value == null) return 'off';
28
36
  return Object.entries(GRADIENT_PRESETS).find(([, colors]) => JSON.stringify(colors) === JSON.stringify(value))?.[0] ?? String(value);
29
37
  }
38
+
39
+ export const GRADIENT_SURFACES: Record<keyof typeof GRADIENT_PRESETS, 'dark' | 'light'> = {ocean:'dark',sunset:'dark',aurora:'dark',glacier:'dark',lagoon:'light',flame:'dark',copper:'light',steel:'dark',sage:'light',petal:'dark',twilight:'dark'};
@@ -32,6 +32,7 @@ function form(e: Editor, g?: GroupDraft): void {
32
32
  }
33
33
  function apply(e: Editor, edit: GroupEdit): void {
34
34
  const m = e.groupManager!;
35
+ if (!e.canMutateDraft()) { m.error=true;m.errorMessage=e.compositionError;return; }
35
36
  try {
36
37
  const display = editGroup(e.draft.display, m.scope, edit, () => newInstance('text', groupScope(e.draft.display, m.scope).instances).id);
37
38
  if (!isDraft({ ...e.draft, display })) throw new Error('invalid');
@@ -0,0 +1,8 @@
1
+ // Generated by tools/generation/resources.ts; do not edit.
2
+ /** Session-only controls; never part of a display draft or portable file. */
3
+ export const SCENARIO_IDS = ['normal', 'warning', 'critical', 'zero', 'missing', 'source-stale', 'source-failed', 'long-content', 'git-clean', 'git-modified', 'git-conflicted', 'no-agents', 'few-agents', 'many-agents'] as const;
4
+ export type PreviewScenario = typeof SCENARIO_IDS[number];
5
+ export const PREVIEW_WIDTHS = ['auto', '40', '80', '120'] as const;
6
+ export function isScenario(value: unknown): value is PreviewScenario { return typeof value === 'string' && (SCENARIO_IDS as readonly string[]).includes(value); }
7
+ export function previewWidth(available: number, requested: string): number { return Math.max(2, Math.min(available, requested === 'auto' ? available : Number(requested))); }
8
+ export function cyclePreview<T>(values: readonly T[], value: T, delta: number): T { return values[(values.indexOf(value) + delta + values.length) % values.length]!; }
@@ -162,7 +162,11 @@ export async function performProfileAction(e: Editor, backend: ProfileBackend):
162
162
  if (!m || !effect) return;
163
163
  m.effect = null;
164
164
  let writing = false;
165
+ let savingDisplay = false;
165
166
  try {
167
+ let generation=e.mutationGeneration;
168
+ const permitted=()=>e.profiles===m && e.canMutateDraft(generation);
169
+ if (!['load','export'].includes(effect.kind) && !e.canMutateDraft()) { m.message=e.compositionError;return; }
166
170
  if (effect.kind === 'load') {
167
171
  const copy = m.action === 'save' && m.candidate !== null;
168
172
  m.library = await backend.request('profiles_read'); m.page = 'list'; m.cursor = 0;
@@ -172,12 +176,13 @@ export async function performProfileAction(e: Editor, backend: ProfileBackend):
172
176
  if (effect.kind === 'switch') {
173
177
  if (effect.save) {
174
178
  if (!e.acceptNumeric()) throw new BackendError('invalid_draft', text('profiles.invalid_draft'));
175
- writing = true;
176
- const saved = await backend.request('apply', { draft: e.draft, expected_revision: e.baseline.revision,
177
- ...(e.baseline.configuration ? { target: e.baseline.configuration.target } : {}) });
178
- e.committed(saved); writing = false;
179
+ const submitted=e.beginSave();writing = true;savingDisplay=true;
180
+ const saved = await backend.request('apply', { draft: submitted.draft, expected_revision: submitted.revision,
181
+ ...(submitted.target ? { target: submitted.target } : {}) });
182
+ e.committed(saved); writing = false;savingDisplay=false;generation=e.mutationGeneration;
179
183
  }
180
184
  const current = await backend.request('read', { target: effect.next.target });
185
+ if(!permitted()) {m.message=e.compositionError;return;}
181
186
  e.committed(current);
182
187
  e.replaceDraft(current.draft);
183
188
  if (effect.next.display) e.replaceDraft({ ...current.draft, display: JSON.parse(JSON.stringify(effect.next.display)) as DisplayDraft });
@@ -186,6 +191,7 @@ export async function performProfileAction(e: Editor, backend: ProfileBackend):
186
191
  if (effect.kind === 'import' || effect.kind === 'reuse') {
187
192
  const original = JSON.stringify(e.draft);
188
193
  const result = await backend.request('profile_import', { path: effect.path });
194
+ if(!permitted()) {m.message=e.compositionError;return;}
189
195
  if (effect.kind === 'reuse') {
190
196
  if (JSON.stringify(e.draft) !== original || e.profiles !== m) throw new BackendError('stale_import', text('review.stale'));
191
197
  const draft = { display: result.display, host: e.draft.host };
@@ -204,10 +210,12 @@ export async function performProfileAction(e: Editor, backend: ProfileBackend):
204
210
  if (effect.payload.bind_path && typeof effect.payload.bind_path === 'string') {
205
211
  const host = e.draft.host;
206
212
  const current = await backend.request('read', { target: { kind: 'project', path: effect.payload.bind_path } });
213
+ if(!permitted()) {m.message=e.compositionError;return;}
207
214
  e.committed(current); e.replaceDraft({ ...current.draft, host });
208
215
  } else if (e.baseline.configuration && (e.baseline.configuration.target.kind !== 'profile' ||
209
216
  m.library.profiles.some(p=>p.id===e.baseline.configuration!.profile_id))) {
210
217
  const current = await backend.request('read', { target: e.baseline.configuration.target });
218
+ if(!permitted()) {m.message=e.compositionError;return;}
211
219
  if (current.configuration?.profile_id === e.baseline.configuration.profile_id &&
212
220
  JSON.stringify(current.draft) === JSON.stringify(e.baseline.draft)) e.baseline = current;
213
221
  }
@@ -215,12 +223,13 @@ export async function performProfileAction(e: Editor, backend: ProfileBackend):
215
223
  m.page = 'list'; m.cursor = 0; m.candidate = null; m.confirmation = null; m.message = text('profiles.saved');
216
224
  } catch (error) {
217
225
  const code = error instanceof BackendError ? error.code : '';
226
+ if(savingDisplay)e.saveFailed(code);
218
227
  if (code === 'profile_duplicate' || code === 'profile_bound' || effect.kind === 'export' && code === 'io_error' && /EEXIST/u.test(String(error))) {
219
228
  m.confirmation = effect.kind === 'mutation' ? { ...effect, payload: { ...effect.payload, overwrite: true } }
220
229
  : effect.kind === 'export' ? { ...effect, overwrite: true } : null;
221
230
  m.page = 'confirm'; m.cursor = 1; m.message = text('profiles.overwrite');
222
231
  } else {
223
- m.uncertain = writing && !['profile_conflict','profile_referenced','profile_invalid','profile_name','profile_path','ownership_mismatch','configuration_conflict','invalid_request','profile_size'].includes(code);
232
+ m.uncertain = !savingDisplay && writing && !['profile_conflict','profile_referenced','profile_invalid','profile_name','profile_path','ownership_mismatch','configuration_conflict','invalid_request','profile_size'].includes(code);
224
233
  m.message = error instanceof BackendError && error.localization ? error.localization : text('profiles.failed', { value: error instanceof Error ? error.message : String(error) });
225
234
  }
226
235
  }
@@ -76,6 +76,7 @@ export function quickView(quick: QuickSetup, language: Language, width: number,
76
76
  export function controlQuick(editor: Editor, key: string): 'transfer' | 'save' | 'profiles' | null {
77
77
  const quick = editor.quick;
78
78
  if (!quick) return null;
79
+ if (!editor.canMutateDraft() && !['cancel','escape','tab','up','down','home','end','pageup','pagedown'].includes(key)) return null;
79
80
  const effect = quickKey(quick,key);
80
81
  if (effect === 'cancel') editor.quick = null;
81
82
  if (effect === 'preset') { editor.preset=quick.preset; editor.pendingTransfer='preset'; return 'transfer'; }
@@ -1,4 +1,5 @@
1
1
  // Generated by tools/generation/resources.ts; do not edit.
2
+ import { SCENARIO_IDS, PREVIEW_WIDTHS, cyclePreview, type PreviewScenario } from './preview-settings.ts';
2
3
  import type { Draft } from '../generated-contracts.ts';
3
4
  import { LANGUAGES, type Language, type LocalizedText } from '../i18n/index.ts';
4
5
  import { copyDraft } from './draft.ts';
@@ -17,6 +18,9 @@ export type SetupEffect = 'cancel' | 'interrupt' | 'preset' | 'language' | 'save
17
18
  /** The wizard holds only drafts; effects are executed by its CLI/TUI adapters. */
18
19
  export class SetupState {
19
20
  phase: 'checks' | 'choice' | 'quick' | 'review' = 'checks';
21
+ previewScenario:PreviewScenario='normal';
22
+ previewWidth='auto';
23
+ previewOffset=0;
20
24
  selected = 0;
21
25
  scroll = 0;
22
26
  quick: QuickSetup | null = null;
@@ -25,6 +29,9 @@ export class SetupState {
25
29
  constructor(readonly facts: SetupFacts, public language: Language) { this.candidate = facts.draft ? copyDraft(facts.draft) : null; }
26
30
  receive(draft: Draft): void { receivePreset(this.quick!, draft); }
27
31
  key(key: string): SetupEffect {
32
+ if(key==='preview-scenario'){this.previewScenario=cyclePreview(SCENARIO_IDS,this.previewScenario,1);this.previewOffset=0;return null;}
33
+ if(key==='preview-width'){this.previewWidth=cyclePreview(PREVIEW_WIDTHS,this.previewWidth as typeof PREVIEW_WIDTHS[number],1);return null;}
34
+ if(key==='preview-next'){this.previewOffset++;return null;}
28
35
  if (key === 'interrupt') return 'interrupt';
29
36
  if (key === 'escape' || key === 'cancel') return 'cancel';
30
37
  if (key === 'l') { this.language = LANGUAGES[(LANGUAGES.indexOf(this.language) + 1) % LANGUAGES.length]!; return 'language'; }