@fbincon/claude-code-statusline 3.9.0 → 3.9.1

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 (30) hide show
  1. package/README.md +92 -80
  2. package/candidate.json +94 -75
  3. package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.d.ts +437 -1
  4. package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.js +5 -1
  5. package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.js.map +1 -1
  6. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/.claude-plugin/plugin.json +1 -1
  7. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/hooks/register.ts +85 -19
  8. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/generated-locales.ts +36 -6
  9. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/session.ts +28 -90
  10. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/resource-manifest.json +12 -11
  11. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/draw.ts +7 -4
  12. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/surface.ts +16 -13
  13. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/components/preview.ts +9 -5
  14. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/components/section.ts +11 -7
  15. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/components/shortcuts.ts +5 -1
  16. package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/frame.ts +72 -0
  17. package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/.claude-plugin/plugin.json +1 -1
  18. package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/resource-manifest.json +3 -3
  19. package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.d.ts +30 -0
  20. package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js +36 -6
  21. package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js.map +1 -1
  22. package/node_modules/@fbincon/statusline-core/dist/src/release.d.ts +1 -1
  23. package/node_modules/@fbincon/statusline-core/dist/src/release.js +1 -1
  24. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/en.json +6 -1
  25. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ja.json +6 -1
  26. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ko.json +6 -1
  27. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-CN.json +6 -1
  28. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-HK.json +6 -1
  29. package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-TW.json +6 -1
  30. package/package.json +1 -1
@@ -24,10 +24,11 @@ import type {
24
24
  Operation,
25
25
  ResultFor,
26
26
  } from '../lib/generated-contracts.ts';
27
- import { MIN_COLUMNS, MIN_ROWS, contentColumns } from '../ui/layout.ts';
27
+ import { MIN_COLUMNS, MIN_ROWS, contentColumns, clip } from '../ui/layout.ts';
28
28
  import { recoveryButton, styles } from '../ui/theme.ts';
29
29
  import { clientProps } from '../lib/session.ts';
30
30
  import type { View } from '../lib/session.ts';
31
+ import { withinBudget } from '../ui/frame.ts';
31
32
  import { parseBatch } from '../lib/client/messages.ts';
32
33
  import { handleKey } from '../lib/client/keys.ts';
33
34
  import { DEFAULT_PREVIEW_BACKGROUND, PREVIEW_BACKGROUND_KEY, previewBackground } from '../lib/preview-preferences.ts';
@@ -112,6 +113,9 @@ interface Session {
112
113
  generation: number;
113
114
  columns: number;
114
115
  rows: number;
116
+ displayColumns: number;
117
+ displayRows: number;
118
+ saveOutcome: 'none' | 'pending' | 'saved' | 'unknown' | 'refused';
115
119
  placed: boolean;
116
120
  clientFault: string;
117
121
  inputChain: Promise<void>;
@@ -133,17 +137,26 @@ function discard(state: Session): void {
133
137
  state.ack = 0;
134
138
  state.placed = false;
135
139
  state.clientFault = '';
140
+ state.saveOutcome = 'none';
136
141
  }
137
142
 
138
143
  function props(state: Session) {
139
- return clientProps(
140
- state.view,
141
- state.epoch,
142
- state.ack,
143
- ++state.generation,
144
- state.columns,
145
- state.rows,
146
- );
144
+ try {
145
+ const projected = clientProps(state.view, state.epoch, state.ack, ++state.generation, state.columns, state.rows);
146
+ state.displayColumns = projected.displayColumns;
147
+ state.displayRows = projected.displayRows;
148
+ return projected;
149
+ } catch (error) {
150
+ state.clientFault = failureText(error).slice(0, 200);
151
+ return null;
152
+ }
153
+ }
154
+
155
+ function clientReply($: EngineInterface, state: Session) {
156
+ const projected = props(state);
157
+ if (projected && !state.clientFault) return { props: projected };
158
+ $.ui.invalidate('ui.render');
159
+ return {};
147
160
  }
148
161
 
149
162
  async function load(
@@ -232,12 +245,15 @@ async function reconcile(
232
245
  JSON.stringify(editor.baseline.installation)
233
246
  ) {
234
247
  editor.committed(current);
248
+ state.saveOutcome = 'saved';
235
249
  setMessage(state.view, "message", localizedText("native.hooks.register.the_submitted_tool_configuration_is_saved"));
236
250
  state.view.error = '';
237
251
  } else if (current.revision === submitted.revision) {
252
+ state.saveOutcome = 'refused';
238
253
  setMessage(state.view, "message", localizedText("native.hooks.register.no_tool_changes_were_committed_review_the_draft"));
239
254
  state.view.error = '';
240
255
  } else {
256
+ state.saveOutcome = 'refused';
241
257
  setMessage(state.view, "error", localizedText("native.hooks.register.configuration_conflict_saved_configuration_differs_discard_the_draft"));
242
258
  }
243
259
  state.pendingSave = null;
@@ -275,6 +291,7 @@ async function save(
275
291
  revision: editor.baseline.revision,
276
292
  };
277
293
  state.pendingSave = submitted;
294
+ state.saveOutcome = 'pending';
278
295
  state.writing = true;
279
296
  setMessage(state.view, "busy", localizedText("native.hooks.register.saving_tool_configuration"));
280
297
  state.view.error = '';
@@ -290,6 +307,7 @@ async function save(
290
307
  editor.committed(result);
291
308
  state.pendingSave = null;
292
309
  saved = true;
310
+ state.saveOutcome = 'saved';
293
311
  setMessage(state.view, "message", (result.changed ? localizedText("native.hooks.register.tool_configuration_saved_later_statusline_refreshes_use_these") : localizedText("native.hooks.register.tool_configuration_is_already_current")));
294
312
  } catch (failure) {
295
313
  if (state.epoch !== saving) return;
@@ -305,6 +323,7 @@ async function save(
305
323
  'unsupported_operation',
306
324
  ].includes(error.code);
307
325
  state.view.uncertain = !refused;
326
+ state.saveOutcome = refused ? 'refused' : 'unknown';
308
327
  if (refused) state.pendingSave = null;
309
328
  } finally {
310
329
  if (state.epoch === saving) {
@@ -578,6 +597,9 @@ export const register: Register = (on, options) => {
578
597
  generation: 0,
579
598
  columns: 72,
580
599
  rows: 24,
600
+ displayColumns: 72,
601
+ displayRows: 24,
602
+ saveOutcome: 'none',
581
603
  placed: false,
582
604
  clientFault: '',
583
605
  inputChain: Promise.resolve(),
@@ -635,10 +657,21 @@ export const register: Register = (on, options) => {
635
657
  return result;
636
658
  });
637
659
 
660
+ // Namespace registration remains valid on hosts predating ui.fault.
661
+ on('ui.*', { component: 'Pane', requestId: PANE }, async ($, e, next) => {
662
+ if (String(next.event) === 'ui.fault' && state.ownsCommand) {
663
+ const fault = e as unknown as { component?: string; requestId?: string; element?: string; module?: string; surface?: string; reason?: unknown };
664
+ if (fault.component === 'Pane' && fault.requestId === PANE && fault.element === 'statusline-client-' + state.epoch && fault.module === 'ui/client/surface.ts' && fault.surface === 'terminal') {
665
+ state.clientFault = failureText(fault.reason).slice(0, 200);
666
+ }
667
+ }
668
+ return next(e);
669
+ });
670
+
638
671
  on('ui.message', { component: 'Pane' }, async ($, e, next) => {
639
672
  if (
640
673
  e.requestId !== PANE ||
641
- e.element !== 'statusline-client' ||
674
+ e.element !== 'statusline-client-' + state.epoch ||
642
675
  e.module !== 'ui/client/surface.ts' ||
643
676
  e.surface !== 'terminal' ||
644
677
  !state.ownsCommand
@@ -661,11 +694,16 @@ export const register: Register = (on, options) => {
661
694
  const batch = parseBatch(e.data);
662
695
  if (!batch) {
663
696
  setMessage(state.view, "error", localizedText("native.hooks.register.invalid_client_input_retry_the_client_region"));
664
- return { props: props(state) };
697
+ return clientReply($, state);
665
698
  }
666
699
  const run = state.inputChain.then(async () => {
667
700
  if (batch.epoch !== state.epoch || !state.placed) return {};
668
701
  const currentEpoch = state.epoch;
702
+ if (state.columns !== batch.columns || state.rows !== batch.rows) {
703
+ state.columns = batch.columns;
704
+ state.rows = batch.rows;
705
+ props(state);
706
+ }
669
707
  for (const message of batch.events) {
670
708
  if (message.seq <= state.ack) continue;
671
709
  if (message.seq !== state.ack + 1) {
@@ -677,8 +715,8 @@ export const register: Register = (on, options) => {
677
715
  const effect = handleKey(
678
716
  state.view,
679
717
  message.event,
680
- batch.columns,
681
- batch.rows,
718
+ state.displayColumns,
719
+ state.displayRows,
682
720
  );
683
721
  if (effect === 'save' || effect === 'finish') {
684
722
  await save($, state, options, effect === 'finish');
@@ -744,13 +782,18 @@ export const register: Register = (on, options) => {
744
782
  }
745
783
  $.ui.invalidate('ui.render');
746
784
  if (state.epoch !== currentEpoch) return {};
747
- return { props: props(state) };
785
+ return clientReply($, state);
748
786
  });
749
787
  state.inputChain = run.then(
750
788
  () => {},
751
789
  () => {},
752
790
  );
753
791
  return run;
792
+ }).catch(($, e, next) => {
793
+ if (e.requestId !== PANE || !state.ownsCommand) return next(e);
794
+ state.clientFault = failureText(next.error.message ?? 'Client reply failed').slice(0, 200);
795
+ $.ui.invalidate('ui.render');
796
+ return {};
754
797
  });
755
798
 
756
799
  on('ui.render', { component: 'Pane' }, async ($, e, next) => {
@@ -826,17 +869,18 @@ export const register: Register = (on, options) => {
826
869
  width >= MIN_COLUMNS &&
827
870
  height >= MIN_ROWS
828
871
  ) {
829
- return Box({
872
+ const projected = props(state);
873
+ const tree = projected ? Box({
830
874
  width,
831
875
  height,
832
876
  flexDirection: 'column',
833
877
  children: [
834
878
  Client({
835
- key: 'statusline-client',
879
+ key: 'statusline-client-' + state.epoch,
836
880
  module: '../ui/client/surface.ts',
837
881
  width,
838
882
  height,
839
- props: props(state),
883
+ props: projected,
840
884
  }),
841
885
  Box({
842
886
  position: 'absolute',
@@ -857,7 +901,9 @@ export const register: Register = (on, options) => {
857
901
  ],
858
902
  }),
859
903
  ],
860
- });
904
+ }) : null;
905
+ if (tree && withinBudget(tree)) return tree;
906
+ state.clientFault ||= tr('native.capacity.failed');
861
907
  }
862
908
  return Box({
863
909
  backgroundColor: styles.text.backgroundColor,
@@ -882,8 +928,12 @@ export const register: Register = (on, options) => {
882
928
  Text({
883
929
  ...styles.error,
884
930
  wrap: 'truncate',
885
- children: [state.clientFault || viewMessage(state.view, 'error') || ' '],
931
+ children: [clip((state.clientFault || viewMessage(state.view, 'error') || ' ').slice(0, 200), Math.min(width, 200))],
886
932
  }),
933
+ Text({ ...styles.text, wrap: 'truncate', children: [clip(
934
+ state.saveOutcome === 'saved' ? tr('native.capacity.saved') : state.view.uncertain ? tr('native.capacity.unknown') : state.writing ? viewMessage(state.view, 'busy') : tr('native.capacity.retained'),
935
+ Math.min(width, 200),
936
+ )] }),
887
937
  ...(state.view.uncertain
888
938
  ? [
889
939
  Button({
@@ -915,5 +965,21 @@ export const register: Register = (on, options) => {
915
965
  }),
916
966
  ],
917
967
  });
968
+ }).catch(($, e, next) => {
969
+ if (e.requestId !== PANE || !state.ownsCommand || e.surface !== 'terminal') return next(e);
970
+ state.clientFault = failureText(next.error.message ?? 'Pane rendering failed').slice(0, 200);
971
+ $.ui.invalidate('ui.render');
972
+ const { Box, Text, Button } = $.ui.resolve(e);
973
+ return Box({ flexDirection: 'column', children: [
974
+ Text({ children: [tr('native.capacity.failed')] }),
975
+ Text({ children: [state.saveOutcome === 'saved' ? tr('native.capacity.saved') : state.view.uncertain ? tr('native.capacity.unknown') : tr('native.capacity.retained')] }),
976
+ Button({ ...recoveryButton, key: 'retry-client', label: tr('native.hooks.register.retry_client'), onPress: () => {
977
+ if (state.writing || state.view.uncertain) return;
978
+ state.epoch++; state.ack = 0; state.clientFault = '';
979
+ $.ui.invalidate('ui.render');
980
+ } }),
981
+ ...(state.view.uncertain ? [Button({ ...recoveryButton, key: 'reconcile', label: tr('native.hooks.register.check_saved_state'), onPress: () => reconcile($, state, options) })] : []),
982
+ Button({ ...recoveryButton, key: 'close', label: tr('native.hooks.register.discard_pending_close'), onPress: () => close($, state, options) }),
983
+ ] });
918
984
  });
919
985
  };
@@ -1973,7 +1973,12 @@ export const LOCALES = {
1973
1973
  "alignment.references": "Adjust these alignment relationships before changing the layout: {ids}.",
1974
1974
  "gradients.preset.ocean": "Ocean",
1975
1975
  "gradients.preset.sunset": "Sunset",
1976
- "gradients.preset.aurora": "Aurora"
1976
+ "gradients.preset.aurora": "Aurora",
1977
+ "native.capacity.reduced": "View limited to {columns}×{rows}; use paging.",
1978
+ "native.capacity.failed": "The editor cannot draw this view.",
1979
+ "native.capacity.saved": "The last save succeeded. Retry only redraws the editor.",
1980
+ "native.capacity.unknown": "Save outcome unknown. Check saved state before retrying.",
1981
+ "native.capacity.retained": "Received draft retained; retry does not save or discard it."
1977
1982
  },
1978
1983
  "zh-CN": {
1979
1984
  "preferences.read_failed": "无法读取 {path} 的界面偏好,使用英文:{detail}",
@@ -3940,7 +3945,12 @@ export const LOCALES = {
3940
3945
  "alignment.references": "请先调整这些对齐关系,再更改布局:{ids}。",
3941
3946
  "gradients.preset.ocean": "海洋 (ocean)",
3942
3947
  "gradients.preset.sunset": "落日 (sunset)",
3943
- "gradients.preset.aurora": "极光 (aurora)"
3948
+ "gradients.preset.aurora": "极光 (aurora)",
3949
+ "native.capacity.reduced": "展示范围缩至 {columns}×{rows},可继续翻页。",
3950
+ "native.capacity.failed": "编辑器暂时无法绘制此视图。",
3951
+ "native.capacity.saved": "上次保存已成功;重试只会重新绘制界面。",
3952
+ "native.capacity.unknown": "保存结果未知,请先核对已保存状态。",
3953
+ "native.capacity.retained": "已接收的草稿仍保留;重试不会保存或丢弃草稿。"
3944
3954
  },
3945
3955
  "zh-TW": {
3946
3956
  "preferences.read_failed": "無法讀取 {path} 的介面偏好,使用英文:{detail}",
@@ -5907,7 +5917,12 @@ export const LOCALES = {
5907
5917
  "alignment.references": "請先調整這些對齊關係,再變更配置:{ids}。",
5908
5918
  "gradients.preset.ocean": "海洋 (ocean)",
5909
5919
  "gradients.preset.sunset": "落日 (sunset)",
5910
- "gradients.preset.aurora": "極光 (aurora)"
5920
+ "gradients.preset.aurora": "極光 (aurora)",
5921
+ "native.capacity.reduced": "顯示範圍縮至 {columns}×{rows},可繼續翻頁。",
5922
+ "native.capacity.failed": "編輯器暫時無法繪製此檢視。",
5923
+ "native.capacity.saved": "上次儲存已成功;重試只會重新繪製介面。",
5924
+ "native.capacity.unknown": "儲存結果未知,請先核對已儲存狀態。",
5925
+ "native.capacity.retained": "已接收的草稿仍保留;重試不會儲存或捨棄草稿。"
5911
5926
  },
5912
5927
  "zh-HK": {
5913
5928
  "preferences.read_failed": "無法讀取 {path} 的介面偏好,使用英文:{detail}",
@@ -7874,7 +7889,12 @@ export const LOCALES = {
7874
7889
  "alignment.references": "請先調整這些對齊關係,再更改佈局:{ids}。",
7875
7890
  "gradients.preset.ocean": "海洋 (ocean)",
7876
7891
  "gradients.preset.sunset": "落日 (sunset)",
7877
- "gradients.preset.aurora": "極光 (aurora)"
7892
+ "gradients.preset.aurora": "極光 (aurora)",
7893
+ "native.capacity.reduced": "顯示範圍縮至 {columns}×{rows},可繼續翻頁。",
7894
+ "native.capacity.failed": "編輯器暫時無法繪製此畫面。",
7895
+ "native.capacity.saved": "上次儲存已成功;重試只會重新繪製介面。",
7896
+ "native.capacity.unknown": "儲存結果未知,請先核對已儲存狀態。",
7897
+ "native.capacity.retained": "已接收的草稿仍保留;重試不會儲存或捨棄草稿。"
7878
7898
  },
7879
7899
  "ja": {
7880
7900
  "preferences.read_failed": "{path} の UI 設定を読み込めません。英語を使用します: {detail}",
@@ -9841,7 +9861,12 @@ export const LOCALES = {
9841
9861
  "alignment.references": "レイアウトを変更する前に、次の整列関係を調整してください:{ids}。",
9842
9862
  "gradients.preset.ocean": "海 (ocean)",
9843
9863
  "gradients.preset.sunset": "夕日 (sunset)",
9844
- "gradients.preset.aurora": "オーロラ (aurora)"
9864
+ "gradients.preset.aurora": "オーロラ (aurora)",
9865
+ "native.capacity.reduced": "表示を {columns}×{rows} に制限しました。ページ移動できます。",
9866
+ "native.capacity.failed": "この画面を描画できません。",
9867
+ "native.capacity.saved": "前回の保存は成功しました。再試行は再描画のみです。",
9868
+ "native.capacity.unknown": "保存結果が不明です。再試行前に保存状態を確認してください。",
9869
+ "native.capacity.retained": "受信済みの下書きは保持されています。再試行では保存も破棄もしません。"
9845
9870
  },
9846
9871
  "ko": {
9847
9872
  "preferences.read_failed": "{path}의 UI 환경설정을 읽을 수 없어 영어를 사용합니다: {detail}",
@@ -11808,7 +11833,12 @@ export const LOCALES = {
11808
11833
  "alignment.references": "레이아웃을 변경하기 전에 다음 정렬 관계를 조정하세요: {ids}.",
11809
11834
  "gradients.preset.ocean": "바다 (ocean)",
11810
11835
  "gradients.preset.sunset": "노을 (sunset)",
11811
- "gradients.preset.aurora": "오로라 (aurora)"
11836
+ "gradients.preset.aurora": "오로라 (aurora)",
11837
+ "native.capacity.reduced": "표시 영역을 {columns}×{rows}로 줄였습니다. 페이지를 이동할 수 있습니다.",
11838
+ "native.capacity.failed": "이 화면을 그릴 수 없습니다.",
11839
+ "native.capacity.saved": "마지막 저장이 완료되었습니다. 재시도는 화면만 다시 그립니다.",
11840
+ "native.capacity.unknown": "저장 결과를 알 수 없습니다. 재시도 전에 저장 상태를 확인하세요.",
11841
+ "native.capacity.retained": "받은 초안은 유지됩니다. 재시도는 초안을 저장하거나 버리지 않습니다."
11812
11842
  }
11813
11843
  } as const;
11814
11844
  export type MessageKey = keyof typeof LOCALES.en;
@@ -1,10 +1,14 @@
1
1
  import type { TextInput } from './editor/text-input.ts';
2
- import { Editor } from './editor/draft.ts';
2
+ import type { Editor } from './editor/draft.ts';
3
3
  import type { Scope, PreviewResult } from './generated-contracts.ts';
4
4
  import type { Preference } from './preferences.ts';
5
5
  import type { PreviewBackground } from './preview-preferences.ts';
6
6
  import type { Language, LocalizedText } from './i18n/index.ts';
7
7
  import type { MessageSlot } from './i18n/messages.ts';
8
+ import { t } from './i18n/index.ts';
9
+ import { draw } from '../ui/client/draw.ts';
10
+ import { CapacityError, frameElements, frameTree, withinBudget } from '../ui/frame.ts';
11
+ import type { Frame } from '../ui/frame.ts';
8
12
 
9
13
  export type InputMode = (
10
14
  | { kind: 'search'; scope: Scope; original: string; selected: string }
@@ -31,101 +35,35 @@ export interface View {
31
35
  uncertain: boolean;
32
36
  }
33
37
 
34
- type EditorData = Pick<
35
- Editor,
36
- | 'description'
37
- | 'baseline'
38
- | 'draft'
39
- | 'page'
40
- | 'advanced'
41
- | 'adding'
42
- | 'pickerSaved'
43
- | 'detail'
44
- | 'guidanceScroll'
45
- | 'explanation'
46
- | 'profiles'
47
- | 'sources'
48
- | 'quick'
49
- | 'groupManager'
50
- | 'alignmentManager'
51
- | 'review'
52
- | 'preset'
53
- | 'path'
54
- | 'pendingTransfer'
55
- | 'setting'
56
- | 'activeNumeric'
57
- | 'selected'
58
- | 'order'
59
- | 'search'
60
- | 'category'
61
- | 'buffers'
62
- | 'fieldErrors'
63
- | 'fieldErrorMessages'
64
- >;
38
+ /** Private host-to-Client presentation contract; unrelated to the backend protocol. */
65
39
  export interface ClientProps {
66
40
  epoch: number;
67
41
  ack: number;
68
42
  generation: number;
69
43
  columns: number;
70
44
  rows: number;
71
- view: Omit<View, 'editor'> & { editor: EditorData | null };
45
+ displayColumns: number;
46
+ displayRows: number;
47
+ language: Language;
48
+ busy: boolean;
49
+ frame: Frame;
72
50
  }
73
51
 
74
- export function clientProps(
75
- view: View,
76
- epoch: number,
77
- ack: number,
78
- generation: number,
79
- columns: number,
80
- rows: number,
81
- ): ClientProps {
82
- const e = view.editor;
83
- // The host freezes port data recursively. Never expose live editor arrays or
84
- // preference rows: subsequent keys must still mutate our own draft.
85
- return JSON.parse(
86
- JSON.stringify({
87
- epoch,
88
- ack,
89
- generation,
90
- columns,
91
- rows,
92
- view: {
93
- ...view,
94
- editor: e
95
- ? {
96
- description: e.description,
97
- baseline: e.baseline,
98
- draft: e.draft,
99
- page: e.page,
100
- advanced: e.advanced,
101
- adding: e.adding,
102
- pickerSaved: e.pickerSaved,
103
- detail: e.detail, preset: e.preset, path: e.path, pendingTransfer: e.pendingTransfer,
104
- guidanceScroll: e.guidanceScroll,
105
- groupManager: e.groupManager, alignmentManager: e.alignmentManager, review: e.review, quick: e.quick, explanation:e.explanation, profiles:e.profiles, sources:e.sources,
106
- setting: e.setting,
107
- activeNumeric: e.activeNumeric,
108
- selected: e.selected,
109
- order: e.order,
110
- search: e.search,
111
- category: e.category,
112
- buffers: e.buffers,
113
- fieldErrors: e.fieldErrors,
114
- fieldErrorMessages: e.fieldErrorMessages,
115
- }
116
- : null,
117
- },
118
- }),
119
- ) as ClientProps;
120
- }
121
-
122
- /** Rendering uses the same editor model, with only plain data crossing ports. */
123
- export function clientView(props: ClientProps): View {
124
- const data = props.view.editor;
125
- return {
126
- ...props.view,
127
- editor: data
128
- ? Object.assign(new Editor(data.description, data.baseline), data)
129
- : null,
130
- };
52
+ export function clientProps(view: View, epoch: number, ack: number, generation: number, columns: number, rows: number): ClientProps {
53
+ let width = Math.max(2, Math.min(10000, columns));
54
+ let height = Math.max(0, Math.min(10000, rows));
55
+ for (;;) {
56
+ try {
57
+ const { elements, frame } = frameElements();
58
+ const reduced = width !== columns || height !== rows;
59
+ draw(elements, view, width, height, reduced ? t('native.capacity.reduced', view.language ?? 'en', {columns: width, rows: height}) : '');
60
+ const result: ClientProps = { epoch, ack, generation, columns, rows, displayColumns: width, displayRows: height, language: view.language ?? 'en', busy: !!view.busy, frame };
61
+ if (withinBudget(result) && withinBudget(frameTree(frame))) return result;
62
+ } catch (error) {
63
+ if (!(error instanceof CapacityError)) throw error;
64
+ }
65
+ if (height > 12) height = Math.max(12, Math.floor(height * 0.75));
66
+ else if (width > 32) width = Math.max(32, Math.floor(width * 0.75));
67
+ else throw new CapacityError();
68
+ }
131
69
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "schema_version": 1,
3
- "backend_version": "3.9.0",
4
- "mod_version": "3.9.0",
3
+ "backend_version": "3.9.1",
4
+ "mod_version": "3.9.1",
5
5
  "protocol_version": 24,
6
6
  "files": {
7
- ".claude-plugin/plugin.json": "058a72ee575dd2ed4ab5fa3a99c69e8f9f096df542ac10fb4afb7f2c9c9210be",
7
+ ".claude-plugin/plugin.json": "5e8882d2a038ae8c462c8f7b1f728f8a0a19af7196acff899f1f38b34bceae4b",
8
8
  "hooks/hooks.json": "8395d73f4e9d61a02c0976385465d87a05abb2825408f8b40ae916b144c05575",
9
- "hooks/register.ts": "af9af6fa72c3086d8037d9410e9c6a185d65aa41cca492a6521a883046df3817",
9
+ "hooks/register.ts": "4c4a0dcd04c38645ee554653f55ad779972484ef67bb5ba9ed9decf22afef1c0",
10
10
  "lib/backend.ts": "300e36c120d66aac31cfdad03b5164666fdbc747b880a237ede37deb401c181b",
11
11
  "lib/client/forms.ts": "0169bc1a009cdeb021ac21e7b33d332e7a3d9603c0ad9f5751b4936708396ea7",
12
12
  "lib/client/keys.ts": "7dfacddefd7fff880c447786854389a7975ea5fea64fe1fd6cce22847025b33e",
@@ -40,22 +40,23 @@
40
40
  "lib/editor/text-input.ts": "c1968edf898e9abd96da9f5326d530c581ef320721197bfb63497825198f81f0",
41
41
  "lib/generated-contracts.ts": "073ecd7ea8c5479f5c9d56398fcf36699d20e4d31647ccce5323282efeac832b",
42
42
  "lib/generated-unicode.ts": "781c7db664dc6166bc2fcf878565937cd8b25b57d192ae420b3016e1ce510907",
43
- "lib/i18n/generated-locales.ts": "7ca94cec1bfc78b8fcbd93fd984d94e64f9d7ba1a3422523ca0cc7421fe9cbd3",
43
+ "lib/i18n/generated-locales.ts": "165dba619b5d6afecef9ed65fa157301efff5f4f1a7f2d69d142d77edda8a549",
44
44
  "lib/i18n/index.ts": "e5e62b59bdd1c984c182cbf706e5d98b398b4d5e9efb233803eacde38f7e5a9a",
45
45
  "lib/i18n/messages.ts": "31775673f7b18efec0f131012e220c523625c77e1e34fc09ecc7732070ede5d1",
46
46
  "lib/i18n/presentation.ts": "50f663ecfc272883bffc3c882db4a3bc0be54f9b2acbb0d0ea81bb142f347cab",
47
47
  "lib/launch.ts": "08303623ef74cb1ce297b6d4ca32d872908dea513ab394ebc1210b8f92c12328",
48
48
  "lib/preferences.ts": "472cccb55fe3b1ab99ba58416654c3982f4ff83479df19960ab8f1dcd551d410",
49
49
  "lib/preview-preferences.ts": "54fee4a98d18717064ce083a76e6fee5f6ddaead98455cfd24391641cb6aff6d",
50
- "lib/session.ts": "fde328392f5d6c4bbfe3ba5c009e579416e542e065769bb1608f6f2b0b4e5856",
50
+ "lib/session.ts": "5e773637be922ce97c48db9cc2e48e86bc8a55eccad2cf3e8b2e7800ae1962b6",
51
51
  "lib/unicode.ts": "f19f01c0255a3e82a227b04dec1c95457cbd6c0834387dcd857037828b1245f6",
52
- "ui/client/draw.ts": "88590e2081e7eb2fbe20adf28481628cf70e680ca76ea54367db71412e62b59d",
52
+ "ui/client/draw.ts": "3e8b012a2519a1f843998a0cf59f269cf08912a593fda30c1d82945a6dae9912",
53
53
  "ui/client/help.ts": "9351221311da6f48582c941531f638a82ca19847313150409fb9986ae9f924d0",
54
- "ui/client/surface.ts": "218a7242add0e05a8ceb46e55f8d94fd37f4e35af2777157e6ccac75eee2eb50",
54
+ "ui/client/surface.ts": "17aeb5eeb201c2e92a2742ac7d7d07ecc3bc555f5c1f7d8c8799500a1212a7f0",
55
55
  "ui/components/catalog.ts": "aceb7bf838514497aa8d5bcb2ca48b1fa7a2a969eb842ea8000cb1f84600a29d",
56
- "ui/components/preview.ts": "fd7a8b836c633fd9838764c05e47300cda29cebad2132e942313b819195a9616",
57
- "ui/components/section.ts": "759b9cf126061db72cee6f8e730c18c377314f566fbe08cea897179acedc65eb",
58
- "ui/components/shortcuts.ts": "66263a4a49568421e3dd5ee39e4241e31004d679b1023ee399e96f516a8fae41",
56
+ "ui/components/preview.ts": "f7aab61c18b2f5ca77bdae302a803da602e79ed7c1f00f27297dec9d5bfbfaab",
57
+ "ui/components/section.ts": "17050a825a026c075abb8475865b89de328b118df8028591b4ab80eef8b6df1c",
58
+ "ui/components/shortcuts.ts": "e73d639d560f91a5adde2353699792237c36b0fb327df3dfadd99e725a5758d5",
59
+ "ui/frame.ts": "bfb1a4cd8a283c6009d2408d81228220f984eb00bbcb434254c3194f86889e9e",
59
60
  "ui/layout.ts": "86e11b465509e6dbcd58ec6e5d759a7e352ffe239281fc653299149e050d3e11",
60
61
  "ui/styled-text.ts": "1a7ace8eb00f9a59d9470df9606e4e915482758cbc2151c89eafec0ec08b55a0",
61
62
  "ui/text.ts": "fcf0c607e950311519df2f39ad9feb42d3389bcbcf775ee7a13f58a6cbd4fc20",
@@ -24,7 +24,7 @@ import { guidanceLines } from '../../lib/editor/guidance.ts';
24
24
  import { reviewRows } from '../../lib/editor/import-review.ts';
25
25
  import { profilesView, targetLabel } from '../../lib/editor/profile-manager.ts';
26
26
 
27
- export function draw(ui: ClientElements, view: View, columns: number, rows: number): RenderElement {
27
+ export function draw(ui: ClientElements, view: View, columns: number, rows: number, capacityNotice = ''): RenderElement {
28
28
  const tr = (key: string, params: Record<string, unknown> = {}) => t(key, view.language ?? 'en', params);
29
29
  const e = view.editor;
30
30
  const layout = editorLayout(view, columns, rows);
@@ -133,7 +133,8 @@ export function draw(ui: ClientElements, view: View, columns: number, rows: numb
133
133
  children: [spanLine(ui, spans, inner, rowStyle(e.setting === row.key, row.editable))],
134
134
  }));
135
135
  }
136
- while (content.length < layout.bodyRows - Number(layout.showSummary)) content.push(line(' '));
136
+ const gap = layout.bodyRows - Number(layout.showSummary) - content.length;
137
+ if (gap > 0) content.push(ui.Box({ height: gap, flexShrink: 0, children: [] }));
137
138
  if (layout.showSummary) content.push(line(tr("native.ui.client.draw.fields", {value0: settings.length ? window.start + 1 : 0, end: window.end, length: settings.length, page: window.page, pages: window.pages}), styles.muted));
138
139
  } else {
139
140
  const scope = e.page === 'main' ? 'main' : 'subagent';
@@ -152,10 +153,12 @@ export function draw(ui: ClientElements, view: View, columns: number, rows: numb
152
153
  children: [spanLine(ui, itemSpans(item, match, e.search[scope], view.language ?? 'en', inner, e.selected[scope] === item.id, e.items(scope).includes(item.id)), inner, rowStyle(e.selected[scope] === item.id))],
153
154
  }));
154
155
  if (!visible.length) content.push(line(tr("native.ui.client.draw.no_matching_items"), styles.muted));
155
- while (content.length < layout.bodyRows - Number(layout.showDetails) - Number(layout.showSummary)) content.push(line(' '));
156
+ const gap = layout.bodyRows - Number(layout.showDetails) - Number(layout.showSummary) - content.length;
157
+ if (gap > 0) content.push(ui.Box({ height: gap, flexShrink: 0, children: [] }));
156
158
  if (layout.showDetails) content.push(line(current ? tr('native.item_detail', {detail: tr('items.' + scope + '.' + (current.type_id ?? current.id) + '.description'), examples: current.examples.join(' · ')}) : tr('native.empty_detail'), styles.muted));
157
159
  if (layout.showSummary) content.push(line(tr("native.ui.client.draw.enabled", {page: window.page, pages: window.pages, length: e.items(scope).length}), styles.muted));
158
160
  }
161
+ if (capacityNotice) title = capacityNotice + ' · ' + title;
159
162
  const subagentPreview = e.quick ? e.quick.previewScope === 'subagent' : e.review ? e.review.previewScope === 'subagent' : e.page === 'subagents';
160
163
  const sample = view.preview ? subagentPreview ? view.preview.subagents : view.preview.main : [];
161
164
  const overflow = layout.previewRows > 1 && sample.length > layout.previewRows;
@@ -180,7 +183,7 @@ export function draw(ui: ClientElements, view: View, columns: number, rows: numb
180
183
  chromeRow(ui, line(tr("native.ui.client.draw.configure_status_line") + (pending ? ' *' : '') + (e.baseline.configuration ? ' · ' + targetLabel(e, view.language ?? 'en') : ''), { ...styles.accent, bold: true }), columns),
181
184
  chromeRow(ui, spanLine(ui, tabs, columns), columns),
182
185
  chromeRow(ui, notice ? line(notice, view.error || Object.keys(e.fieldErrors).length ? styles.error : styles.text)
183
- : line(tr("native.ui.client.draw.click_region_for_keys"), styles.muted), columns),
186
+ : line(capacityNotice || tr("native.ui.client.draw.click_region_for_keys"), styles.muted), columns),
184
187
  section(ui, 'content-region', title, content, columns, layout.bodyHeight, layout.framed),
185
188
  section(ui, 'preview-region', e.review ? tr('review.preview', {scope:tr('review.sections.' + e.review.previewScope)}) : previewTitle((e.quick?.candidate ?? e.draft).display, columns, view.previewBusy, background, view.language), preview, columns, layout.previewHeight, layout.framed, true),
186
189
  ui.Box({
@@ -1,7 +1,7 @@
1
1
  import { t } from '../../lib/i18n/index.ts';
2
2
  import type { ClientSurface, RenderElement } from 'claude-code';
3
3
  import type { ClientProps } from '../../lib/session.ts';
4
- import { clientView } from '../../lib/session.ts';
4
+ import { drawFrame, withinBudget, CapacityError } from '../frame.ts';
5
5
  import {
6
6
  keyEvents,
7
7
  MAX_BATCH,
@@ -9,7 +9,6 @@ import {
9
9
  MAX_PENDING_TEXT,
10
10
  } from '../../lib/client/messages.ts';
11
11
  import type { KeyMessage } from '../../lib/client/messages.ts';
12
- import { draw } from './draw.ts';
13
12
  import { styles } from '../theme.ts';
14
13
 
15
14
  interface State {
@@ -17,6 +16,7 @@ interface State {
17
16
  next: number;
18
17
  pending: KeyMessage[];
19
18
  latest: ClientProps;
19
+ viewportSent: string;
20
20
  }
21
21
 
22
22
  /** Surface input and drawing only: no process, filesystem or host API access. */
@@ -24,7 +24,7 @@ export default function StatuslineClient(
24
24
  props: ClientProps,
25
25
  surface: ClientSurface<State>,
26
26
  ): RenderElement {
27
- const tr = (key: string) => t(key, props.view.language ?? 'en');
27
+ const tr = (key: string) => t(key, props.language);
28
28
  let state = surface.state;
29
29
  if (state && props.epoch < state.epoch) props = state.latest;
30
30
  if (!state || state.epoch !== props.epoch) {
@@ -33,6 +33,7 @@ export default function StatuslineClient(
33
33
  next: props.ack + 1,
34
34
  pending: [],
35
35
  latest: props,
36
+ viewportSent: '',
36
37
  };
37
38
  surface.setState(state);
38
39
  }
@@ -43,7 +44,12 @@ export default function StatuslineClient(
43
44
  (item) => item.seq > active.latest.ack,
44
45
  );
45
46
  const post = () => {
46
- if (!active.pending.length) return;
47
+ const columns = surface.columns || active.latest.columns;
48
+ const rows = surface.rows || active.latest.rows;
49
+ const viewport = columns + ':' + rows;
50
+ const changed = columns !== active.latest.columns || rows !== active.latest.rows;
51
+ if (!active.pending.length && (!changed || active.viewportSent === viewport)) return;
52
+ active.viewportSent = viewport;
47
53
  let budget=48000;
48
54
  const batch: KeyMessage[]=[];
49
55
  for(const item of active.pending.slice(0,MAX_BATCH)) {
@@ -53,8 +59,8 @@ export default function StatuslineClient(
53
59
  }
54
60
  surface.post({
55
61
  epoch: active.epoch,
56
- columns: surface.columns || active.latest.columns,
57
- rows: surface.rows || active.latest.rows,
62
+ columns,
63
+ rows,
58
64
  events: batch.map(({ seq, event }) => ({
59
65
  seq,
60
66
  event: {
@@ -69,7 +75,7 @@ export default function StatuslineClient(
69
75
  });
70
76
  };
71
77
  surface.onKey((event) => {
72
- if (active.latest.view.busy) return;
78
+ if (active.latest.busy) return;
73
79
  if (active.pending.length >= MAX_PENDING || active.pending.reduce((sum,item)=>sum+item.event.key.length,0)+event.key.length>MAX_PENDING_TEXT) {
74
80
  if (!active.pending.some(item => item.event.overflow)) active.pending.push({seq: active.next++, event: {key: 'input-overflow', overflow: true}});
75
81
  post(); return;
@@ -83,12 +89,9 @@ export default function StatuslineClient(
83
89
  // unacknowledged events; a fresh acknowledgement sends the next bounded batch.
84
90
  post();
85
91
  try {
86
- return draw(
87
- surface.elements,
88
- clientView(active.latest),
89
- surface.columns || active.latest.columns,
90
- surface.rows || active.latest.rows,
91
- );
92
+ const tree = drawFrame(surface.elements, active.latest.frame);
93
+ if (!withinBudget(tree)) throw new CapacityError();
94
+ return tree;
92
95
  } catch (error) {
93
96
  surface.post({
94
97
  epoch: active.epoch,