@fbincon/claude-code-statusline 3.8.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.
- package/README.md +92 -80
- package/candidate.json +336 -254
- package/node_modules/@fbincon/statusline-cli/dist/src/config/arguments.js +18 -4
- package/node_modules/@fbincon/statusline-cli/dist/src/config/arguments.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/config/commands.js +26 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/config/commands.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/config/profile-command.js +7 -2
- package/node_modules/@fbincon/statusline-cli/dist/src/config/profile-command.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/config/selective-import.d.ts +3 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/selective-import.js +40 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/config/selective-import.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/help.js +3 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/help.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/mods.d.ts +4 -3
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/mods.js +14 -13
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/mods.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/resources.d.ts +5 -2
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/resources.js +8 -6
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/resources.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/management/integration.js +12 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/management/integration.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/management/mod-transition-runner.d.ts +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/mod-transition-runner.js +16 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/mod-transition-runner.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/mod-transition.d.ts +3 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/mod-transition.js +96 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/mod-transition.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.d.ts +437 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.js +27 -7
- package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/.claude-plugin/plugin.json +1 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/hooks/register.ts +86 -20
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/backend.ts +7 -4
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/keys.ts +9 -6
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/settings.ts +5 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/alignment-manager.ts +59 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/alignments.ts +77 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/appearance.ts +3 -2
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/draft.ts +17 -4
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/forms.ts +18 -4
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/gradients.ts +29 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/group-manager.ts +5 -3
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/groups.ts +2 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/import-differences.ts +72 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/import-review.ts +49 -2
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/import-selection.ts +38 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/profile-manager.ts +14 -5
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/generated-contracts.ts +9 -3
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/generated-locales.ts +240 -6
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/presentation.ts +2 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/session.ts +28 -88
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/resource-manifest.json +31 -25
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/draw.ts +13 -6
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/help.ts +1 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/surface.ts +16 -13
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/components/preview.ts +9 -5
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/components/section.ts +11 -7
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/components/shortcuts.ts +5 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/frame.ts +72 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/.claude-plugin/plugin.json +1 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/resource-manifest.json +3 -3
- package/node_modules/@fbincon/statusline-core/dist/src/config/defaults.js +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/display.d.ts +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/display.js +13 -4
- package/node_modules/@fbincon/statusline-core/dist/src/config/display.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/editor-fields.js +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/editor-fields.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/formatting.js +11 -4
- package/node_modules/@fbincon/statusline-core/dist/src/config/formatting.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/import-review.d.ts +2 -4
- package/node_modules/@fbincon/statusline-core/dist/src/config/import-review.js +2 -83
- package/node_modules/@fbincon/statusline-core/dist/src/config/import-review.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/instances.js +12 -3
- package/node_modules/@fbincon/statusline-core/dist/src/config/instances.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.d.ts +15 -3
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.js +2 -2
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/alignment-manager.d.ts +18 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/alignment-manager.js +112 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/alignment-manager.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/alignments.d.ts +21 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/alignments.js +117 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/alignments.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/appearance.js +3 -2
- package/node_modules/@fbincon/statusline-core/dist/src/editor/appearance.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/backend.js +8 -4
- package/node_modules/@fbincon/statusline-core/dist/src/editor/backend.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.d.ts +4 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js +16 -3
- package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/forms.js +24 -4
- package/node_modules/@fbincon/statusline-core/dist/src/editor/forms.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/gradients.d.ts +16 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/gradients.js +31 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/gradients.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/group-manager.d.ts +2 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/group-manager.js +5 -3
- package/node_modules/@fbincon/statusline-core/dist/src/editor/group-manager.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/groups.js +3 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/groups.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/import-differences.d.ts +4 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/import-differences.js +86 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/import-differences.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/import-review.d.ts +8 -2
- package/node_modules/@fbincon/statusline-core/dist/src/editor/import-review.js +67 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/import-review.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/import-selection.d.ts +7 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/import-selection.js +42 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/import-selection.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/profile-manager.d.ts +4 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/profile-manager.js +16 -4
- package/node_modules/@fbincon/statusline-core/dist/src/editor/profile-manager.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.d.ts +234 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js +240 -6
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/management/compatibility.js +2 -1
- package/node_modules/@fbincon/statusline-core/dist/src/management/compatibility.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/release.d.ts +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/release.js +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/alignment.d.ts +3 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/alignment.js +97 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/alignment.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/components.d.ts +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/components.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/diagnose.js +2 -3
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/diagnose.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/explain.js +2 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/explain.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/gradients.d.ts +13 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/gradients.js +68 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/gradients.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/groups.js +5 -4
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/groups.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/items.d.ts +4 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/items.js +41 -15
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/items.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/layout.d.ts +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/layout.js +9 -3
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/layout.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/powerline.d.ts +4 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/powerline.js +15 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/powerline.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/subagents.js +7 -5
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/subagents.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/trace.d.ts +3 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/trace.js +3 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/trace.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/en.json +40 -1
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ja.json +40 -1
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ko.json +40 -1
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-CN.json +40 -1
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-HK.json +40 -1
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-TW.json +40 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing/pages.js +5 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing/pages.js.map +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing/presentation.js +5 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing/presentation.js.map +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing/shortcuts.js +2 -2
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing/shortcuts.js.map +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing.js +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing.js.map +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/session.js +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/session.js.map +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/state.js +12 -5
- package/node_modules/@fbincon/statusline-tui/dist/src/state.js.map +1 -1
- package/package.json +3 -3
|
@@ -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
|
-
|
|
140
|
-
state.view,
|
|
141
|
-
state.
|
|
142
|
-
state.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
state.
|
|
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) {
|
|
@@ -343,7 +362,7 @@ async function transferDraft($: EngineInterface, state: Session, options: Plugin
|
|
|
343
362
|
const result = await callBackend($, options, 'review_import', {draft:copyDraft(candidate.draft), path:e.path});
|
|
344
363
|
if (state.epoch === epoch && state.view.editor === e) {
|
|
345
364
|
if (!sameDraft(e.draft, original)) { setMessage(state.view, 'message', localizedText('review.stale')); return; }
|
|
346
|
-
e.review = createReview(result);
|
|
365
|
+
e.review = createReview(result, candidate.draft);
|
|
347
366
|
state.view.preview = null;
|
|
348
367
|
state.previewKey = '';
|
|
349
368
|
state.view.message = '';
|
|
@@ -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
|
|
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
|
-
|
|
681
|
-
|
|
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
|
|
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
|
-
|
|
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:
|
|
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
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// Generated by tools/generation/resources.ts; do not edit.
|
|
2
|
+
import { validAlignments } from './editor/alignments.ts';
|
|
3
|
+
import { GRADIENT_KEYS, validGradient } from './editor/gradients.ts';
|
|
2
4
|
import { validCostRateOptions } from './editor/cost-rate.ts';
|
|
3
5
|
import { validGroups } from './editor/groups.ts';
|
|
4
6
|
import { INDICATOR_KEYS, validIndicatorOptions } from './editor/indicators.ts';
|
|
@@ -108,10 +110,10 @@ function formatOverrides(value: unknown): boolean {
|
|
|
108
110
|
function itemOptions(value: unknown, ids: readonly string[], scope: "main" | "subagent"): boolean {
|
|
109
111
|
if (!object(value)) return false;
|
|
110
112
|
return Object.entries(value).every(([id, option]) => ids.includes(id) && object(option) &&
|
|
111
|
-
exact(option, ['label', 'icon', 'priority', 'max_width', 'formatting', 'foreground', 'background', 'visibility', 'visibility_threshold', ...(option.link !== undefined ? ['link'] : []), ...INDICATOR_KEYS.filter(key => Object.hasOwn(option, key)), ...(Object.hasOwn(option, 'cost_rate_basis') ? ['cost_rate_basis'] : [])]) && (option.link === undefined || ['off','auto','on'].includes(String(option.link))) &&
|
|
113
|
+
exact(option, [...GRADIENT_KEYS.filter(key => Object.hasOwn(option, key)), 'label', 'icon', 'priority', 'max_width', 'formatting', 'foreground', 'background', 'visibility', 'visibility_threshold', ...(option.link !== undefined ? ['link'] : []), ...INDICATOR_KEYS.filter(key => Object.hasOwn(option, key)), ...(Object.hasOwn(option, 'cost_rate_basis') ? ['cost_rate_basis'] : [])]) && (option.link === undefined || ['off','auto','on'].includes(String(option.link))) &&
|
|
112
114
|
(option.label === null || (text(option.label) && [...option.label].length <= 256)) &&
|
|
113
115
|
(option.icon === null || (text(option.icon) && [...option.icon].length <= 256)) &&
|
|
114
|
-
validIndicatorOptions(option, scope, id) && validCostRateOptions(option, scope, id) && range(option.priority, 0, 100) && range(option.max_width, 2, 10000, true) &&
|
|
116
|
+
GRADIENT_KEYS.every(key => option[key] === undefined || id !== 'spacer' && validGradient(option[key])) && validIndicatorOptions(option, scope, id) && validCostRateOptions(option, scope, id) && range(option.priority, 0, 100) && range(option.max_width, 2, 10000, true) &&
|
|
115
117
|
formatOverrides(option.formatting) && validColor(option.foreground) && validColor(option.background) &&
|
|
116
118
|
typeof option.visibility === "string" && visibilityChoices(scope, id).includes(option.visibility) &&
|
|
117
119
|
range(option.visibility_threshold, 0, 100));
|
|
@@ -173,7 +175,7 @@ export function isDraft(value: unknown): value is Draft {
|
|
|
173
175
|
)
|
|
174
176
|
return false;
|
|
175
177
|
if (
|
|
176
|
-
d.schema_version !==
|
|
178
|
+
d.schema_version !== 15 ||
|
|
177
179
|
!object(d.powerline) || !exact(d.powerline, POWERLINE_FIELDS.map(f => f.key.slice(10))) ||
|
|
178
180
|
!POWERLINE_FIELDS.every(f => f.kind === 'boolean' ? typeof (d.powerline as Record<string, unknown>)[f.key.slice(10)] === 'boolean' :
|
|
179
181
|
(f.choices as readonly unknown[]).includes((d.powerline as Record<string, unknown>)[f.key.slice(10)])) ||
|
|
@@ -208,12 +210,13 @@ export function isDraft(value: unknown): value is Draft {
|
|
|
208
210
|
const ids = d.instances.map(i=>i.id);
|
|
209
211
|
const spacers = new Set(d.instances.filter(i=>i.type_id==='spacer').map(i=>i.id));
|
|
210
212
|
const layout = d.layout;
|
|
211
|
-
if (!object(layout) || !exact(layout, ['mode', 'rows']) ||
|
|
213
|
+
if (!object(layout) || !exact(layout, ['mode', 'rows', ...(Object.hasOwn(layout, 'alignments') ? ['alignments'] : [])]) ||
|
|
212
214
|
!['auto', 'explicit'].includes(String(layout.mode)) || !Array.isArray(layout.rows) ||
|
|
213
215
|
!layout.rows.every((r) => selection(r, ids) && r.length > 0 && r.filter(id => spacers.has(id)).length <= 1) ||
|
|
214
216
|
(layout.mode === 'auto' ? layout.rows.length !== 0 || spacers.size > 0 :
|
|
215
217
|
JSON.stringify(layout.rows.flat()) !== JSON.stringify(ids))) return false;
|
|
216
218
|
if (!validGroups(d.groups, d.instances, layout as unknown as import('./generated-contracts.ts').LayoutDraft) || !validGroups(sub.groups, sub.instances)) return false;
|
|
219
|
+
if (!validAlignments(layout.alignments, layout as unknown as import('./generated-contracts.ts').LayoutDraft, d.instances, d.groups)) return false;
|
|
217
220
|
// Exclusions come from describe; the backend remains the final draft validator.
|
|
218
221
|
return (
|
|
219
222
|
typeof h.padding === 'number' &&
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { openAlignments, alignmentsKey } from '../editor/alignment-manager.ts';
|
|
1
2
|
import { openGroups, groupsKey } from '../editor/group-manager.ts';
|
|
2
3
|
import { openSources, sourcesKey } from '../editor/source-manager.ts';
|
|
3
4
|
import { openExplanation, explanationKey } from '../editor/explanation.ts';
|
|
@@ -37,6 +38,7 @@ export function handleKey(view: View, event: NativeKeyEvent, columns: number, ro
|
|
|
37
38
|
const shortcut = /^[A-Z]$/.test(key) ? key.toLowerCase() : key;
|
|
38
39
|
if (!e || view.busy) return null;
|
|
39
40
|
if (event.overflow) { setMessage(view, 'message', localizedText('input.overflow')); return null; }
|
|
41
|
+
if (e.alignmentManager) return alignmentsKey(e,event);
|
|
40
42
|
if (e.groupManager) return groupsKey(e, event);
|
|
41
43
|
if (event.ctrl && key.toLowerCase() === 'b' && !view.input && !view.uncertain && !e.sources && !e.profiles && !e.review && !e.quick && !e.explanation && !event.text) { openGroups(e); return null; }
|
|
42
44
|
if (e.sources) return sourcesKey(e,event);
|
|
@@ -56,7 +58,7 @@ export function handleKey(view: View, event: NativeKeyEvent, columns: number, ro
|
|
|
56
58
|
if (view.uncertain) return event.ctrl || event.meta ? null : shortcut === 'k' ? 'reconcile' : shortcut === 'q' ? 'close' : null;
|
|
57
59
|
if (e.review) {
|
|
58
60
|
if (event.ctrl || event.meta) return null;
|
|
59
|
-
if (shortcut === 'a') {
|
|
61
|
+
if (shortcut === 'a' && !e.review.choosing) {
|
|
60
62
|
e.replaceDraft(e.review.result.draft);
|
|
61
63
|
setMessage(view, 'message', localizedText('review.accepted'));
|
|
62
64
|
return 'reviewPreview';
|
|
@@ -64,7 +66,7 @@ export function handleKey(view: View, event: NativeKeyEvent, columns: number, ro
|
|
|
64
66
|
if (shortcut === 'q') { cancelInput(view); return 'reviewPreview'; }
|
|
65
67
|
const layout = editorLayout(view, columns, rows);
|
|
66
68
|
navigateReview(e.review, key, view.language ?? 'en', Math.max(2, columns - (layout.framed ? 2 : 0)), Math.max(1, layout.bodyRows - 1));
|
|
67
|
-
return
|
|
69
|
+
return 'reviewPreview';
|
|
68
70
|
}
|
|
69
71
|
if (e.guidanceScroll !== null && e.detail) {
|
|
70
72
|
const layout = editorLayout(view, columns, rows);
|
|
@@ -141,11 +143,11 @@ export function handleKey(view: View, event: NativeKeyEvent, columns: number, ro
|
|
|
141
143
|
if(!event.meta && key.toLowerCase()==='a'&&!e.adding){e.openPicker(scope);return null;}
|
|
142
144
|
if(!event.meta && ['d','x'].includes(key.toLowerCase())&&!e.adding){
|
|
143
145
|
if(!e.instanceAction(scope,key.toLowerCase()==='d'?'copy':'remove'))
|
|
144
|
-
setMessage(view,'message',
|
|
146
|
+
setMessage(view,'message',e.compositionError);
|
|
145
147
|
return null;
|
|
146
148
|
}
|
|
147
149
|
if(e.adding&&!event.ctrl&&!event.meta&&(key==='return'||key===' ')){
|
|
148
|
-
if(!e.instanceAction(scope,'add',e.selected[scope]))setMessage(view,'message',
|
|
150
|
+
if(!e.instanceAction(scope,'add',e.selected[scope]))setMessage(view,'message',e.compositionError);
|
|
149
151
|
return null;
|
|
150
152
|
}
|
|
151
153
|
if(e.adding&&!event.ctrl&&!event.meta&&shortcut==='q'){e.closePicker(scope);return null;}
|
|
@@ -198,11 +200,12 @@ export function handleKey(view: View, event: NativeKeyEvent, columns: number, ro
|
|
|
198
200
|
if (isSettings) adjustSetting(view, key === 'left' ? -1 : 1);
|
|
199
201
|
else {
|
|
200
202
|
const delta = key === 'left' ? -1 : 1;
|
|
201
|
-
if (keys[index + delta] && !e.move(scope, delta)) setMessage(view, 'message',
|
|
203
|
+
if (keys[index + delta] && !e.move(scope, delta)) setMessage(view, 'message', e.compositionError);
|
|
202
204
|
}
|
|
203
205
|
return isSettings && e.setting === 'preview-background' ? 'previewBackground' : isSettings && e.setting === 'ui-language' ? 'uiLanguage' : null;
|
|
204
206
|
} else if (key === 'return' || key === ' ' || key === 'space') {
|
|
205
|
-
if (!isSettings) { if(!e.toggle(scope, selected))setMessage(view,"message",
|
|
207
|
+
if (!isSettings) { if(!e.toggle(scope, selected))setMessage(view,"message",e.compositionError); }
|
|
208
|
+
else if (e.setting === 'row-alignment') { openAlignments(e); return null; }
|
|
206
209
|
else if (e.setting === 'component-groups') { openGroups(e); return null; }
|
|
207
210
|
else if (e.setting === 'sources') {openSources(e);return 'sources';}
|
|
208
211
|
else if (e.setting === 'profiles') { if (e.acceptNumeric()) { openProfiles(e); return 'profiles'; } }
|
package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/settings.ts
CHANGED
|
@@ -16,7 +16,11 @@ export interface SettingRow {
|
|
|
16
16
|
export function settingRows(view: View): SettingRow[] {
|
|
17
17
|
const e = view.editor!;
|
|
18
18
|
if (e.detail) return [...(!e.adding ? [{key:'item-explain',label:'Configuration and sample explanation',group:'Item format',value:'Enter',editable:true}] : []), {key:'item-guidance', label:'Sources and requirements', group:'Item format', value:'Enter: read guidance', editable:true}, ...formRows(view)];
|
|
19
|
-
if (e.page === 'layout')
|
|
19
|
+
if (e.page === 'layout') {
|
|
20
|
+
const fields = formRows(view);
|
|
21
|
+
if (!e.draft.display.instances.length) return fields;
|
|
22
|
+
return [fields[0]!, {key:'row-alignment',label:'Align explicit main rows',group:'Layout',value:'Enter',editable:true}, ...fields.slice(1)];
|
|
23
|
+
}
|
|
20
24
|
const d = e.draft.display;
|
|
21
25
|
const h = e.draft.host;
|
|
22
26
|
const rows: SettingRow[] = [
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Generated by tools/generation/resources.ts; do not edit.
|
|
2
|
+
import type { AlignmentDraft, AlignmentRef } from '../generated-contracts.ts';
|
|
3
|
+
import type { Editor } from './draft.ts';
|
|
4
|
+
import type { TextKey } from './text-input.ts';
|
|
5
|
+
import { alignmentUnits, editAlignment, refKey } from './alignments.ts';
|
|
6
|
+
import { newInstance } from './instances.ts';
|
|
7
|
+
import { t, type Language } from '../i18n/index.ts';
|
|
8
|
+
import { wrapText } from '../../ui/text.ts';
|
|
9
|
+
export interface AlignmentManager {
|
|
10
|
+
page:'list'|'actions'|'form';cursor:number;selected:string|null;column:number;columns:AlignmentRef[][];error:boolean;
|
|
11
|
+
}
|
|
12
|
+
export function openAlignments(e: Editor): void {
|
|
13
|
+
e.alignmentManager={page:'list',cursor:0,selected:null,column:0,columns:[[]],error:false};
|
|
14
|
+
}
|
|
15
|
+
function form(e:Editor,value?:AlignmentDraft):void {
|
|
16
|
+
const m=e.alignmentManager!;m.page='form';m.cursor=0;m.selected=value?.id??null;m.columns=JSON.parse(JSON.stringify(value?.columns??[[]]));m.column=0;m.error=false;
|
|
17
|
+
}
|
|
18
|
+
export function alignmentsKey(e:Editor,event:TextKey):null {
|
|
19
|
+
const m=e.alignmentManager!;if(event.text||event.paste||event.meta||event.overflow)return null;
|
|
20
|
+
const key=event.key==='return'?'enter':event.key;
|
|
21
|
+
if(key==='escape'||event.ctrl&&key.toLowerCase()==='g') { if(m.page==='list')e.alignmentManager=null;else {m.page='list';m.cursor=0;m.error=false;}return null; }
|
|
22
|
+
if(event.ctrl)return null;
|
|
23
|
+
const d=e.draft.display, values=d.layout.alignments??[], length=m.page==='list'?values.length+1:m.page==='actions'?2:d.layout.rows.length+4;
|
|
24
|
+
if(['up','down','tab'].includes(key))m.cursor=Math.max(0,Math.min(length-1,m.cursor+(key==='up'?-1:1)));
|
|
25
|
+
if(key==='home')m.cursor=0;if(key==='end')m.cursor=length-1;
|
|
26
|
+
if(m.page==='list'&&key==='enter') { const value=values[m.cursor];if(value){m.selected=value.id;m.page='actions';m.cursor=0;}else form(e); }
|
|
27
|
+
else if(m.page==='actions'&&key==='enter') {
|
|
28
|
+
if(m.cursor===0)form(e,values.find(v=>v.id===m.selected));
|
|
29
|
+
else { e.draft={...e.draft,display:editAlignment(d,m.selected!)};m.page='list';m.cursor=0; }
|
|
30
|
+
} else if(m.page==='form'&&['left','right','enter','space',' '].includes(key)) {
|
|
31
|
+
const rows=d.layout.rows.length;
|
|
32
|
+
if(m.cursor===0)m.column=(m.column+(key==='left'?m.columns.length-1:1))%m.columns.length;
|
|
33
|
+
else if(m.cursor<=rows) {
|
|
34
|
+
const row=m.cursor-1, units=alignmentUnits(d.layout,d.instances,d.groups), choices=units.filter(u=>u.row===row);
|
|
35
|
+
const previous=m.columns[m.column]!.find(ref=>choices.some(u=>refKey(u.ref)===refKey(ref)));
|
|
36
|
+
const index=previous?choices.findIndex(u=>refKey(u.ref)===refKey(previous))+1:0;
|
|
37
|
+
const next=(index+(key==='left'?choices.length:1))%(choices.length+1);
|
|
38
|
+
m.columns[m.column]=m.columns[m.column]!.filter(ref=>!choices.some(u=>refKey(u.ref)===refKey(ref)));
|
|
39
|
+
if(next)m.columns[m.column]!.push(choices[next-1]!.ref);
|
|
40
|
+
} else if(key==='enter'&&m.cursor===rows+1) {m.columns.push([]);m.column=m.columns.length-1;m.cursor=1;}
|
|
41
|
+
else if(key==='enter'&&m.cursor===rows+2) {if(m.columns.length>1)m.columns.splice(m.column,1);else m.columns=[[]];m.column=Math.min(m.column,m.columns.length-1);}
|
|
42
|
+
else if(key==='enter'&&m.cursor===rows+3) {
|
|
43
|
+
try {
|
|
44
|
+
let id=m.selected??newInstance('text',d.instances).id;while(!m.selected&&values.some(v=>v.id===id))id=newInstance('text',d.instances).id;
|
|
45
|
+
e.draft={...e.draft,display:editAlignment(d,id,m.columns)};m.page='list';m.cursor=0;m.error=false;
|
|
46
|
+
}catch {m.error=true;}return null;
|
|
47
|
+
}
|
|
48
|
+
m.error=false;
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
export function alignmentsView(e:Editor,language:Language,width:number,height:number):{text:string;selected?:boolean}[] {
|
|
53
|
+
const m=e.alignmentManager!,d=e.draft.display,tr=(key:string)=>t('alignment.'+key,language),units=alignmentUnits(d.layout,d.instances,d.groups);
|
|
54
|
+
const label=(ref:AlignmentRef)=>{const u=units.find(u=>refKey(u.ref)===refKey(ref));return u?e.instanceLabel('main',ref.kind==='group'?d.groups.find(g=>g.id===ref.id)!.primary_id:ref.id,language)+(ref.kind==='group'?' · '+tr('group'):'')+' ('+ref.id+')':'—';};
|
|
55
|
+
const values=m.page==='list'?[...(d.layout.alignments??[]).map(v=>v.id+' · '+v.columns.length),tr('create')]:m.page==='actions'?[tr('edit'),tr('remove')]:
|
|
56
|
+
[tr('column')+': '+(m.column+1)+'/'+m.columns.length,...d.layout.rows.map((_,row)=>tr('row')+' '+(row+1)+': '+(m.columns[m.column]!.find(ref=>units.some(u=>u.row===row&&refKey(u.ref)===refKey(ref))) ? label(m.columns[m.column]!.find(ref=>units.some(u=>u.row===row&&refKey(u.ref)===refKey(ref)))!) : '—')),tr('add_column'),tr('remove_column'),tr('apply')];
|
|
57
|
+
const note=wrapText([tr(d.layout.mode!=='explicit'?'explicit':m.error?'invalid':'help')],width),capacity=Math.max(1,height-Math.min(2,note.length)),start=Math.max(0,m.cursor-capacity+1);
|
|
58
|
+
return [...values.slice(start,start+capacity).map((text,i)=>({text:(start+i===m.cursor?'› ':' ')+text,selected:start+i===m.cursor})),...note.slice(0,Math.max(0,height-Math.min(capacity,values.length))).map(text=>({text}))];
|
|
59
|
+
}
|
package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/alignments.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Generated by tools/generation/resources.ts; do not edit.
|
|
2
|
+
/** Stable references to whole units; row positions are resolved from the current explicit layout. */
|
|
3
|
+
import type { AlignmentRef, DisplayDraft, GroupDraft, InstanceDraft, LayoutDraft } from '../generated-contracts.ts';
|
|
4
|
+
export interface AlignmentUnit { ref: AlignmentRef; ids: string[]; row: number; side: 'left' | 'right'; position: number }
|
|
5
|
+
export const refKey = (ref: AlignmentRef): string => ref.kind + ':' + ref.id;
|
|
6
|
+
const object = (v: unknown): v is Record<string, unknown> => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
7
|
+
const identifier = (v: unknown): v is string => typeof v === 'string' && /^[A-Za-z0-9][A-Za-z0-9_-]{0,95}$/u.test(v);
|
|
8
|
+
export function alignmentUnits(layout: LayoutDraft, nodes: readonly InstanceDraft[], groups: readonly GroupDraft[]): AlignmentUnit[] {
|
|
9
|
+
const byId = new Map(nodes.map(n => [n.id,n])), membership = new Map(groups.flatMap(g=>g.member_ids.map(id=>[id,g] as const)));
|
|
10
|
+
return layout.rows.flatMap((ids,row) => {
|
|
11
|
+
const seen = new Set<string>(), units: AlignmentUnit[] = []; let side: 'left' | 'right' = 'left';
|
|
12
|
+
for (const id of ids) {
|
|
13
|
+
if (byId.get(id)?.type_id === 'spacer') { side='right';continue; }
|
|
14
|
+
const group=membership.get(id); if(group && seen.has(group.id))continue;
|
|
15
|
+
if(group)seen.add(group.id);
|
|
16
|
+
units.push({ref:{kind:group?'group':'instance',id:group?.id??id},ids:group?[...group.member_ids]:[id],row,side,position:units.length});
|
|
17
|
+
}
|
|
18
|
+
return units;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export function validAlignments(value: unknown, layout: LayoutDraft, nodes: readonly InstanceDraft[], groups: readonly GroupDraft[]): boolean {
|
|
22
|
+
if(value === undefined)return true;
|
|
23
|
+
if(!Array.isArray(value)||value.length>nodes.length)return false;
|
|
24
|
+
if(!value.length)return true;
|
|
25
|
+
if(layout.mode!=='explicit')return false;
|
|
26
|
+
const units=new Map(alignmentUnits(layout,nodes,groups).map(u=>[refKey(u.ref),u])), used=new Set<string>(), ids=new Set<string>(), ownership=new Map<string,string>();
|
|
27
|
+
return value.every(alignment=>{
|
|
28
|
+
if(!object(alignment)||Object.keys(alignment).sort().join(',')!=='columns,id'||!identifier(alignment.id)||ids.has(alignment.id)||
|
|
29
|
+
!Array.isArray(alignment.columns)||!alignment.columns.length||alignment.columns.length>nodes.length)return false;
|
|
30
|
+
ids.add(alignment.id);const positions=new Map<string,number>();
|
|
31
|
+
return alignment.columns.every(column=>{
|
|
32
|
+
if(!Array.isArray(column)||column.length<2||column.length>layout.rows.length)return false;
|
|
33
|
+
const rows=new Set<number>();let side: string|undefined;
|
|
34
|
+
return column.every(ref=>{
|
|
35
|
+
if(!object(ref)||Object.keys(ref).sort().join(',')!=='id,kind'||!['instance','group'].includes(String(ref.kind))||!identifier(ref.id))return false;
|
|
36
|
+
const key=refKey(ref as unknown as AlignmentRef), unit=units.get(key);
|
|
37
|
+
if(!unit||used.has(key)||rows.has(unit.row)||side!==undefined&&unit.side!==side)return false;
|
|
38
|
+
const owner=unit.row+':'+unit.side, previous=positions.get(owner);
|
|
39
|
+
if(ownership.has(owner)&&ownership.get(owner)!==alignment.id||previous!==undefined&&previous>=unit.position)return false;
|
|
40
|
+
ownership.set(owner,alignment.id as string);positions.set(owner,unit.position);rows.add(unit.row);used.add(key);side=unit.side;return true;
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
export function editAlignment(display: DisplayDraft, id: string, columns?: AlignmentRef[][]): DisplayDraft {
|
|
46
|
+
const result=JSON.parse(JSON.stringify(display)) as DisplayDraft, values=result.layout.alignments??[];
|
|
47
|
+
if(!identifier(id))throw new Error('alignment.invalid');
|
|
48
|
+
const index=values.findIndex(v=>v.id===id);
|
|
49
|
+
if(columns===undefined) { if(index<0)throw new Error('alignment.invalid');values.splice(index,1); }
|
|
50
|
+
else { const value={id,columns};if(index<0)values.push(value);else values[index]=value; }
|
|
51
|
+
result.layout.alignments=values;
|
|
52
|
+
if(!validAlignments(values,result.layout,result.instances,result.groups))throw new Error('alignment.invalid');
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
/** Identify relationships that a proposed structural edit would invalidate. */
|
|
56
|
+
export function alignmentConflicts(display: DisplayDraft): string[] {
|
|
57
|
+
const values = display.layout.alignments;
|
|
58
|
+
if (validAlignments(values, display.layout, display.instances, display.groups)) return [];
|
|
59
|
+
if (!Array.isArray(values)) return [];
|
|
60
|
+
const named = values.filter(value => object(value) && identifier(value.id));
|
|
61
|
+
const invalid = named.filter(value => !validAlignments([value], display.layout, display.instances, display.groups));
|
|
62
|
+
return (invalid.length ? invalid : named).map(value => value.id);
|
|
63
|
+
}
|
|
64
|
+
export function requireAlignments(display: DisplayDraft): void {
|
|
65
|
+
const ids = alignmentConflicts(display);
|
|
66
|
+
if (ids.length) throw new AlignmentReferenceError(ids);
|
|
67
|
+
}
|
|
68
|
+
export class AlignmentReferenceError extends Error {
|
|
69
|
+
constructor(readonly ids: string[]) { super('alignment.references'); }
|
|
70
|
+
}
|
|
71
|
+
export function parseAlignmentColumns(raw: string): AlignmentRef[][] {
|
|
72
|
+
return raw.split(';').map(column=>column.split(',').map(token=>{
|
|
73
|
+
const match=/^(instance|group):([A-Za-z0-9][A-Za-z0-9_-]{0,95})$/u.exec(token.trim());
|
|
74
|
+
if(!match)throw new Error('alignment.invalid');
|
|
75
|
+
return {kind:match[1] as AlignmentRef['kind'],id:match[2]!};
|
|
76
|
+
}));
|
|
77
|
+
}
|
package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/appearance.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Generated by tools/generation/resources.ts; do not edit.
|
|
2
|
+
import { GRADIENT_FIELDS } from './gradients.ts';
|
|
2
3
|
import { COST_RATE_FIELD } from './cost-rate.ts';
|
|
3
4
|
import { supportsIndicator, INDICATOR_FIELDS } from './indicators.ts';
|
|
4
5
|
/** Pure controls/validation from Python's scoped visibility capabilities. */
|
|
@@ -27,13 +28,13 @@ export function supportedFormats(scope: Scope, id: string, capability?: ItemCapa
|
|
|
27
28
|
|
|
28
29
|
export function itemFields(fields: EditorField[], scope: Scope, id: string, capability?: ItemCapability): EditorField[] {
|
|
29
30
|
if(id==='spacer')return [];
|
|
30
|
-
if(id==='text')return [{key:'text',label:'Literal text',group:'Item format',kind:'text',choices:[],minimum:0,maximum:256,nullable:false},
|
|
31
|
+
if(id==='text')return [...GRADIENT_FIELDS,{key:'text',label:'Literal text',group:'Item format',kind:'text',choices:[],minimum:0,maximum:256,nullable:false},
|
|
31
32
|
...fields.filter(f=>['label','icon','foreground','background','priority','max_width'].includes(f.key))];
|
|
32
33
|
const choices = capability?.visibility ?? visibilityChoices(scope, id);
|
|
33
34
|
const links: EditorField[] = capability?.link ? [{key:'link',label:'Links',group:'Item format',kind:'choice',choices:['off','auto','on'],minimum:0,maximum:0,nullable:false}] : [];
|
|
34
35
|
const formats = supportedFormats(scope, id, capability);
|
|
35
36
|
fields = fields.filter(field => !Object.hasOwn(FORMAT_CHOICES,field.key) || formats.includes(field.key));
|
|
36
|
-
return [...(scope === 'main' && id === 'session-cost-rate' ? [COST_RATE_FIELD] : []), ...(supportsIndicator(scope, id) ? INDICATOR_FIELDS : []), ...links, ...fields.filter(spec => (spec.key !== 'visibility' || choices.length > 1) &&
|
|
37
|
+
return [...GRADIENT_FIELDS, ...(scope === 'main' && id === 'session-cost-rate' ? [COST_RATE_FIELD] : []), ...(supportsIndicator(scope, id) ? INDICATOR_FIELDS : []), ...links, ...fields.filter(spec => (spec.key !== 'visibility' || choices.length > 1) &&
|
|
37
38
|
(spec.key !== 'visibility_threshold' || choices.includes('used-at-least')))
|
|
38
39
|
.map(spec => spec.key === 'visibility' ? {...spec, choices} : spec)];
|
|
39
40
|
}
|
package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/draft.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
// Generated by tools/generation/resources.ts; do not edit.
|
|
2
|
+
import type { AlignmentManager } from './alignment-manager.ts';
|
|
2
3
|
import type { GroupManager } from './group-manager.ts';
|
|
3
4
|
import { reconcileGroups, insertionAfter } from './groups.ts';
|
|
4
5
|
import type { ExplanationView } from './explanation.ts';
|
|
5
6
|
import type { SourceManager } from './source-manager.ts';
|
|
6
7
|
import type { ProfileManager } from './profile-manager.ts';
|
|
7
8
|
import type { QuickSetup } from './quick-setup.ts';
|
|
8
|
-
import { t, type Language } from '../i18n/index.ts';
|
|
9
|
+
import { t, text, type Language } from '../i18n/index.ts';
|
|
10
|
+
import { alignmentConflicts } from './alignments.ts';
|
|
9
11
|
import { nodes, newInstance, reconcileRows } from './instances.ts';
|
|
10
12
|
import { isDraft } from '../backend.ts';
|
|
11
13
|
import type {
|
|
@@ -50,6 +52,8 @@ export class Editor {
|
|
|
50
52
|
profiles: ProfileManager | null = null;
|
|
51
53
|
sources: SourceManager | null = null;
|
|
52
54
|
groupManager: GroupManager | null = null;
|
|
55
|
+
alignmentManager: AlignmentManager | null = null;
|
|
56
|
+
compositionError: LocalizedText = text('composition.invalid');
|
|
53
57
|
preset = 'minimal';
|
|
54
58
|
path = 'statusline.json';
|
|
55
59
|
pendingTransfer: 'import' | 'export' | 'preset' | null = null;
|
|
@@ -95,7 +99,7 @@ export class Editor {
|
|
|
95
99
|
this.detail = null;
|
|
96
100
|
this.guidanceScroll = null;
|
|
97
101
|
this.explanation = null;
|
|
98
|
-
this.review = null;
|
|
102
|
+
this.review = null; this.alignmentManager = null;
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
get modified(): boolean {
|
|
@@ -153,6 +157,7 @@ export class Editor {
|
|
|
153
157
|
this.adding=false;this.pickerSaved=null;
|
|
154
158
|
}
|
|
155
159
|
instanceAction(scope: Scope, action:'add'|'copy'|'remove', typeId?:string): boolean {
|
|
160
|
+
this.compositionError = text('composition.invalid');
|
|
156
161
|
const draft=copyDraft(this.draft), list=nodes(draft,scope);
|
|
157
162
|
const selected=this.adding ? this.pickerSaved?.selected : this.selected[scope];
|
|
158
163
|
const index=list.findIndex(i=>i.id===selected);
|
|
@@ -168,7 +173,7 @@ export class Editor {
|
|
|
168
173
|
const target = scope === 'main' ? draft.display : draft.display.subagents;
|
|
169
174
|
target.groups = reconcileGroups(target.groups, list);
|
|
170
175
|
if(scope==='main')reconcileRows(draft);
|
|
171
|
-
if(!
|
|
176
|
+
if(!this.acceptStructure(draft))return false;
|
|
172
177
|
if(this.adding){this.closePicker(scope);this.search[scope]='';this.category[scope]='all';}
|
|
173
178
|
this.draft=draft;this.order[scope]=list.map(i=>i.id);this.selected[scope]=next;
|
|
174
179
|
return true;
|
|
@@ -197,6 +202,7 @@ export class Editor {
|
|
|
197
202
|
}
|
|
198
203
|
|
|
199
204
|
toggle(scope: Scope, id: string): boolean {
|
|
205
|
+
this.compositionError = text('composition.invalid');
|
|
200
206
|
if(this.adding)return this.instanceAction(scope,'add',id);
|
|
201
207
|
const draft=copyDraft(this.draft),node=nodes(draft,scope).find(i=>i.id===id);
|
|
202
208
|
if(!node)return false;
|
|
@@ -206,6 +212,7 @@ export class Editor {
|
|
|
206
212
|
}
|
|
207
213
|
|
|
208
214
|
move(scope: Scope, delta: -1 | 1): boolean {
|
|
215
|
+
this.compositionError = text('composition.invalid');
|
|
209
216
|
if (this.adding || this.filtered(scope)) return false;
|
|
210
217
|
const visible = this.visible(scope).map((item) => item.id as string);
|
|
211
218
|
const id = this.selected[scope];
|
|
@@ -218,12 +225,18 @@ export class Editor {
|
|
|
218
225
|
const [moving] = ordered.splice(sourceIndex, 1);
|
|
219
226
|
ordered.splice(ordered.findIndex(node => node.id === target) + (delta > 0 ? 1 : 0), 0, moving!);
|
|
220
227
|
if (scope === 'main') reconcileRows(draft);
|
|
221
|
-
if (!
|
|
228
|
+
if (!this.acceptStructure(draft)) return false;
|
|
222
229
|
this.draft = draft;
|
|
223
230
|
this.order[scope] = ordered.map(node => node.id);
|
|
224
231
|
return true;
|
|
225
232
|
}
|
|
226
233
|
|
|
234
|
+
private acceptStructure(draft: Draft): boolean {
|
|
235
|
+
const ids = alignmentConflicts(draft.display);
|
|
236
|
+
if (ids.length) this.compositionError = text('alignment.references', { ids: ids.join(', ') });
|
|
237
|
+
return isDraft(draft);
|
|
238
|
+
}
|
|
239
|
+
|
|
227
240
|
setBuffer(field: NumericField, value: string): void {
|
|
228
241
|
this.activeNumeric = field;
|
|
229
242
|
this.buffers[field] = value;
|