opencode-navigator 0.21.8 → 0.22.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/CHANGELOG.md +9 -1
- package/README.md +93 -19
- package/dist/{chunk-d1bws32s.js → chunk-dz8cfnfs.js} +4 -3
- package/dist/chunk-qmntexwm.js +0 -0
- package/dist/chunk-v6bz59xn.js +20 -0
- package/dist/icon-picker.js +175 -0
- package/dist/layout-preset-actions.js +4 -20
- package/dist/navigator-updates.js +12 -4
- package/dist/project-profile.js +12 -4
- package/dist/provider-limits.js +3 -1
- package/dist/quick-actions-settings.js +5 -13
- package/dist/rpc.js +1 -0
- package/dist/runtime-dependencies.json +10 -0
- package/dist/server.js +16 -54
- package/dist/settings-import.js +4 -3
- package/dist/sidebar-settings.js +828 -0
- package/dist/sidebar-shortcuts.js +261 -0
- package/dist/toolbar-settings.js +161 -0
- package/dist/tui.js +949 -990
- package/package.json +8 -7
- package/scripts/snapshot-runtime.mjs +32 -0
- package/scripts/update-local-snapshot.mjs +14 -3
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import {PLUGIN_ID
|
|
2
|
+
} from "./chunk-dz8cfnfs.js";
|
|
3
|
+
import {createSignal} from "solid-js"
|
|
4
|
+
import {supportsSidebarSection} from "./tui.js"
|
|
5
|
+
var ACTIONS=[{key:"h",label:"Toggle sidebar",icon:"sections",group:"navigate",command:"session.sidebar.toggle",section:undefined
|
|
6
|
+
},{key:"t",label:"Todo",icon:"todo",group:"navigate",command:`${PLUGIN_ID}.focus.todo`,section:"todo"},{key:"a",label:"Subagents",icon:"subagents",group:"navigate",command:`${PLUGIN_ID}.focus.subagents`,section:"subagents"
|
|
7
|
+
},{key:"s",label:"Skills",icon:"skills",group:"navigate",command:`${PLUGIN_ID}.focus.skills`,section:"skills"
|
|
8
|
+
},{key:"q",label:"Quick actions",icon:"actions",group:"navigate",command:`${PLUGIN_ID}.focus.quick_actions`,section:"quick_actions"
|
|
9
|
+
},{key:"l",label:"LSP",icon:"lsp",group:"navigate",command:`${PLUGIN_ID}.focus.lsp`,section:"lsp"},{key:"m",label:"MCP",icon:"mcp",group:"navigate",command:`${PLUGIN_ID}.focus.mcp`,section:"mcp"},{key:"c",label:"Check update",icon:"search",group:"updates",command:`${PLUGIN_ID}.check-update`,section:undefined
|
|
10
|
+
},{key:"u",label:"Update Navigator",icon:"update",group:"updates",command:`${PLUGIN_ID}.update-navigator`,section:undefined
|
|
11
|
+
}];
|
|
12
|
+
var ENTRY_COMMAND=`${PLUGIN_ID}.sidebar-shortcuts.enter`
|
|
13
|
+
var CANCEL_COMMAND=`${PLUGIN_ID}.sidebar-shortcuts.cancel`
|
|
14
|
+
var MODE=`${PLUGIN_ID}.sidebar-shortcuts`;
|
|
15
|
+
import {lazy} from "solid-js"
|
|
16
|
+
var SidebarShortcutHint=lazy(()=>{const path=import.meta.url.includes("/dist/tui.js")?"./sidebar-shortcuts.js":"../../../sidebar-shortcuts"
|
|
17
|
+
return import(path)
|
|
18
|
+
});
|
|
19
|
+
import {createComponent as _$createComponent3} from "@opentui/solid"
|
|
20
|
+
import {effect as _$effect3} from "@opentui/solid"
|
|
21
|
+
import {createTextNode as _$createTextNode} from "@opentui/solid"
|
|
22
|
+
import {insertNode as _$insertNode3} from "@opentui/solid"
|
|
23
|
+
import {insert as _$insert3} from "@opentui/solid"
|
|
24
|
+
import {memo as _$memo} from "@opentui/solid"
|
|
25
|
+
import {setProp as _$setProp3} from "@opentui/solid"
|
|
26
|
+
import {createElement as _$createElement3} from "@opentui/solid"
|
|
27
|
+
import {TextAttributes as TextAttributes2} from "@opentui/core"
|
|
28
|
+
import {useTerminalDimensions} from "@opentui/solid"
|
|
29
|
+
import {Show as Show3} from "solid-js"
|
|
30
|
+
import {SelectionBox as SelectionBox2,useIcons as useIcons2} from "./tui.js"
|
|
31
|
+
import {insertNode as _$insertNode2} from "@opentui/solid"
|
|
32
|
+
import {createComponent as _$createComponent2} from "@opentui/solid"
|
|
33
|
+
import {effect as _$effect2} from "@opentui/solid"
|
|
34
|
+
import {insert as _$insert2} from "@opentui/solid"
|
|
35
|
+
import {setProp as _$setProp2} from "@opentui/solid"
|
|
36
|
+
import {createElement as _$createElement2} from "@opentui/solid"
|
|
37
|
+
import {For,Show as Show2} from "solid-js"
|
|
38
|
+
import {insertNode as _$insertNode} from "@opentui/solid"
|
|
39
|
+
import {createComponent as _$createComponent} from "@opentui/solid"
|
|
40
|
+
import {effect as _$effect} from "@opentui/solid"
|
|
41
|
+
import {insert as _$insert} from "@opentui/solid"
|
|
42
|
+
import {setProp as _$setProp} from "@opentui/solid"
|
|
43
|
+
import {createElement as _$createElement} from "@opentui/solid"
|
|
44
|
+
import {TextAttributes} from "@opentui/core"
|
|
45
|
+
import {Show} from "solid-js"
|
|
46
|
+
import {SelectionBox,useIcons} from "./tui.js"
|
|
47
|
+
function ShortcutKey(props){const icons=useIcons()
|
|
48
|
+
const theme=()=>props.api.theme.current
|
|
49
|
+
const keyWidth=()=>props.keyLabel.length + 2
|
|
50
|
+
return(()=>{var _el$=_$createElement("box"),_el$3=_$createElement("box"),_el$5=_$createElement("text")
|
|
51
|
+
_$insertNode(_el$,_el$3)
|
|
52
|
+
_$setProp(_el$,"height",1)
|
|
53
|
+
_$setProp(_el$,"flexDirection","row")
|
|
54
|
+
_$setProp(_el$,"gap",1)
|
|
55
|
+
_$setProp(_el$,"overflow","hidden")
|
|
56
|
+
_$insert(_el$,_$createComponent(SelectionBox,{get width(){return keyWidth()
|
|
57
|
+
},height:1,flexShrink:0,get backgroundColor(){return theme().backgroundElement
|
|
58
|
+
},get children(){var _el$2=_$createElement("text")
|
|
59
|
+
_$insert(_el$2,()=>props.keyLabel)
|
|
60
|
+
_$effect((_p$)=>{var _v$=theme().accent,_v$2=TextAttributes.BOLD
|
|
61
|
+
_v$!==_p$.e&&(_p$.e=_$setProp(_el$2,"fg",_v$,_p$.e))
|
|
62
|
+
_v$2!==_p$.t&&(_p$.t=_$setProp(_el$2,"attributes",_v$2,_p$.t))
|
|
63
|
+
return _p$
|
|
64
|
+
},{e:undefined,t:undefined
|
|
65
|
+
})
|
|
66
|
+
return _el$2
|
|
67
|
+
}}),_el$3)
|
|
68
|
+
_$insertNode(_el$3,_el$5)
|
|
69
|
+
_$setProp(_el$3,"flexDirection","row")
|
|
70
|
+
_$setProp(_el$3,"gap",1)
|
|
71
|
+
_$setProp(_el$3,"flexShrink",1)
|
|
72
|
+
_$setProp(_el$3,"minWidth",0)
|
|
73
|
+
_$setProp(_el$3,"overflow","hidden")
|
|
74
|
+
_$insert(_el$3,_$createComponent(Show,{get when(){return props.width>=16
|
|
75
|
+
},get children(){var _el$4=_$createElement("text")
|
|
76
|
+
_$insert(_el$4,()=>icons.icon(props.icon))
|
|
77
|
+
_$effect((_$p)=>_$setProp(_el$4,"fg",theme().textMuted,_$p))
|
|
78
|
+
return _el$4
|
|
79
|
+
}}),_el$5)
|
|
80
|
+
_$setProp(_el$5,"wrapMode","none")
|
|
81
|
+
_$insert(_el$5,()=>props.label)
|
|
82
|
+
_$effect((_p$)=>{var _v$3=props.width,_v$4=theme().text
|
|
83
|
+
_v$3!==_p$.e&&(_p$.e=_$setProp(_el$,"width",_v$3,_p$.e))
|
|
84
|
+
_v$4!==_p$.t&&(_p$.t=_$setProp(_el$5,"fg",_v$4,_p$.t))
|
|
85
|
+
return _p$
|
|
86
|
+
},{e:undefined,t:undefined
|
|
87
|
+
})
|
|
88
|
+
return _el$
|
|
89
|
+
})()
|
|
90
|
+
}
|
|
91
|
+
function ShortcutGroup(props){const itemWidth=()=>Math.max(1,Math.floor((props.width-(props.columns-1)*2) / props.columns))
|
|
92
|
+
return(()=>{var _el$=_$createElement2("box"),_el$3=_$createElement2("box")
|
|
93
|
+
_$insertNode2(_el$,_el$3)
|
|
94
|
+
_$setProp2(_el$,"gap",0)
|
|
95
|
+
_$insert2(_el$,_$createComponent2(Show2,{get when(){return !props.compact
|
|
96
|
+
},get children(){var _el$2=_$createElement2("text")
|
|
97
|
+
_$insert2(_el$2,()=>props.title)
|
|
98
|
+
_$effect2((_$p)=>_$setProp2(_el$2,"fg",props.api.theme.current.textMuted,_$p))
|
|
99
|
+
return _el$2
|
|
100
|
+
}}),_el$3)
|
|
101
|
+
_$setProp2(_el$3,"flexDirection","row")
|
|
102
|
+
_$setProp2(_el$3,"flexWrap","wrap")
|
|
103
|
+
_$setProp2(_el$3,"columnGap",2)
|
|
104
|
+
_$insert2(_el$3,_$createComponent2(For,{get each(){return props.actions
|
|
105
|
+
},children:(action)=>_$createComponent2(ShortcutKey,{get api(){return props.api
|
|
106
|
+
},get keyLabel(){return action.key
|
|
107
|
+
},get label(){return action.label
|
|
108
|
+
},get icon(){return action.icon
|
|
109
|
+
},get width(){return itemWidth()
|
|
110
|
+
}})
|
|
111
|
+
}))
|
|
112
|
+
return _el$
|
|
113
|
+
})()
|
|
114
|
+
}
|
|
115
|
+
function SidebarShortcutHint2(props){const dimensions=useTerminalDimensions()
|
|
116
|
+
const icons=useIcons2()
|
|
117
|
+
const theme=()=>props.api.theme.current
|
|
118
|
+
const width=()=>Math.max(1,Math.min(66,dimensions().width-2))
|
|
119
|
+
const contentWidth=()=>Math.max(1,width()-2)
|
|
120
|
+
const compact=()=>dimensions().height<20
|
|
121
|
+
const columns=()=>compact()?width()>=50?3:2:width()>=50?2:1
|
|
122
|
+
const navigation=()=>props.actions.filter((action)=>action.group==="navigate")
|
|
123
|
+
const updates=()=>props.actions.filter((action)=>action.group==="updates")
|
|
124
|
+
const rows=()=>Math.ceil(navigation().length / columns()) + Math.ceil(updates().length / columns()) + (compact()?0:3)
|
|
125
|
+
const bodyHeight=()=>Math.min(rows(),Math.max(1,dimensions().height-8))
|
|
126
|
+
return(()=>{var _el$=_$createElement3("box")
|
|
127
|
+
_$setProp3(_el$,"position","absolute")
|
|
128
|
+
_$setProp3(_el$,"top",1)
|
|
129
|
+
_$setProp3(_el$,"right",1)
|
|
130
|
+
_$setProp3(_el$,"zIndex",2000)
|
|
131
|
+
_$setProp3(_el$,"overflow","hidden")
|
|
132
|
+
_$insert3(_el$,_$createComponent3(SelectionBox2,{id:"opencode-navigator.shortcuts.hint",width:"100%",get backgroundColor(){return theme().backgroundPanel
|
|
133
|
+
},get paddingTop(){return dimensions().height<8?0:1
|
|
134
|
+
},get paddingBottom(){return dimensions().height<8?0:1
|
|
135
|
+
},get gap(){return dimensions().height<8?0:1
|
|
136
|
+
},get children(){return [(()=>{var _el$2=_$createElement3("text"),_el$3=_$createTextNode(` Navigator shortcuts`)
|
|
137
|
+
_$insertNode3(_el$2,_el$3)
|
|
138
|
+
_$setProp3(_el$2,"wrapMode","none")
|
|
139
|
+
_$insert3(_el$2,()=>icons.icon("help"),_el$3)
|
|
140
|
+
_$effect3((_p$)=>{var _v$=theme().text,_v$2=TextAttributes2.BOLD
|
|
141
|
+
_v$!==_p$.e&&(_p$.e=_$setProp3(_el$2,"fg",_v$,_p$.e))
|
|
142
|
+
_v$2!==_p$.t&&(_p$.t=_$setProp3(_el$2,"attributes",_v$2,_p$.t))
|
|
143
|
+
return _p$
|
|
144
|
+
},{e:undefined,t:undefined
|
|
145
|
+
})
|
|
146
|
+
return _el$2
|
|
147
|
+
})(),_$createComponent3(Show3,{get when(){return dimensions().height>=10
|
|
148
|
+
},get children(){var _el$4=_$createElement3("scrollbox"),_el$5=_$createElement3("box")
|
|
149
|
+
_$insertNode3(_el$4,_el$5)
|
|
150
|
+
_$setProp3(_el$4,"scrollX",false)
|
|
151
|
+
_$setProp3(_el$4,"verticalScrollbarOptions",{visible:false
|
|
152
|
+
})
|
|
153
|
+
_$setProp3(_el$4,"horizontalScrollbarOptions",{visible:false
|
|
154
|
+
})
|
|
155
|
+
_$insert3(_el$5,_$createComponent3(ShortcutGroup,{get api(){return props.api
|
|
156
|
+
},title:"Navigate",get actions(){return navigation()
|
|
157
|
+
},get width(){return contentWidth()
|
|
158
|
+
},get columns(){return columns()
|
|
159
|
+
},get compact(){return compact()
|
|
160
|
+
}}),null)
|
|
161
|
+
_$insert3(_el$5,_$createComponent3(ShortcutGroup,{get api(){return props.api
|
|
162
|
+
},title:"Updates",get actions(){return updates()
|
|
163
|
+
},get width(){return contentWidth()
|
|
164
|
+
},get columns(){return columns()
|
|
165
|
+
},get compact(){return compact()
|
|
166
|
+
}}),null)
|
|
167
|
+
_$effect3((_p$)=>{var _v$3=bodyHeight(),_v$4=compact()?0:1
|
|
168
|
+
_v$3!==_p$.e&&(_p$.e=_$setProp3(_el$4,"height",_v$3,_p$.e))
|
|
169
|
+
_v$4!==_p$.t&&(_p$.t=_$setProp3(_el$5,"gap",_v$4,_p$.t))
|
|
170
|
+
return _p$
|
|
171
|
+
},{e:undefined,t:undefined
|
|
172
|
+
})
|
|
173
|
+
return _el$4
|
|
174
|
+
}}),_$createComponent3(ShortcutKey,{get api(){return props.api
|
|
175
|
+
},keyLabel:"Esc",label:"Cancel",icon:"close",get width(){return contentWidth()
|
|
176
|
+
}})]
|
|
177
|
+
}}))
|
|
178
|
+
_$effect3((_p$)=>{var _v$5=width(),_v$6=Math.max(1,dimensions().height-2),_v$7=theme().background
|
|
179
|
+
_v$5!==_p$.e&&(_p$.e=_$setProp3(_el$,"width",_v$5,_p$.e))
|
|
180
|
+
_v$6!==_p$.t&&(_p$.t=_$setProp3(_el$,"maxHeight",_v$6,_p$.t))
|
|
181
|
+
_v$7!==_p$.a&&(_p$.a=_$setProp3(_el$,"backgroundColor",_v$7,_p$.a))
|
|
182
|
+
return _p$
|
|
183
|
+
},{e:undefined,t:undefined,a:undefined
|
|
184
|
+
})
|
|
185
|
+
return _el$
|
|
186
|
+
})()
|
|
187
|
+
}
|
|
188
|
+
import {createComponent as _$createComponent5} from "@opentui/solid"
|
|
189
|
+
import {createDialogStack} from "./tui.js"
|
|
190
|
+
import {insert as _$insert4} from "@opentui/solid"
|
|
191
|
+
import {createComponent as _$createComponent4} from "@opentui/solid"
|
|
192
|
+
import {createElement as _$createElement4} from "@opentui/solid"
|
|
193
|
+
import {Suspense,lazy as lazy2} from "solid-js"
|
|
194
|
+
var HelpView=lazy2(async ()=>{const path=import.meta.url.includes("/dist/tui.js")?"./sidebar-shortcuts.js":"../../../sidebar-shortcuts"
|
|
195
|
+
const module=await import(path)
|
|
196
|
+
return{default:module.KeyboardHelpDialog
|
|
197
|
+
}});
|
|
198
|
+
import {createComponent as _$createComponent6} from "@opentui/solid"
|
|
199
|
+
import {use as _$use} from "@opentui/solid"
|
|
200
|
+
import {setProp as _$setProp4} from "@opentui/solid"
|
|
201
|
+
import {effect as _$effect4} from "@opentui/solid"
|
|
202
|
+
import {createTextNode as _$createTextNode2} from "@opentui/solid"
|
|
203
|
+
import {insertNode as _$insertNode4} from "@opentui/solid"
|
|
204
|
+
import {insert as _$insert5} from "@opentui/solid"
|
|
205
|
+
import {createElement as _$createElement5} from "@opentui/solid"
|
|
206
|
+
import {TextAttributes as TextAttributes3} from "@opentui/core"
|
|
207
|
+
import {useTerminalDimensions as useTerminalDimensions2} from "@opentui/solid"
|
|
208
|
+
import {Index,onCleanup} from "solid-js"
|
|
209
|
+
import {DialogSurface,useIcons as useIcons3} from "./tui.js"
|
|
210
|
+
function KeyboardHelpDialog2(props){const dimensions=useTerminalDimensions2()
|
|
211
|
+
const icons=useIcons3()
|
|
212
|
+
let body
|
|
213
|
+
const keys=["up","down","pageup","pagedown"]
|
|
214
|
+
const unregister=props.api.keymap.registerLayer({mode:"modal",commands:keys.map((_key,index)=>({name:`opencode-navigator.keyboard-help.scroll.${index}`,run:()=>body?.scrollBy([-1,1,-8,8][index])
|
|
215
|
+
})),bindings:keys.map((key,index)=>({key,cmd:`opencode-navigator.keyboard-help.scroll.${index}`
|
|
216
|
+
}))
|
|
217
|
+
})
|
|
218
|
+
onCleanup(unregister)
|
|
219
|
+
const theme=()=>props.api.theme.current
|
|
220
|
+
const hints=()=>[`${icons.key("up")}/k and ${icons.key("down")}/j move \xB7 ${icons.key("enter")} activates`,`${icons.key("enter")} on a filter starts typing \xB7 ${icons.key("esc")} returns`,`Todo: ${icons.key("enter")} on All / Active / Finished changes the view`,`MCP: ${icons.key("enter")} toggles a group`,"Show all / Show less expands or limits the filtered list",`Skills: ${icons.key("enter")} shows description and source \xB7 ${icons.icon("recent")} marks recent skills`,"Navigator Settings: Ctrl+,",`Navigator shortcuts: ${props.shortcuts?.map(({
|
|
221
|
+
key,
|
|
222
|
+
label
|
|
223
|
+
}) => `${key} ${label}`).join(" \xB7 ") || "use the configured sidebar shortcut"}`,`Search Everything: shortcut in Settings ${icons.icon("right")} Behavior`,`Search: type \xB7 ${icons.key("up/down")} results \xB7 ${icons.key("tab/shift+tab")} tabs \xB7 ${icons.key("enter")} run`,`${icons.key("esc")} leaves the sidebar \xB7 ${icons.key("?")} opens this help`]
|
|
224
|
+
return _$createComponent6(DialogSurface,{get api(){return props.api
|
|
225
|
+
},lift:true,get children(){return [(()=>{var _el$=_$createElement5("text"),_el$2=_$createTextNode2(` Navigator keyboard help`)
|
|
226
|
+
_$insertNode4(_el$,_el$2)
|
|
227
|
+
_$insert5(_el$,()=>icons.icon("help"),_el$2)
|
|
228
|
+
_$effect4((_p$)=>{var _v$=TextAttributes3.BOLD,_v$2=theme().text
|
|
229
|
+
_v$!==_p$.e&&(_p$.e=_$setProp4(_el$,"attributes",_v$,_p$.e))
|
|
230
|
+
_v$2!==_p$.t&&(_p$.t=_$setProp4(_el$,"fg",_v$2,_p$.t))
|
|
231
|
+
return _p$
|
|
232
|
+
},{e:undefined,t:undefined
|
|
233
|
+
})
|
|
234
|
+
return _el$
|
|
235
|
+
})(),(()=>{var _el$3=_$createElement5("scrollbox")
|
|
236
|
+
_$use((node)=>{body=node
|
|
237
|
+
},_el$3)
|
|
238
|
+
_$setProp4(_el$3,"id","opencode-navigator.keyboard-help.body")
|
|
239
|
+
_$setProp4(_el$3,"scrollX",false)
|
|
240
|
+
_$insert5(_el$3,_$createComponent6(Index,{get each(){return hints()
|
|
241
|
+
},children:(hint)=>(()=>{var _el$7=_$createElement5("text")
|
|
242
|
+
_$setProp4(_el$7,"wrapMode","word")
|
|
243
|
+
_$insert5(_el$7,hint)
|
|
244
|
+
_$effect4((_$p)=>_$setProp4(_el$7,"fg",theme().textMuted,_$p))
|
|
245
|
+
return _el$7
|
|
246
|
+
})()
|
|
247
|
+
}))
|
|
248
|
+
_$effect4((_$p)=>_$setProp4(_el$3,"height",Math.max(1,Math.min(16,dimensions().height-13)),_$p))
|
|
249
|
+
return _el$3
|
|
250
|
+
})(),(()=>{var _el$4=_$createElement5("text"),_el$5=_$createTextNode2(` scroll \xB7 `),_el$6=_$createTextNode2(` close`)
|
|
251
|
+
_$insertNode4(_el$4,_el$5)
|
|
252
|
+
_$insertNode4(_el$4,_el$6)
|
|
253
|
+
_$insert5(_el$4,()=>icons.key("up/down"),_el$5)
|
|
254
|
+
_$insert5(_el$4,()=>icons.key("esc"),_el$6)
|
|
255
|
+
_$effect4((_$p)=>_$setProp4(_el$4,"fg",theme().textMuted,_$p))
|
|
256
|
+
return _el$4
|
|
257
|
+
})()]
|
|
258
|
+
}})
|
|
259
|
+
}
|
|
260
|
+
export{KeyboardHelpDialog2 as KeyboardHelpDialog,SidebarShortcutHint2 as default
|
|
261
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import"./chunk-dz8cfnfs.js"
|
|
2
|
+
import"./chunk-v6bz59xn.js";
|
|
3
|
+
import {createComponent as _$createComponent4} from "@opentui/solid"
|
|
4
|
+
import {mergeProps as _$mergeProps} from "@opentui/solid"
|
|
5
|
+
import {memo as _$memo3} from "@opentui/solid"
|
|
6
|
+
import {createSignal} from "solid-js"
|
|
7
|
+
function toolbarPinKey(pin){return pin.kind==="action"?`action:${pin.id}`:`skill:${pin.location}`
|
|
8
|
+
}
|
|
9
|
+
import {createDialogStack} from "./tui.js"
|
|
10
|
+
import {createComponent as _$createComponent2} from "@opentui/solid"
|
|
11
|
+
import {createEffect,onCleanup,untrack} from "solid-js"
|
|
12
|
+
import {QUICK_ACTIONS as QUICK_ACTIONS2,quickActionLabel as quickActionLabel2} from "./tui.js"
|
|
13
|
+
import {SelectionMenu as SelectionMenu2,useDialogs} from "./tui.js"
|
|
14
|
+
import {memo as _$memo} from "@opentui/solid"
|
|
15
|
+
import {createComponent as _$createComponent} from "@opentui/solid"
|
|
16
|
+
import {QUICK_ACTIONS,quickActionDisabledReason,quickActionLabel} from "./tui.js"
|
|
17
|
+
import {SelectionMenu} from "./tui.js"
|
|
18
|
+
function openToolbarSources(input,kind){if(kind==="action"){input.dialogs.open(()=>_$createComponent(SelectionMenu,{get api(){return input.api
|
|
19
|
+
},title:"Pin Quick Action",height:18,get options(){return QUICK_ACTIONS.map((action)=>({title:quickActionLabel(input.api,action),value:action.command,description:quickActionDisabledReason(input.api,action)??"Choose icons before pinning"
|
|
20
|
+
}))
|
|
21
|
+
},onSelect:(option)=>openToolbarPin({...input,pin:{kind:"action",id:option.value,icon:"bolt"
|
|
22
|
+
}})
|
|
23
|
+
}))
|
|
24
|
+
return
|
|
25
|
+
}
|
|
26
|
+
if(!input.skills)
|
|
27
|
+
return
|
|
28
|
+
const target=input.skills.target()
|
|
29
|
+
input.dialogs.prompt({title:"Find a Skill to pin",placeholder:"Name or description",value:"",onConfirm(query){const list=input.skills.list(target).filter((skill)=>`${skill.name} ${skill.description ?? ""}`.toLowerCase().includes(query.toLowerCase()))
|
|
30
|
+
input.dialogs.open(()=>_$createComponent(SelectionMenu,{get api(){return input.api
|
|
31
|
+
},title:"Pin Skill",height:18,get options(){return _$memo(()=>list.length>0)()?list.map((skill,index)=>({title:skill.name,value:String(index),description:skill.location||"Unavailable: host provides no source location"
|
|
32
|
+
})):[{title:"No matching Skills",value:"empty",description:input.skills.error(target)??"Try another query"
|
|
33
|
+
}]
|
|
34
|
+
},onSelect:(option)=>{const skill=list[Number(option.value)]
|
|
35
|
+
if(!skill?.location||input.skills.target().key!==target.key)
|
|
36
|
+
return
|
|
37
|
+
openToolbarPin({...input,pin:{kind:"skill",location:skill.location,name:skill.name,icon:"book"
|
|
38
|
+
}})
|
|
39
|
+
}}))
|
|
40
|
+
}})
|
|
41
|
+
}
|
|
42
|
+
function ToolbarManager(props){const dialogs=useDialogs(props.api)
|
|
43
|
+
createEffect(()=>{const current=props.skills?.target()
|
|
44
|
+
if(!current||!props.skills)
|
|
45
|
+
return
|
|
46
|
+
const release=untrack(()=>props.skills.activate(current))
|
|
47
|
+
onCleanup(release)
|
|
48
|
+
untrack(()=>{props.skills.refresh(current).catch(()=>{})
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
function move(key,direction){const pins=props.preferences.toolbarPins()
|
|
52
|
+
const index=pins.findIndex((pin)=>toolbarPinKey(pin)===key)
|
|
53
|
+
const destination=index + direction
|
|
54
|
+
if(destination<0||destination>=pins.length)
|
|
55
|
+
return
|
|
56
|
+
props.preferences.changeToolbarPin({operation:"move",key,before:toolbarPinKey(pins[direction<0?destination:destination + 1]??pins[index])
|
|
57
|
+
})
|
|
58
|
+
dialogs.back()
|
|
59
|
+
}
|
|
60
|
+
return _$createComponent2(SelectionMenu2,{adaptive:true,get api(){return props.api
|
|
61
|
+
},title:"Pinned toolbar",height:18,get options(){return [{title:"Add Quick Action\u2026",value:"action",description:"Choose an action and its icons",icon:"add"
|
|
62
|
+
},{title:"Add Skill\u2026",value:"skill",description:props.skills?.error()??"Search the full workspace skill list",icon:"skills"
|
|
63
|
+
},...props.preferences.toolbarPins().map((pin,index)=>({title:`${index + 1}. ${pin.kind === "skill" ? pin.name : quickActionLabel2(props.api, QUICK_ACTIONS2.find((item) => item.command === pin.id))}`,value:toolbarPinKey(pin),description:pin.kind==="skill"?pin.location:"Quick Action",icon:"edit"
|
|
64
|
+
})),{title:"Back",value:"back",description:"Return to the previous screen",icon:"close"
|
|
65
|
+
}]
|
|
66
|
+
},onSelect:(option)=>{if(option.value==="action"||option.value==="skill"){openToolbarSources({...props,dialogs
|
|
67
|
+
},option.value)
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
const pin=props.preferences.toolbarPins().find((item)=>toolbarPinKey(item)===option.value)
|
|
71
|
+
if(!pin){dialogs.back()
|
|
72
|
+
return
|
|
73
|
+
}
|
|
74
|
+
dialogs.open(()=>_$createComponent2(SelectionMenu2,{get api(){return props.api
|
|
75
|
+
},title:"Toolbar button",options:[{title:"Configure icons\u2026",value:"configure",description:"Base and available state icons",icon:"edit"
|
|
76
|
+
},{title:"Move up",value:"up",description:"Earlier in the toolbar",icon:"selected"
|
|
77
|
+
},{title:"Move down",value:"down",description:"Later in the toolbar",icon:"selected"
|
|
78
|
+
},{title:"Unpin",value:"remove",description:"Keep the original bookmark unchanged",icon:"delete"
|
|
79
|
+
},{title:"Cancel",value:"cancel",description:"Return",icon:"close"
|
|
80
|
+
}],onSelect:(action)=>{if(action.value==="configure")
|
|
81
|
+
openToolbarPin({...props,dialogs,pin
|
|
82
|
+
})
|
|
83
|
+
else if(action.value==="up"||action.value==="down")
|
|
84
|
+
move(option.value,action.value==="up"?-1:1)
|
|
85
|
+
else{if(action.value==="remove")
|
|
86
|
+
props.preferences.changeToolbarPin({operation:"remove",key:option.value
|
|
87
|
+
})
|
|
88
|
+
dialogs.back()
|
|
89
|
+
}}}))
|
|
90
|
+
}})
|
|
91
|
+
}
|
|
92
|
+
import {createComponent as _$createComponent3} from "@opentui/solid"
|
|
93
|
+
import {memo as _$memo2} from "@opentui/solid"
|
|
94
|
+
import {quickActionStates} from "./tui.js"
|
|
95
|
+
import {IconPicker,SelectionMenu as SelectionMenu3,terminalIcon,useDialogState,useDialogs as useDialogs2,useIcons} from "./tui.js"
|
|
96
|
+
function ToolbarPinDialog(props){const dialogs=useDialogs2(props.api)
|
|
97
|
+
const icons=useIcons()
|
|
98
|
+
const [icon,setIcon]=useDialogState("pin-icon",props.pin.icon)
|
|
99
|
+
const [states,setStates]=useDialogState("pin-states",{...props.pin.stateIcons
|
|
100
|
+
})
|
|
101
|
+
const [sourceRoute]=useDialogState("pin-route",JSON.stringify(props.api.route.current))
|
|
102
|
+
const [sourceTarget]=useDialogState("pin-target",props.skills?.target().key)
|
|
103
|
+
const existing=()=>props.preferences.toolbarPins().find((pin)=>toolbarPinKey(pin)===toolbarPinKey(props.pin))
|
|
104
|
+
function choose(state){dialogs.open(()=>_$createComponent3(IconPicker,{get api(){return props.api
|
|
105
|
+
},get value(){return state?states()[state]??icon():icon()
|
|
106
|
+
},onSelect:(id)=>{if(state)
|
|
107
|
+
setStates((value)=>({...value,[state]:id
|
|
108
|
+
}))
|
|
109
|
+
else
|
|
110
|
+
setIcon(id)
|
|
111
|
+
dialogs.back()
|
|
112
|
+
}}),"large")
|
|
113
|
+
}
|
|
114
|
+
function save(){try{if(sourceRoute()!==JSON.stringify(props.api.route.current)||sourceTarget()!==props.skills?.target().key)
|
|
115
|
+
throw new Error("Workspace or session changed; reopen pin configuration")
|
|
116
|
+
const source=props.pin.kind==="skill"?props.pin.location:undefined
|
|
117
|
+
if(!props.expected&&source&&!props.skills?.list().some((skill)=>skill.location===source))
|
|
118
|
+
throw new Error("Skill source changed; choose it again")
|
|
119
|
+
const pin={...props.pin,icon:icon(),stateIcons:states()
|
|
120
|
+
}
|
|
121
|
+
props.preferences.changeToolbarPin(props.expected?{operation:"configure",key:toolbarPinKey(pin),icon:pin.icon,stateIcons:pin.stateIcons,expected:props.expected
|
|
122
|
+
}:{operation:"pin",pin
|
|
123
|
+
})
|
|
124
|
+
dialogs.back()
|
|
125
|
+
} catch(error){props.api.ui.toast({variant:"error",title:"Toolbar",message:String(error)
|
|
126
|
+
})
|
|
127
|
+
}}
|
|
128
|
+
return _$createComponent3(SelectionMenu3,{adaptive:true,get api(){return props.api
|
|
129
|
+
},get title(){return _$memo2(()=>props.pin.kind==="skill")()?`Pin Skill \xB7 ${props.pin.name}`:"Pin Quick Action"
|
|
130
|
+
},height:16,get options(){return [{title:`${terminalIcon(icon(), icons.style())} Base icon`,value:"base",description:"Used when the state is unavailable or has no custom icon",icon:"edit"
|
|
131
|
+
},...props.pin.kind==="action"?quickActionStates(props.api,props.pin.id).map((state)=>({title:`${terminalIcon(states()[state.id] ?? icon(), icons.style())} ${state.label}`,value:`state:${state.id}`,description:states()[state.id]?"Custom state icon":"Uses base icon",icon:"edit"
|
|
132
|
+
})):[],{title:props.expected?"Save":"Pin to toolbar",value:"save",description:"Save this draft",icon:"save"
|
|
133
|
+
},...existing()?[{title:"Unpin",value:"unpin",description:"Remove only this toolbar button",icon:"delete"
|
|
134
|
+
}]:[],{title:"Cancel",value:"cancel",description:"Discard this draft",icon:"close"
|
|
135
|
+
}]
|
|
136
|
+
},onSelect:(option)=>{if(option.value==="base")
|
|
137
|
+
choose()
|
|
138
|
+
else if(option.value.startsWith("state:"))
|
|
139
|
+
choose(option.value.slice(6))
|
|
140
|
+
else if(option.value==="save")
|
|
141
|
+
save()
|
|
142
|
+
else if(option.value==="unpin"){props.preferences.changeToolbarPin({operation:"remove",key:toolbarPinKey(props.pin)
|
|
143
|
+
})
|
|
144
|
+
dialogs.back()
|
|
145
|
+
} else
|
|
146
|
+
dialogs.back()
|
|
147
|
+
}})
|
|
148
|
+
}
|
|
149
|
+
function navigation(input){const route=JSON.stringify(input.api.route.current)
|
|
150
|
+
return input.dialogs??createDialogStack(input.api,input.preferences.lspIconStyle,()=>route===JSON.stringify(input.api.route.current),input.preferences.cornerFont)
|
|
151
|
+
}
|
|
152
|
+
function openToolbarPin(input){const dialogs=navigation(input)
|
|
153
|
+
const current=input.preferences.toolbarPins().find((pin)=>toolbarPinKey(pin)===toolbarPinKey(input.pin))
|
|
154
|
+
dialogs.open(()=>_$createComponent4(ToolbarPinDialog,_$mergeProps(input,{get pin(){return current??input.pin
|
|
155
|
+
},get expected(){return current&&JSON.stringify(current)
|
|
156
|
+
}})),"large")
|
|
157
|
+
}
|
|
158
|
+
function openToolbarManager(input){navigation(input).open(()=>_$createComponent4(ToolbarManager,input),"large")
|
|
159
|
+
}
|
|
160
|
+
export{openToolbarManager,openToolbarPin
|
|
161
|
+
}
|