@fbincon/claude-code-statusline 3.10.0 → 3.11.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.
- package/README.md +79 -78
- package/candidate.json +201 -148
- package/node_modules/@fbincon/statusline-cli/dist/src/help.js +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/help.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/configure.d.ts +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/configure.js +2 -2
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/configure.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/main.js +5 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/main.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/management/inspection.d.ts +8 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/inspection.js +147 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/inspection.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/restore.d.ts +14 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/management/restore.js +2 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/management/restore.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/management/review-jobs.d.ts +15 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/review-jobs.js +90 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/review-jobs.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/review-worker-entry.d.ts +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/review-worker-entry.js +33 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/review-worker-entry.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/review.d.ts +5 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/review.js +44 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/review.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/service.d.ts +4 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/management/service.js +10 -3
- package/node_modules/@fbincon/statusline-cli/dist/src/management/service.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/tasks/command.d.ts +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/tasks/command.js +11 -4
- package/node_modules/@fbincon/statusline-cli/dist/src/tasks/command.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/tasks/view.d.ts +3 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/tasks/view.js +25 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/tasks/view.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.d.ts +3 -3
- package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.js +23 -0
- 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 +77 -52
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/backend.ts +3 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/keys.ts +4 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/settings.ts +1 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/draft.ts +2 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/package-manager.ts +314 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/package-validation.ts +43 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/task-viewer.ts +319 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/generated-contracts.ts +75 -3
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/generated-locales.ts +336 -6
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/resource-manifest.json +16 -13
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/draw.ts +3 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/help.ts +1 -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/contracts/ui.d.ts +75 -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/backend.js +5 -0
- 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 +2 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js +2 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/package-manager.d.ts +41 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/package-manager.js +281 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/package-manager.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/package-validation.d.ts +3 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/package-validation.js +42 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/package-validation.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/task-viewer.d.ts +46 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/task-viewer.js +279 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/task-viewer.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.d.ts +330 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js +336 -6
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.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/resources/i18n/locales/en.json +56 -1
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ja.json +56 -1
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ko.json +56 -1
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-CN.json +56 -1
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-HK.json +56 -1
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-TW.json +56 -1
- package/node_modules/@fbincon/statusline-platform/dist/src/review-worker.d.ts +4 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/review-worker.js +22 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/review-worker.js.map +1 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing/pages.js +10 -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 +4 -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 +4 -0
- 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.d.ts +3 -2
- package/node_modules/@fbincon/statusline-tui/dist/src/session.js +22 -4
- package/node_modules/@fbincon/statusline-tui/dist/src/session.js.map +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/state.d.ts +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/state.js +20 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/state.js.map +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/task-viewer.d.ts +6 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/task-viewer.js +34 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/task-viewer.js.map +1 -0
- package/package.json +2 -2
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { performPackage, closePackage } from '../lib/editor/package-manager.ts';
|
|
1
2
|
import { diagnosisRequest } from '../lib/editor/diagnosis-view.ts';
|
|
2
3
|
import { colorDraft } from '../lib/editor/color-manager.ts';
|
|
3
4
|
import { previewWidth } from '../lib/editor/preview-settings.ts';
|
|
4
5
|
import { performSourceAction, closeSources } from '../lib/editor/source-manager.ts';
|
|
5
|
-
import {
|
|
6
|
+
import { taskViewer, taskViewerView, taskViewerKey, receiveTask, type TaskViewer } from '../lib/editor/task-viewer.ts';
|
|
6
7
|
import { receivePreset } from '../lib/editor/quick-setup.ts';
|
|
7
8
|
import { performProfileAction } from '../lib/editor/profile-manager.ts';
|
|
8
9
|
import type {
|
|
@@ -31,7 +32,7 @@ import { MIN_COLUMNS, MIN_ROWS, contentColumns, clip } from '../ui/layout.ts';
|
|
|
31
32
|
import { recoveryButton, styles } from '../ui/theme.ts';
|
|
32
33
|
import { clientProps } from '../lib/session.ts';
|
|
33
34
|
import type { View } from '../lib/session.ts';
|
|
34
|
-
import { withinBudget } from '../ui/frame.ts';
|
|
35
|
+
import { withinBudget, frameElements } from '../ui/frame.ts';
|
|
35
36
|
import { parseBatch } from '../lib/client/messages.ts';
|
|
36
37
|
import { handleKey } from '../lib/client/keys.ts';
|
|
37
38
|
import { DEFAULT_PREVIEW_BACKGROUND, PREVIEW_BACKGROUND_KEY, previewBackground } from '../lib/preview-preferences.ts';
|
|
@@ -167,6 +168,7 @@ async function load(
|
|
|
167
168
|
state: Session,
|
|
168
169
|
options: PluginOptions,
|
|
169
170
|
) {
|
|
171
|
+
if (state.view.editor?.packages) await closePackage(state.view.editor.packages,{request:(operation,payload)=>callBackend($,options,operation,payload)});
|
|
170
172
|
if (state.view.editor?.sources) await closeSources(state.view.editor,{request:(operation,payload)=>callBackend($,options,operation,payload)});
|
|
171
173
|
discard(state);
|
|
172
174
|
const opening = state.epoch;
|
|
@@ -453,7 +455,8 @@ async function close($: EngineInterface, state: Session, options: PluginOptions)
|
|
|
453
455
|
return;
|
|
454
456
|
}
|
|
455
457
|
try {
|
|
456
|
-
if (state.view.editor?.
|
|
458
|
+
if (state.view.editor?.packages) await closePackage(state.view.editor.packages,{request:(operation,payload)=>callBackend($,options,operation,payload)});
|
|
459
|
+
if (state.view.editor?.sources) await closeSources(state.view.editor,{request:(operation,payload)=>callBackend($,options,operation,payload)});
|
|
457
460
|
await $.ui.close({ id: PANE });
|
|
458
461
|
const open = await $.ui.panes();
|
|
459
462
|
if (!open.some((p) => p.id === PANE)) discard(state);
|
|
@@ -494,14 +497,13 @@ async function openEditor(
|
|
|
494
497
|
|
|
495
498
|
/** Task host calls stay in this statically inspected entry; presentation is shared in core. */
|
|
496
499
|
const TASK_COMMAND = 'statusline-task', TASK_PANE = 'statusline-task-details';
|
|
497
|
-
export interface TaskPaneState {
|
|
498
|
-
owned: boolean;
|
|
499
|
-
language: Language; report: TaskDetails | null; error: LocalizedText | null; warning: LocalizedText | null;
|
|
500
|
-
lines: { report: TaskDetails; language: Language; width: number; value: string[] } | null;
|
|
500
|
+
export interface TaskPaneState extends TaskViewer {
|
|
501
|
+
owned: boolean; epoch: number; ack: number; frameGeneration: number; chain: Promise<void>;
|
|
501
502
|
}
|
|
502
503
|
export function taskPaneState(): TaskPaneState {
|
|
503
|
-
return {
|
|
504
|
+
return {...taskViewer(),input:null,owned:false,epoch:0,ack:0,frameGeneration:0,chain:Promise.resolve()};
|
|
504
505
|
}
|
|
506
|
+
|
|
505
507
|
async function taskLanguage($: EngineInterface, options: PluginOptions, state: TaskPaneState, epoch: number): Promise<boolean> {
|
|
506
508
|
try {
|
|
507
509
|
const preference=await callBackend($,options,'read_ui_preferences');
|
|
@@ -521,77 +523,94 @@ async function taskCommand($: EngineInterface, state: TaskPaneState, epoch: numb
|
|
|
521
523
|
return state.owned && state.generation===epoch;
|
|
522
524
|
}
|
|
523
525
|
export async function startTaskDetails($: EngineInterface, state: TaskPaneState, options: PluginOptions): Promise<void> {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
+
const generation=state.generation+1,epoch=state.epoch+1;
|
|
527
|
+
Object.assign(state,taskPaneState(),{generation,epoch});
|
|
528
|
+
if(await taskLanguage($,options,state,generation))await taskCommand($,state,generation);
|
|
526
529
|
}
|
|
527
530
|
async function refreshTaskDetails($: EngineInterface, options: PluginOptions, state: TaskPaneState, readLanguage=true): Promise<void> {
|
|
528
|
-
if(state.
|
|
529
|
-
state.
|
|
531
|
+
if(state.busy||state.closed)return;
|
|
532
|
+
state.busy=true;const generation=state.generation;
|
|
530
533
|
$.ui.invalidate('ui.render');
|
|
531
534
|
try {
|
|
532
535
|
if(readLanguage) {
|
|
533
536
|
const previous=state.language;
|
|
534
|
-
if(!await taskLanguage($,options,state,
|
|
537
|
+
if(!await taskLanguage($,options,state,generation)||!await taskCommand($,state,generation))return;
|
|
535
538
|
if(previous!==state.language)await $.ui.open({id:TASK_PANE,title:t('task.title',state.language),closeOnEscape:true,rows:24,columns:88});
|
|
536
539
|
}
|
|
537
540
|
const session=await $.session.id();
|
|
541
|
+
if(!state.session)state.session=session;
|
|
538
542
|
let host_agents: { observed_at:number; agents:{id:string;name:string|null}[] } | undefined;
|
|
539
|
-
try {
|
|
543
|
+
if(state.session===session)try {
|
|
540
544
|
const agents=await $.agent.list();
|
|
541
545
|
host_agents={observed_at:await $.clock.now(),agents:agents.slice(0,256).map(a=>({id:a.id,name:[...(a.name ?? a.description ?? '').replace(/[\p{Cc}\p{Cs}]/gu,'')].slice(0,256).join('') || null}))};
|
|
542
546
|
}catch { /* Published evidence remains usable without a host snapshot. */ }
|
|
543
|
-
if(state.generation!==
|
|
544
|
-
const result=await callBackend($,options,'task_details',{session_id:session,...(host_agents?{host_agents}:{})});
|
|
545
|
-
if(state.generation!==
|
|
546
|
-
|
|
547
|
-
state.report=result;state.offset=0;
|
|
547
|
+
if(state.generation!==generation)return;
|
|
548
|
+
const result=await callBackend($,options,'task_details',{session_id:state.session,prompt_id:state.prompt,...(host_agents?{host_agents}:{})});
|
|
549
|
+
if(state.generation!==generation)return;
|
|
550
|
+
receiveTask(state,result);
|
|
548
551
|
}catch(failure) {
|
|
549
|
-
if(state.generation===
|
|
552
|
+
if(state.generation===generation)state.error=failureMessage(failure);
|
|
550
553
|
}finally {
|
|
551
|
-
if(state.generation===
|
|
554
|
+
if(state.generation===generation){state.busy=false;$.ui.invalidate('ui.render');}
|
|
552
555
|
}
|
|
553
556
|
}
|
|
557
|
+
|
|
554
558
|
export function registerTaskDetails(on: On, options: PluginOptions, state: TaskPaneState): void {
|
|
555
559
|
const tr=(key:string)=>t(key,state.language);
|
|
556
560
|
on('command.run',{command:'statusline-task'},async($,e,next)=>{
|
|
557
561
|
if(!state.owned)return next(e);
|
|
558
|
-
|
|
559
|
-
if(!
|
|
562
|
+
await startTaskDetails($,state,options);
|
|
563
|
+
if(!state.owned)return next(e);
|
|
560
564
|
const opened=await $.ui.open({id:TASK_PANE,title:tr('task.title'),focus:true,closeOnEscape:true,rows:24,columns:88});
|
|
561
565
|
if(!opened.isPlaced)return {text:tr('task.fallback')};
|
|
562
566
|
await refreshTaskDetails($,options,state,false);return {};
|
|
563
567
|
});
|
|
564
568
|
on('ui.close',{id:'statusline-task-details'},async($,e,next)=>{
|
|
565
|
-
state.generation++;state.
|
|
569
|
+
state.generation++;state.epoch++;state.closed=true;state.busy=false;state.report=null;return next(e);
|
|
570
|
+
});
|
|
571
|
+
on('ui.message',{component:'Pane'},async($,e,next)=>{
|
|
572
|
+
if(e.requestId!==TASK_PANE||e.element!=='task-client-'+state.epoch||e.module!=='ui/client/surface.ts'||e.surface!=='terminal'||!state.owned||state.closed)return next(e);
|
|
573
|
+
const batch=parseBatch(e.data);
|
|
574
|
+
if(!batch){state.error=localizedText('task.fallback');$.ui.invalidate('ui.render');return {};}
|
|
575
|
+
const run=state.chain.then(async()=>{
|
|
576
|
+
if(batch.epoch!==state.epoch||state.closed)return {};
|
|
577
|
+
for(const message of batch.events){
|
|
578
|
+
if(message.seq<=state.ack)continue;
|
|
579
|
+
if(message.seq!==state.ack+1){state.error=localizedText('task.fallback');break;}
|
|
580
|
+
state.ack=message.seq;
|
|
581
|
+
const action=taskViewerKey(state,message.event);
|
|
582
|
+
if(action==='close'){await $.ui.close({id:TASK_PANE});break;}
|
|
583
|
+
if(action==='read')await refreshTaskDetails($,options,state);
|
|
584
|
+
}
|
|
585
|
+
$.ui.invalidate('ui.render');return {};
|
|
586
|
+
});
|
|
587
|
+
state.chain=run.then(()=>{},()=>{});return run;
|
|
566
588
|
});
|
|
567
589
|
on('ui.render',{component:'Pane',requestId:'statusline-task-details'},async($,e,next)=>{
|
|
568
590
|
if(!state.owned)return next(e);
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
let width=Math.max(2,Math.min(10000,e.props.bodyColumns)),height=Math.max(
|
|
591
|
+
if(e.surface!=='terminal')return $.ui.resolve(e).Text({...styles.text,children:[tr('task.fallback')]});
|
|
592
|
+
const {Box,Text,Button,Client}=$.ui.resolve(e);
|
|
593
|
+
let width=Math.max(2,Math.min(10000,e.props.bodyColumns)),height=Math.max(6,Math.min(10000,e.props.scroll.bodyRows));
|
|
572
594
|
for(;;) {
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
if(height>4)height=Math.max(4,Math.floor(height*.75));
|
|
593
|
-
else if(width>32)width=Math.max(32,Math.floor(width*.75));
|
|
594
|
-
else return Text({...styles.text,children:[tr('task.fallback')]});
|
|
595
|
+
const lines=taskViewerView(state,Math.max(2,width-2),Math.max(1,height-3));
|
|
596
|
+
const {elements,frame}=frameElements();
|
|
597
|
+
elements.Text({...styles.muted,wrap:'truncate',children:[clip(tr('task.viewer.help_read'),width)]});
|
|
598
|
+
const reduced=width<e.props.bodyColumns||height<e.props.scroll.bodyRows;
|
|
599
|
+
const pane=Box({width,height,flexDirection:'column',children:[
|
|
600
|
+
Text({...styles.accent,bold:true,wrap:'truncate',children:[clip((reduced?t('native.capacity.reduced',state.language,{columns:width,rows:height})+' · ':'')+tr('task.title')+' · '+(state.busy?tr('profiles.loading'):tr('task.readonly')),width)]}),
|
|
601
|
+
...lines.map(row=>Text({...styles.text,bold:row.selected,wrap:'truncate',children:[row.text]})),
|
|
602
|
+
Client({key:'task-client-'+state.epoch,module:'../ui/client/surface.ts',width,height:1,props:{epoch:state.epoch,ack:state.ack,generation:++state.frameGeneration,columns:width,rows:1,displayColumns:width,displayRows:1,language:state.language,busy:false,frame}}),
|
|
603
|
+
Box({flexDirection:'row',columnGap:1,children:[
|
|
604
|
+
Button({...recoveryButton,key:'task-up',label:'↑',hotkey:'k',onPress:()=>{taskViewerKey(state,{key:'pageup'});$.ui.invalidate('ui.render');}}),
|
|
605
|
+
Button({...recoveryButton,key:'task-down',label:'↓',hotkey:'j',onPress:()=>{taskViewerKey(state,{key:'pagedown'});$.ui.invalidate('ui.render');}}),
|
|
606
|
+
Button({...recoveryButton,key:'task-refresh',label:tr('profiles.refresh'),hotkey:'r',onPress:()=>refreshTaskDetails($,options,state)}),
|
|
607
|
+
Button({...recoveryButton,key:'task-close',label:tr('task.close'),hotkey:'q',onPress:()=>$.ui.close({id:TASK_PANE})}),
|
|
608
|
+
]}),
|
|
609
|
+
]});
|
|
610
|
+
if(withinBudget(pane))return pane;
|
|
611
|
+
if(height>6)height=Math.max(6,Math.floor(height*.75));
|
|
612
|
+
else if(width>32)width=Math.max(32,Math.floor(width*.75));
|
|
613
|
+
else return Text({...styles.text,children:[tr('task.fallback')]});
|
|
595
614
|
}
|
|
596
615
|
});
|
|
597
616
|
}
|
|
@@ -626,7 +645,8 @@ export const register: Register = (on, options) => {
|
|
|
626
645
|
on('session.start', async ($, e, next) => {
|
|
627
646
|
await startTaskDetails($, taskDetails, options);
|
|
628
647
|
state.ownsCommand = false;
|
|
629
|
-
if (state.view.editor?.
|
|
648
|
+
if (state.view.editor?.packages) await closePackage(state.view.editor.packages,{request:(operation,payload)=>callBackend($,options,operation,payload)});
|
|
649
|
+
if (state.view.editor?.sources) await closeSources(state.view.editor,{request:(operation,payload)=>callBackend($,options,operation,payload)});
|
|
630
650
|
discard(state);
|
|
631
651
|
const open = await $.ui.panes();
|
|
632
652
|
if (open.some((p) => p.id === PANE)) {
|
|
@@ -664,7 +684,8 @@ export const register: Register = (on, options) => {
|
|
|
664
684
|
$.ui.invalidate('ui.render');
|
|
665
685
|
return { deny: state.view.error };
|
|
666
686
|
}
|
|
667
|
-
if (state.view.editor?.
|
|
687
|
+
if (state.view.editor?.packages) await closePackage(state.view.editor.packages,{request:(operation,payload)=>callBackend($,options,operation,payload)});
|
|
688
|
+
if (state.view.editor?.sources) await closeSources(state.view.editor,{request:(operation,payload)=>callBackend($,options,operation,payload)});
|
|
668
689
|
const result = await next(e);
|
|
669
690
|
const open = await $.ui.panes();
|
|
670
691
|
if (!open.some((p) => p.id === PANE)) discard(state);
|
|
@@ -755,6 +776,10 @@ export const register: Register = (on, options) => {
|
|
|
755
776
|
});
|
|
756
777
|
state.diagnosisTimer=timer;
|
|
757
778
|
}
|
|
779
|
+
else if (effect === 'packages' && state.view.editor?.packages) {
|
|
780
|
+
const view=state.view.editor.packages;await performPackage(view,{request:(operation,payload)=>callBackend($,options,operation,payload)});
|
|
781
|
+
if(view.closed)state.view.editor.packages=null;
|
|
782
|
+
}
|
|
758
783
|
else if (effect === 'sources' && state.view.editor) {
|
|
759
784
|
state.writing=true;
|
|
760
785
|
try { await performSourceAction(state.view.editor,{request:(operation,payload)=>callBackend($,options,operation,payload)}); }
|
|
@@ -848,7 +873,7 @@ export const register: Register = (on, options) => {
|
|
|
848
873
|
width >= MIN_COLUMNS &&
|
|
849
874
|
height >= MIN_ROWS &&
|
|
850
875
|
!state.writing &&
|
|
851
|
-
!editor?.diagnosis && state.previewKey !== key
|
|
876
|
+
!editor?.diagnosis && !editor?.packages && state.previewKey !== key
|
|
852
877
|
) {
|
|
853
878
|
state.previewKey = key;
|
|
854
879
|
const requestedEpoch = state.epoch;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Generated by tools/generation/resources.ts; do not edit.
|
|
2
|
+
import { isPackageResult } from './editor/package-validation.ts';
|
|
2
3
|
import { isScenario } from './editor/preview-settings.ts';
|
|
3
4
|
import { validAlignments } from './editor/alignments.ts';
|
|
4
5
|
import { GRADIENT_KEYS, validGradient } from './editor/gradients.ts';
|
|
@@ -478,6 +479,8 @@ export function parseResponse<O extends Operation>(
|
|
|
478
479
|
if (!exact(result, ['draft','changes']) || !isDraft(result.draft) || !Array.isArray(result.changes) || !result.changes.every(isImportChange)) fail();
|
|
479
480
|
} else if (operation === 'import' || operation === 'preset') {
|
|
480
481
|
if (!isDraft(result.draft)) fail();
|
|
482
|
+
} else if (operation.startsWith('package_')) {
|
|
483
|
+
if (!isPackageResult(operation,result)) fail();
|
|
481
484
|
} else if (operation.startsWith('source')) {
|
|
482
485
|
if (!isSourceResult(operation,result)) fail();
|
|
483
486
|
} else if (operation === 'profiles_read' || operation === 'profiles_apply') {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { packageManager, packageKey } from '../editor/package-manager.ts';
|
|
1
2
|
import { openDiagnosis, diagnosisKey } from '../editor/diagnosis-view.ts';
|
|
2
3
|
import { openColors, colorsKey } from '../editor/color-manager.ts';
|
|
3
4
|
import { SCENARIO_IDS, PREVIEW_WIDTHS, cyclePreview } from '../editor/preview-settings.ts';
|
|
@@ -20,7 +21,7 @@ import { formSelection, pageSelection } from '../editor/navigation.ts';
|
|
|
20
21
|
import { guidanceLines } from '../editor/guidance.ts';
|
|
21
22
|
import { navigateReview } from '../editor/import-review.ts';
|
|
22
23
|
|
|
23
|
-
export type Effect = 'diagnoseFile' | 'save' | 'finish' | 'close' | 'reload' | 'reconcile' | 'retry' | 'applyPreferences' | 'transfer' | 'previewBackground' | 'uiLanguage' | 'reviewPreview' | 'explain' | 'profiles' | 'sources' | null;
|
|
24
|
+
export type Effect = 'packages' | 'diagnoseFile' | 'save' | 'finish' | 'close' | 'reload' | 'reconcile' | 'retry' | 'applyPreferences' | 'transfer' | 'previewBackground' | 'uiLanguage' | 'reviewPreview' | 'explain' | 'profiles' | 'sources' | null;
|
|
24
25
|
|
|
25
26
|
export function cancelInput(view: View): void {
|
|
26
27
|
const input = view.input, e = view.editor;
|
|
@@ -42,6 +43,7 @@ export function handleKey(view: View, event: NativeKeyEvent, columns: number, ro
|
|
|
42
43
|
if (e) e.setSaveState(view.uncertain ? 'unknown' : view.busy ? 'pending' : 'idle');
|
|
43
44
|
if (!e || view.busy) return null;
|
|
44
45
|
if (event.overflow) { setMessage(view, 'message', localizedText('input.overflow')); return null; }
|
|
46
|
+
if(e.packages)return packageKey(e.packages,event);
|
|
45
47
|
if(e.diagnosis)return diagnosisKey(e,event);
|
|
46
48
|
if(e.colors)return colorsKey(e,event,view.language ?? 'en');
|
|
47
49
|
if(event.ctrl&&key.toLowerCase()==='l'&&!view.input&&!e.sources&&!e.profiles&&!e.groupManager&&!e.alignmentManager&&!e.quick&&!e.review&&!e.explanation){openDiagnosis(e);return null;}
|
|
@@ -218,6 +220,7 @@ export function handleKey(view: View, event: NativeKeyEvent, columns: number, ro
|
|
|
218
220
|
else if (e.setting === 'row-alignment') { openAlignments(e); return null; }
|
|
219
221
|
else if (e.setting === 'component-groups') { openGroups(e); return null; }
|
|
220
222
|
else if (e.setting === 'sources') {openSources(e);return 'sources';}
|
|
223
|
+
else if (e.setting === 'package-management') {e.packages=packageManager();return 'packages';}
|
|
221
224
|
else if (e.setting === 'profiles') { if (e.acceptNumeric()) { openProfiles(e); return 'profiles'; } }
|
|
222
225
|
else if (e.setting === 'quick-setup') { if (e.acceptNumeric()) e.quick=openQuick(e.draft); }
|
|
223
226
|
else if(e.setting==='item-explain' && e.detail) { e.explanation=openExplanation(e.detail.scope,e.detail.id); return 'explain'; }
|
package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/settings.ts
CHANGED
|
@@ -111,6 +111,7 @@ export function settingRows(view: View): SettingRow[] {
|
|
|
111
111
|
{ key: 'preset-apply', label: 'Expand selected preset', group: 'Presets / portable files', value: 'replace draft; save later', editable: true },
|
|
112
112
|
{ key: 'import-file', label: 'Import file', group: 'Presets / portable files', value: 'file path; save later', editable: true },
|
|
113
113
|
{ key: 'export-file', label: 'Export current draft', group: 'Presets / portable files', value: 'new file path (may be unsaved)', editable: true },
|
|
114
|
+
{ key: 'package-management', label: 'Version and installation', group: 'Inspection', value: 'Enter', editable: true },
|
|
114
115
|
);
|
|
115
116
|
if (e.advanced) {
|
|
116
117
|
for (const spec of PREFERENCE_SPECS) {
|
package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/draft.ts
CHANGED
|
@@ -61,6 +61,8 @@ export class Editor {
|
|
|
61
61
|
explanation: ExplanationView | null = null;
|
|
62
62
|
profiles: ProfileManager | null = null;
|
|
63
63
|
sources: SourceManager | null = null;
|
|
64
|
+
taskViewer: import('./task-viewer.js').TaskViewer | null = null;
|
|
65
|
+
packages: import('./package-manager.js').PackageManager | null = null;
|
|
64
66
|
groupManager: GroupManager | null = null;
|
|
65
67
|
alignmentManager: AlignmentManager | null = null;
|
|
66
68
|
compositionError: LocalizedText = text('composition.invalid');
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
// Generated by tools/generation/resources.ts; do not edit.
|
|
2
|
+
import type { PackageStatus, PackageReviewJob, PackageReviewRequest, Operation, ResultFor } from '../generated-contracts.ts';
|
|
3
|
+
import { t, text, renderMessage, type Language, type LocalizedText } from '../i18n/index.ts';
|
|
4
|
+
import { inputKey, inputView, textInput, type TextInput, type TextKey } from './text-input.ts';
|
|
5
|
+
import { wrapText } from '../../ui/text.ts';
|
|
6
|
+
import { BackendError } from '../backend.ts';
|
|
7
|
+
interface Row {
|
|
8
|
+
key: string;
|
|
9
|
+
text: string;
|
|
10
|
+
action?: PackageReviewRequest['action'];
|
|
11
|
+
backup?: string;
|
|
12
|
+
selected?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface PackageManager {
|
|
15
|
+
owner: string;
|
|
16
|
+
status: PackageStatus | null;
|
|
17
|
+
job: PackageReviewJob | null;
|
|
18
|
+
prefix: string;
|
|
19
|
+
target: string;
|
|
20
|
+
channel: 'latest' | 'beta' | null;
|
|
21
|
+
offset: number;
|
|
22
|
+
selected: string;
|
|
23
|
+
scroll: number;
|
|
24
|
+
rows: Row[];
|
|
25
|
+
capacity: number;
|
|
26
|
+
input: TextInput | null;
|
|
27
|
+
editing: 'prefix' | 'target' | null;
|
|
28
|
+
message: LocalizedText | string | null;
|
|
29
|
+
effect: 'load' | 'start' | 'status' | 'cancel' | 'close' | null;
|
|
30
|
+
action: PackageReviewRequest['action'];
|
|
31
|
+
backup: string | null;
|
|
32
|
+
busy: boolean;
|
|
33
|
+
closed: boolean;
|
|
34
|
+
generation: number;
|
|
35
|
+
}
|
|
36
|
+
export function packageManager(): PackageManager {
|
|
37
|
+
return { owner: 'viewer-' + Date.now().toString(36) + '-' + Math.random().toString(36).slice(2), status: null, job: null,
|
|
38
|
+
prefix: '', target: '', channel: null, offset: 0, selected: 'prefix', scroll: 0, rows: [], capacity: 1, input: null, editing: null, message: null,
|
|
39
|
+
effect: 'load', action: 'check', backup: null, busy: false, closed: false, generation: 0 };
|
|
40
|
+
}
|
|
41
|
+
export interface PackageBackend {
|
|
42
|
+
request<O extends Operation>(operation: O, payload?: unknown): ResultFor<O> | Promise<ResultFor<O>>;
|
|
43
|
+
}
|
|
44
|
+
export async function closePackage(view: PackageManager, backend: PackageBackend): Promise<void> {
|
|
45
|
+
view.closed = true;
|
|
46
|
+
view.generation++;
|
|
47
|
+
const job = view.job;
|
|
48
|
+
if (job)
|
|
49
|
+
try {
|
|
50
|
+
await backend.request('package_review_cancel', { id: job.id, owner: view.owner });
|
|
51
|
+
}
|
|
52
|
+
catch { /* Worker deadlines still bound a disconnected view. */ }
|
|
53
|
+
}
|
|
54
|
+
export async function performPackage(view: PackageManager, backend: PackageBackend): Promise<void> {
|
|
55
|
+
const effect = view.effect;
|
|
56
|
+
if (!effect || view.busy)
|
|
57
|
+
return;
|
|
58
|
+
view.effect = null;
|
|
59
|
+
if (effect === 'close') {
|
|
60
|
+
await closePackage(view, backend);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
view.busy = true;
|
|
64
|
+
const generation = view.generation;
|
|
65
|
+
try {
|
|
66
|
+
if (effect === 'load') {
|
|
67
|
+
if (view.job && view.prefix && view.job.request.prefix !== view.prefix) {
|
|
68
|
+
const cancelled = await backend.request('package_review_cancel', { id: view.job.id, owner: view.owner });
|
|
69
|
+
if (view.closed || generation !== view.generation)
|
|
70
|
+
return;
|
|
71
|
+
if (cancelled.state !== 'cancelled') {
|
|
72
|
+
view.job = cancelled;
|
|
73
|
+
view.message = text('package.ui.cancel_requested');
|
|
74
|
+
view.selected = 'message';
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
view.job = null;
|
|
78
|
+
}
|
|
79
|
+
const status = await backend.request('package_status', { prefix: view.prefix || null, offset: view.offset });
|
|
80
|
+
if (view.closed || generation !== view.generation)
|
|
81
|
+
return;
|
|
82
|
+
if (view.job && status.revision !== view.job.request.expected_revision) {
|
|
83
|
+
view.job = { ...view.job, state: 'failed', review: null, error: 'conflict' };
|
|
84
|
+
view.message = text('package.ui.changed');
|
|
85
|
+
view.selected = 'message';
|
|
86
|
+
}
|
|
87
|
+
view.status = status;
|
|
88
|
+
view.prefix = status.prefix ?? view.prefix;
|
|
89
|
+
}
|
|
90
|
+
else if (effect === 'start') {
|
|
91
|
+
if (!view.status?.prefix)
|
|
92
|
+
throw new BackendError('prefix', text('package.reason_prefix'));
|
|
93
|
+
if (view.job?.state === 'running')
|
|
94
|
+
return;
|
|
95
|
+
const previous = view.job;
|
|
96
|
+
let target = view.action === 'recover-package' ? view.status.pending?.version ?? view.target : view.target || null;
|
|
97
|
+
let integrity: string | null = null;
|
|
98
|
+
if (view.action === 'update' && previous?.state === 'complete' && previous.request.action === 'check' && previous.request.expected_revision === view.status.revision && previous.review &&
|
|
99
|
+
(!target || target === previous.review.target) && (!view.channel || view.channel === previous.review.channel || !!target)) {
|
|
100
|
+
target = previous.review.target;
|
|
101
|
+
integrity = previous.review.integrity;
|
|
102
|
+
}
|
|
103
|
+
const request: PackageReviewRequest = { action: view.action, prefix: view.status.prefix, expected_revision: view.status.revision,
|
|
104
|
+
target: view.action === 'restore-config' ? null : target, channel: !target && ['check', 'update'].includes(view.action) ? view.channel : null,
|
|
105
|
+
backup_id: view.action === 'restore-config' ? view.backup : null, expected_integrity: integrity };
|
|
106
|
+
if (previous) {
|
|
107
|
+
const cancelled = await backend.request('package_review_cancel', { id: previous.id, owner: view.owner });
|
|
108
|
+
if (view.closed || generation !== view.generation)
|
|
109
|
+
return;
|
|
110
|
+
if (cancelled.state !== 'cancelled') {
|
|
111
|
+
view.job = cancelled;
|
|
112
|
+
view.message = text('package.ui.cancel_requested');
|
|
113
|
+
view.selected = 'message';
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
view.job = null;
|
|
117
|
+
}
|
|
118
|
+
const job = await backend.request('package_review_start', { request, owner: view.owner });
|
|
119
|
+
if (view.closed || generation !== view.generation) {
|
|
120
|
+
await backend.request('package_review_cancel', { id: job.id, owner: view.owner });
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
view.job = job;
|
|
124
|
+
view.message = null;
|
|
125
|
+
view.selected = 'job';
|
|
126
|
+
}
|
|
127
|
+
else if (view.job) {
|
|
128
|
+
const job = await backend.request(effect === 'cancel' ? 'package_review_cancel' : 'package_review_status', { id: view.job.id, owner: view.owner });
|
|
129
|
+
if (view.closed || generation !== view.generation)
|
|
130
|
+
return;
|
|
131
|
+
const cancelled = effect === 'cancel' && job.state === 'cancelled';
|
|
132
|
+
view.job = cancelled ? null : job;
|
|
133
|
+
view.message = effect === 'cancel' ? text(cancelled ? 'package.cancelled' : 'package.ui.cancel_requested') : null;
|
|
134
|
+
if (effect === 'cancel')
|
|
135
|
+
view.selected = 'message';
|
|
136
|
+
else if (job.state !== 'running') {
|
|
137
|
+
view.selected = job.review ? 'verification' : job.error ? 'job-error' : 'job';
|
|
138
|
+
view.scroll = Math.max(0, view.rows.findIndex(row => row.key === 'job'));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
if (!view.closed && generation === view.generation) {
|
|
144
|
+
view.message = error instanceof BackendError && error.localization ? error.localization : text('package.reason_io_error');
|
|
145
|
+
view.selected = 'message';
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
finally {
|
|
149
|
+
if (generation === view.generation)
|
|
150
|
+
view.busy = false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
export function packageView(view: PackageManager, language: Language, width: number, height: number): Row[] {
|
|
154
|
+
const tr = (key: string, params: Record<string, unknown> = {}) => t(key, language, params), rows: Row[] = [];
|
|
155
|
+
const add = (key: string, value: string, action?: Row['action'], backup?: string) => wrapText([value.replace(/[\p{Cc}\p{Cs}]/gu, '')], Math.max(2, width - 2)).forEach((line, index) => rows.push({ key: index ? key + ':' + index : key, text: line, ...(action ? { action } : {}), ...(backup ? { backup } : {}) }));
|
|
156
|
+
const status = view.status;
|
|
157
|
+
add('notice', tr('package.ui.readonly'));
|
|
158
|
+
if (status)
|
|
159
|
+
add('current', tr('package.ui.current', { value: status.current ?? tr('task.unknown') }));
|
|
160
|
+
add('prefix', tr('package.ui.prefix', { value: view.editing === 'prefix' && view.input ? inputView(view.input, Math.max(2, width - 12)) : view.prefix || tr('task.unknown') }));
|
|
161
|
+
if (!status)
|
|
162
|
+
add('loading', tr(view.busy ? 'profiles.loading' : 'task.unknown'));
|
|
163
|
+
else {
|
|
164
|
+
add('entry', tr('package.ui.entry', { value: status.entry ?? tr('task.unknown') }));
|
|
165
|
+
add('config', tr('package.ui.config', { value: status.config_dir }));
|
|
166
|
+
add('previous', tr('package.ui.previous', { value: status.previous ?? tr('task.unknown') }));
|
|
167
|
+
add('observed-channel', tr('package.ui.channel', { value: status.channel ?? tr('task.unknown') }));
|
|
168
|
+
add('runtime', `Node ${status.node_version} · Claude ${status.host ?? tr('task.unknown')}`);
|
|
169
|
+
status.reasons.forEach(reason => add('reason:' + reason, t('package.reason_' + reason, language, {}, reason)));
|
|
170
|
+
add('target', tr('package.ui.target', { value: view.editing === 'target' && view.input ? inputView(view.input, Math.max(2, width - 12)) : view.target || tr('package.ui.default_target') }));
|
|
171
|
+
add('channel', tr('package.ui.channel', { value: view.channel ?? tr('package.ui.inherit') }));
|
|
172
|
+
for (const action of ['check', 'update', 'rollback', 'recover-package'] as const)
|
|
173
|
+
add(action, 'Enter · ' + tr('package.ui.' + action), action);
|
|
174
|
+
if (status.pending)
|
|
175
|
+
add('pending', tr('package.ui.pending', { id: status.pending.id, stage: tr('package.ui.stage_' + status.pending.stage), running: status.pending.running ? tr('task.value.running') : tr('task.unknown') }));
|
|
176
|
+
for (const record of status.history) {
|
|
177
|
+
add('backup:' + record.id, `${record.id} · ${record.version ?? '—'} · ${tr('package.ui.stage_' + record.stage)} · ${tr('package.ui.backup_' + record.backup)}`, record.backup === 'verified' ? 'restore-config' : undefined, record.id);
|
|
178
|
+
}
|
|
179
|
+
if (status.total > 16) {
|
|
180
|
+
add('previous-page', tr('package.ui.previous_page'));
|
|
181
|
+
add('next-page', tr('package.ui.next_page'));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
const job = view.job;
|
|
185
|
+
if (job) {
|
|
186
|
+
add('job', tr('package.ui.job', { id: job.id, state: tr('package.ui.state_' + job.state) }));
|
|
187
|
+
if (job.error)
|
|
188
|
+
add('job-error', t('package.reason_' + job.error, language, {}, job.error));
|
|
189
|
+
if (job.review) {
|
|
190
|
+
const review = job.review;
|
|
191
|
+
add('verification', tr(review.action === 'restore-config' ? 'package.ui.restore_review' : review.artifact_verified ? 'package.ui.verified' : 'package.ui.unverified'));
|
|
192
|
+
add('review-target', `${review.current ?? '—'} → ${review.target ?? '—'}`);
|
|
193
|
+
add('review-config', tr('package.ui.config', { value: review.config_dir }));
|
|
194
|
+
if (review.registry)
|
|
195
|
+
add('registry', review.registry);
|
|
196
|
+
if (review.integrity)
|
|
197
|
+
add('integrity', review.integrity);
|
|
198
|
+
if (review.node_engine)
|
|
199
|
+
add('engine', 'Node ' + review.node_engine);
|
|
200
|
+
review.reasons.forEach(reason => add('review-reason:' + reason, t('package.reason_' + reason, language, {}, reason)));
|
|
201
|
+
review.configuration_conflicts.forEach(file => add('conflict:' + file, file));
|
|
202
|
+
review.files.forEach(file => add('restore:' + file, file));
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (view.message)
|
|
206
|
+
add('message', renderMessage(view.message, language));
|
|
207
|
+
let index = rows.findIndex(row => row.key === view.selected);
|
|
208
|
+
if (index < 0)
|
|
209
|
+
index = 0;
|
|
210
|
+
view.rows = rows;
|
|
211
|
+
view.selected = rows[index]?.key ?? '';
|
|
212
|
+
view.capacity = Math.max(1, height);
|
|
213
|
+
view.scroll = Math.max(0, Math.min(view.scroll, index, Math.max(0, rows.length - view.capacity)));
|
|
214
|
+
if (index >= view.scroll + view.capacity)
|
|
215
|
+
view.scroll = index - view.capacity + 1;
|
|
216
|
+
return rows.slice(view.scroll, view.scroll + view.capacity).map(row => ({ ...row, text: (row.key === view.selected ? '› ' : ' ') + row.text, selected: row.key === view.selected }));
|
|
217
|
+
}
|
|
218
|
+
export function packageKey(view: PackageManager, event: TextKey): 'packages' | null {
|
|
219
|
+
const key = event.key === 'return' ? 'enter' : event.key, cancel = !event.text && !event.paste && (key === 'escape' || event.ctrl && key.toLowerCase() === 'g');
|
|
220
|
+
if (view.input && view.editing) {
|
|
221
|
+
if (cancel) {
|
|
222
|
+
view.input = null;
|
|
223
|
+
view.editing = null;
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
if (!event.text && !event.paste && key === 'enter') {
|
|
227
|
+
const field = view.editing;
|
|
228
|
+
view[field] = view.input.value;
|
|
229
|
+
view.input = null;
|
|
230
|
+
view.editing = null;
|
|
231
|
+
if (field === 'prefix')
|
|
232
|
+
view.status = null;
|
|
233
|
+
if (field === 'target' && view.job) {
|
|
234
|
+
view.effect = 'cancel';
|
|
235
|
+
return 'packages';
|
|
236
|
+
}
|
|
237
|
+
if (field === 'prefix') {
|
|
238
|
+
view.offset = 0;
|
|
239
|
+
view.effect = 'load';
|
|
240
|
+
return 'packages';
|
|
241
|
+
}
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
const result = inputKey(view.input.value, view.input, event, view.editing === 'prefix' ? 4096 : 100);
|
|
245
|
+
view.input = result.state;
|
|
246
|
+
if (result.error)
|
|
247
|
+
view.message = text('input.' + result.error, { limit: view.editing === 'prefix' ? 4096 : 100 });
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
if (event.text || event.paste || event.meta)
|
|
251
|
+
return null;
|
|
252
|
+
if (cancel || !event.ctrl && key.toLowerCase() === 'q') {
|
|
253
|
+
view.effect = 'close';
|
|
254
|
+
return 'packages';
|
|
255
|
+
}
|
|
256
|
+
if (event.ctrl || view.busy)
|
|
257
|
+
return null;
|
|
258
|
+
if (key.toLowerCase() === 'r') {
|
|
259
|
+
view.effect = view.job ? 'status' : 'load';
|
|
260
|
+
return 'packages';
|
|
261
|
+
}
|
|
262
|
+
if (key.toLowerCase() === 'l') {
|
|
263
|
+
view.effect = 'load';
|
|
264
|
+
return 'packages';
|
|
265
|
+
}
|
|
266
|
+
if (key.toLowerCase() === 'c' && view.job) {
|
|
267
|
+
view.effect = 'cancel';
|
|
268
|
+
return 'packages';
|
|
269
|
+
}
|
|
270
|
+
let index = Math.max(0, view.rows.findIndex(row => row.key === view.selected));
|
|
271
|
+
if (key === 'up')
|
|
272
|
+
index--;
|
|
273
|
+
if (key === 'down')
|
|
274
|
+
index++;
|
|
275
|
+
if (key === 'pageup')
|
|
276
|
+
index -= view.capacity;
|
|
277
|
+
if (key === 'pagedown')
|
|
278
|
+
index += view.capacity;
|
|
279
|
+
if (key === 'home')
|
|
280
|
+
index = 0;
|
|
281
|
+
if (key === 'end')
|
|
282
|
+
index = view.rows.length - 1;
|
|
283
|
+
view.selected = view.rows[Math.max(0, Math.min(index, view.rows.length - 1))]?.key ?? '';
|
|
284
|
+
if (key !== 'enter')
|
|
285
|
+
return null;
|
|
286
|
+
const selectedKey = view.selected.replace(/:\d+$/u, '');
|
|
287
|
+
if (selectedKey === 'prefix' || selectedKey === 'target') {
|
|
288
|
+
view.editing = selectedKey;
|
|
289
|
+
view.input = textInput(view[view.editing]);
|
|
290
|
+
return null;
|
|
291
|
+
}
|
|
292
|
+
if (selectedKey === 'channel') {
|
|
293
|
+
const channels = [null, 'latest', 'beta'] as const;
|
|
294
|
+
view.channel = channels[(channels.indexOf(view.channel) + 1) % 3]!;
|
|
295
|
+
if (view.job) {
|
|
296
|
+
view.effect = 'cancel';
|
|
297
|
+
return 'packages';
|
|
298
|
+
}
|
|
299
|
+
return null;
|
|
300
|
+
}
|
|
301
|
+
if (['next-page', 'previous-page'].includes(selectedKey)) {
|
|
302
|
+
view.offset = Math.max(0, Math.min(view.offset + (selectedKey === 'next-page' ? 16 : -16), Math.max(0, Math.floor(((view.status?.total ?? 1) - 1) / 16) * 16)));
|
|
303
|
+
view.effect = 'load';
|
|
304
|
+
return 'packages';
|
|
305
|
+
}
|
|
306
|
+
const selected = view.rows.find(row => row.key === view.selected);
|
|
307
|
+
if (selected?.action) {
|
|
308
|
+
view.action = selected.action;
|
|
309
|
+
view.backup = selected.backup ?? null;
|
|
310
|
+
view.effect = 'start';
|
|
311
|
+
return 'packages';
|
|
312
|
+
}
|
|
313
|
+
return null;
|
|
314
|
+
}
|