@neurocode-ai/tui 1.18.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/bunfig.toml +4 -0
  2. package/package.json +72 -0
  3. package/src/app.tsx +1134 -0
  4. package/src/attention.ts +260 -0
  5. package/src/audio.d.ts +9 -0
  6. package/src/audio.ts +53 -0
  7. package/src/clipboard.ts +124 -0
  8. package/src/component/bg-pulse-render.ts +436 -0
  9. package/src/component/bg-pulse.tsx +99 -0
  10. package/src/component/command-palette.tsx +79 -0
  11. package/src/component/dialog-agent.tsx +31 -0
  12. package/src/component/dialog-console-org.tsx +135 -0
  13. package/src/component/dialog-debug.tsx +90 -0
  14. package/src/component/dialog-mcp.tsx +85 -0
  15. package/src/component/dialog-model.tsx +197 -0
  16. package/src/component/dialog-move-session.tsx +353 -0
  17. package/src/component/dialog-provider.tsx +469 -0
  18. package/src/component/dialog-retry-action.tsx +160 -0
  19. package/src/component/dialog-session-delete-failed.tsx +99 -0
  20. package/src/component/dialog-session-list.tsx +364 -0
  21. package/src/component/dialog-session-rename.tsx +31 -0
  22. package/src/component/dialog-skill.tsx +70 -0
  23. package/src/component/dialog-stash.tsx +87 -0
  24. package/src/component/dialog-status.tsx +168 -0
  25. package/src/component/dialog-tag.tsx +47 -0
  26. package/src/component/dialog-theme-list.tsx +50 -0
  27. package/src/component/dialog-variant.tsx +39 -0
  28. package/src/component/dialog-workspace-create.tsx +308 -0
  29. package/src/component/dialog-workspace-file-changes.tsx +144 -0
  30. package/src/component/dialog-workspace-list.tsx +112 -0
  31. package/src/component/dialog-workspace-unavailable.tsx +69 -0
  32. package/src/component/error-component.tsx +240 -0
  33. package/src/component/logo.tsx +61 -0
  34. package/src/component/plugin-route-missing.tsx +14 -0
  35. package/src/component/prompt/autocomplete.tsx +781 -0
  36. package/src/component/prompt/cwd.ts +0 -0
  37. package/src/component/prompt/frecency.tsx +1 -0
  38. package/src/component/prompt/history.tsx +1 -0
  39. package/src/component/prompt/index.tsx +1713 -0
  40. package/src/component/prompt/local-attachment.ts +48 -0
  41. package/src/component/prompt/move.tsx +205 -0
  42. package/src/component/prompt/stash.tsx +1 -0
  43. package/src/component/prompt/workspace.tsx +137 -0
  44. package/src/component/register-spinner.ts +6 -0
  45. package/src/component/spinner.tsx +26 -0
  46. package/src/component/startup-loading.tsx +63 -0
  47. package/src/component/todo-item.tsx +32 -0
  48. package/src/component/use-connected.tsx +12 -0
  49. package/src/component/workspace-label.tsx +19 -0
  50. package/src/config/index.tsx +129 -0
  51. package/src/config/keybind.ts +471 -0
  52. package/src/context/args.tsx +16 -0
  53. package/src/context/clipboard.tsx +18 -0
  54. package/src/context/data.tsx +569 -0
  55. package/src/context/directory.ts +17 -0
  56. package/src/context/editor.ts +408 -0
  57. package/src/context/epilogue.tsx +6 -0
  58. package/src/context/event.ts +36 -0
  59. package/src/context/exit.tsx +8 -0
  60. package/src/context/helper.tsx +26 -0
  61. package/src/context/kv.tsx +66 -0
  62. package/src/context/local.tsx +542 -0
  63. package/src/context/location.tsx +14 -0
  64. package/src/context/path-format.tsx +24 -0
  65. package/src/context/permission.tsx +26 -0
  66. package/src/context/project.tsx +115 -0
  67. package/src/context/prompt.tsx +18 -0
  68. package/src/context/route.tsx +60 -0
  69. package/src/context/runtime.tsx +62 -0
  70. package/src/context/sdk.tsx +151 -0
  71. package/src/context/sync.tsx +666 -0
  72. package/src/context/theme.tsx +332 -0
  73. package/src/context/thinking.ts +67 -0
  74. package/src/editor-zed.ts +286 -0
  75. package/src/editor.ts +101 -0
  76. package/src/feature-plugins/builtins.ts +36 -0
  77. package/src/feature-plugins/home/footer.tsx +100 -0
  78. package/src/feature-plugins/home/tips-view.tsx +287 -0
  79. package/src/feature-plugins/home/tips.tsx +59 -0
  80. package/src/feature-plugins/sidebar/context.tsx +65 -0
  81. package/src/feature-plugins/sidebar/files.tsx +70 -0
  82. package/src/feature-plugins/sidebar/footer.tsx +98 -0
  83. package/src/feature-plugins/sidebar/lsp.tsx +65 -0
  84. package/src/feature-plugins/sidebar/mcp.tsx +97 -0
  85. package/src/feature-plugins/sidebar/todo.tsx +49 -0
  86. package/src/feature-plugins/system/diff-viewer-file-tree-utils.ts +232 -0
  87. package/src/feature-plugins/system/diff-viewer-file-tree.tsx +162 -0
  88. package/src/feature-plugins/system/diff-viewer-ui.tsx +103 -0
  89. package/src/feature-plugins/system/diff-viewer.tsx +1077 -0
  90. package/src/feature-plugins/system/notifications.ts +94 -0
  91. package/src/feature-plugins/system/plugins.tsx +269 -0
  92. package/src/feature-plugins/system/which-key.tsx +608 -0
  93. package/src/index.tsx +1 -0
  94. package/src/keymap.tsx +290 -0
  95. package/src/logo.ts +11 -0
  96. package/src/parsers-config.ts +386 -0
  97. package/src/plugin/adapters.tsx +355 -0
  98. package/src/plugin/api.ts +52 -0
  99. package/src/plugin/command-shim.ts +109 -0
  100. package/src/plugin/runtime.tsx +81 -0
  101. package/src/plugin/slots.tsx +65 -0
  102. package/src/prompt/display.ts +48 -0
  103. package/src/prompt/frecency.tsx +80 -0
  104. package/src/prompt/history.tsx +111 -0
  105. package/src/prompt/part.ts +29 -0
  106. package/src/prompt/stash.tsx +89 -0
  107. package/src/prompt/traits.ts +29 -0
  108. package/src/routes/home/session-destination.tsx +41 -0
  109. package/src/routes/home.tsx +95 -0
  110. package/src/routes/session/dialog-fork-from-timeline.tsx +76 -0
  111. package/src/routes/session/dialog-message.tsx +109 -0
  112. package/src/routes/session/dialog-subagent.tsx +26 -0
  113. package/src/routes/session/dialog-timeline.tsx +47 -0
  114. package/src/routes/session/footer.tsx +91 -0
  115. package/src/routes/session/index.tsx +2710 -0
  116. package/src/routes/session/permission.tsx +718 -0
  117. package/src/routes/session/question.tsx +514 -0
  118. package/src/routes/session/sidebar.tsx +103 -0
  119. package/src/routes/session/subagent-footer.tsx +132 -0
  120. package/src/runtime.tsx +9 -0
  121. package/src/terminal-win32.ts +130 -0
  122. package/src/theme/assets/aura.json +69 -0
  123. package/src/theme/assets/ayu.json +80 -0
  124. package/src/theme/assets/carbonfox.json +248 -0
  125. package/src/theme/assets/catppuccin-frappe.json +230 -0
  126. package/src/theme/assets/catppuccin-macchiato.json +230 -0
  127. package/src/theme/assets/catppuccin.json +112 -0
  128. package/src/theme/assets/cobalt2.json +225 -0
  129. package/src/theme/assets/cursor.json +249 -0
  130. package/src/theme/assets/dracula.json +219 -0
  131. package/src/theme/assets/everforest.json +241 -0
  132. package/src/theme/assets/flexoki.json +237 -0
  133. package/src/theme/assets/github.json +233 -0
  134. package/src/theme/assets/gruvbox.json +242 -0
  135. package/src/theme/assets/kanagawa.json +77 -0
  136. package/src/theme/assets/lucent-orng.json +234 -0
  137. package/src/theme/assets/material.json +235 -0
  138. package/src/theme/assets/matrix.json +77 -0
  139. package/src/theme/assets/mercury.json +252 -0
  140. package/src/theme/assets/monokai.json +221 -0
  141. package/src/theme/assets/nightowl.json +221 -0
  142. package/src/theme/assets/nord.json +223 -0
  143. package/src/theme/assets/one-dark.json +84 -0
  144. package/src/theme/assets/opencode.json +245 -0
  145. package/src/theme/assets/orng.json +249 -0
  146. package/src/theme/assets/osaka-jade.json +93 -0
  147. package/src/theme/assets/palenight.json +222 -0
  148. package/src/theme/assets/rosepine.json +234 -0
  149. package/src/theme/assets/solarized.json +223 -0
  150. package/src/theme/assets/synthwave84.json +226 -0
  151. package/src/theme/assets/tokyonight.json +243 -0
  152. package/src/theme/assets/vercel.json +245 -0
  153. package/src/theme/assets/vesper.json +218 -0
  154. package/src/theme/assets/zenburn.json +223 -0
  155. package/src/theme/index.ts +1089 -0
  156. package/src/ui/border.ts +21 -0
  157. package/src/ui/dialog-alert.tsx +66 -0
  158. package/src/ui/dialog-confirm.tsx +108 -0
  159. package/src/ui/dialog-export-options.tsx +217 -0
  160. package/src/ui/dialog-help.tsx +40 -0
  161. package/src/ui/dialog-prompt.tsx +126 -0
  162. package/src/ui/dialog-select.tsx +790 -0
  163. package/src/ui/dialog.tsx +231 -0
  164. package/src/ui/link.tsx +34 -0
  165. package/src/ui/spinner.ts +368 -0
  166. package/src/ui/toast.tsx +102 -0
  167. package/src/util/collapse-tool-output.ts +19 -0
  168. package/src/util/error.ts +182 -0
  169. package/src/util/filetype.ts +130 -0
  170. package/src/util/format.ts +20 -0
  171. package/src/util/layout.ts +25 -0
  172. package/src/util/locale.ts +86 -0
  173. package/src/util/model.ts +28 -0
  174. package/src/util/path.ts +12 -0
  175. package/src/util/persistence.ts +33 -0
  176. package/src/util/presentation.ts +38 -0
  177. package/src/util/provider-origin.ts +7 -0
  178. package/src/util/record.ts +3 -0
  179. package/src/util/renderer.ts +7 -0
  180. package/src/util/revert-diff.ts +18 -0
  181. package/src/util/scroll.ts +27 -0
  182. package/src/util/selection.ts +79 -0
  183. package/src/util/session.ts +3 -0
  184. package/src/util/signal.ts +51 -0
  185. package/src/util/system.ts +20 -0
  186. package/src/util/tool-display.ts +13 -0
  187. package/src/util/transcript.ts +112 -0
  188. package/sst-env.d.ts +10 -0
  189. package/test/app-lifecycle.test.tsx +128 -0
  190. package/test/cli/cmd/tui/dialog-workspace-create.test.ts +28 -0
  191. package/test/cli/cmd/tui/model-options.test.ts +32 -0
  192. package/test/cli/cmd/tui/notifications.test.ts +267 -0
  193. package/test/cli/cmd/tui/provider-options.test.ts +41 -0
  194. package/test/cli/cmd/tui/sync-fixture.tsx +70 -0
  195. package/test/cli/cmd/tui/sync-live-hydration.test.tsx +262 -0
  196. package/test/cli/cmd/tui/sync-undefined-messages.test.tsx +43 -0
  197. package/test/cli/cmd/tui/sync.test.tsx +65 -0
  198. package/test/cli/tui/__snapshots__/inline-tool-wrap-snapshot.test.tsx.snap +92 -0
  199. package/test/cli/tui/data.test.tsx +486 -0
  200. package/test/cli/tui/dialog-prompt.test.tsx +147 -0
  201. package/test/cli/tui/diff-viewer-file-tree.test.tsx +200 -0
  202. package/test/cli/tui/diff-viewer.test.tsx +268 -0
  203. package/test/cli/tui/inline-tool-wrap-snapshot.test.tsx +351 -0
  204. package/test/cli/tui/prompt-submit-race.test.ts +98 -0
  205. package/test/cli/tui/thinking.test.ts +36 -0
  206. package/test/cli/tui/use-event.test.tsx +148 -0
  207. package/test/clipboard.test.ts +19 -0
  208. package/test/component/dialog-session-list.test.ts +46 -0
  209. package/test/config.test.tsx +127 -0
  210. package/test/context/local.test.ts +22 -0
  211. package/test/editor.test.ts +32 -0
  212. package/test/feature-plugins/diff-viewer-file-tree-utils.test.ts +323 -0
  213. package/test/fixture/fixture.ts +13 -0
  214. package/test/fixture/tui-environment.tsx +32 -0
  215. package/test/fixture/tui-plugin.ts +36 -0
  216. package/test/fixture/tui-runtime.ts +12 -0
  217. package/test/fixture/tui-sdk.ts +109 -0
  218. package/test/index.test.tsx +6 -0
  219. package/test/keymap.test.tsx +141 -0
  220. package/test/plugin/runtime.test.ts +50 -0
  221. package/test/plugin/slots.test.tsx +38 -0
  222. package/test/prompt/display.test.ts +33 -0
  223. package/test/prompt/history.test.ts +39 -0
  224. package/test/prompt/jsonl.test.ts +24 -0
  225. package/test/prompt/local-attachment.test.ts +43 -0
  226. package/test/prompt/part.test.ts +53 -0
  227. package/test/prompt/persistence.test.ts +23 -0
  228. package/test/prompt/traits.test.ts +25 -0
  229. package/test/runtime.test.tsx +37 -0
  230. package/test/theme.test.ts +81 -0
  231. package/test/util/error.test.ts +49 -0
  232. package/test/util/filetype.test.ts +16 -0
  233. package/test/util/format.test.ts +59 -0
  234. package/test/util/model.test.ts +9 -0
  235. package/test/util/presentation.test.ts +8 -0
  236. package/test/util/renderer.test.ts +30 -0
  237. package/test/util/revert-diff.test.ts +35 -0
  238. package/test/util/session.test.ts +10 -0
  239. package/test/util/tool-display.test.ts +40 -0
  240. package/test/util/transcript.test.ts +421 -0
  241. package/tsconfig.json +10 -0
@@ -0,0 +1,94 @@
1
+ import type { Event } from "@neurocode-ai/sdk/v2"
2
+ import type { TuiAttentionSoundName, TuiPlugin, TuiPluginApi } from "@neurocode-ai/plugin/tui"
3
+ import type { BuiltinTuiPlugin } from "../builtins"
4
+
5
+ const id = "internal:notifications"
6
+
7
+ type SessionError = Extract<Event, { type: "session.error" }>["properties"]["error"]
8
+
9
+ function notify(api: TuiPluginApi, sessionID: string | undefined, message: string, sound: TuiAttentionSoundName) {
10
+ const session = sessionID ? api.state.session.get(sessionID) : undefined
11
+ const isSubagent = session?.parentID !== undefined
12
+ void api.attention.notify({
13
+ title: session?.title,
14
+ message,
15
+ notification: isSubagent ? false : { when: "blurred" },
16
+ sound: { name: sound, when: "always" },
17
+ })
18
+ }
19
+
20
+ function sessionErrorMessage(error: SessionError) {
21
+ if (error?.name === "MessageAbortedError") return "Session aborted"
22
+ const data = error?.data
23
+ if (data && typeof data === "object" && "message" in data && data.message === "SSE read timed out") {
24
+ return "Model stopped responding"
25
+ }
26
+ return "Session error"
27
+ }
28
+
29
+ const tui: TuiPlugin = async (api) => {
30
+ const active = new Set<string>()
31
+ const errored = new Set<string>()
32
+ const questions = new Set<string>()
33
+ const permissions = new Set<string>()
34
+
35
+ api.event.on("question.asked", (event) => {
36
+ if (questions.has(event.properties.id)) return
37
+ questions.add(event.properties.id)
38
+ notify(api, event.properties.sessionID, "Question needs input", "question")
39
+ })
40
+
41
+ api.event.on("question.replied", (event) => {
42
+ questions.delete(event.properties.requestID)
43
+ })
44
+
45
+ api.event.on("question.rejected", (event) => {
46
+ questions.delete(event.properties.requestID)
47
+ })
48
+
49
+ api.event.on("permission.asked", (event) => {
50
+ if (permissions.has(event.properties.id)) return
51
+ permissions.add(event.properties.id)
52
+ notify(api, event.properties.sessionID, "Permission needs input", "permission")
53
+ })
54
+
55
+ api.event.on("permission.replied", (event) => {
56
+ permissions.delete(event.properties.requestID)
57
+ })
58
+
59
+ api.event.on("session.status", (event) => {
60
+ const sessionID = event.properties.sessionID
61
+ if (event.properties.status.type === "busy" || event.properties.status.type === "retry") {
62
+ active.add(sessionID)
63
+ errored.delete(sessionID)
64
+ return
65
+ }
66
+
67
+ if (event.properties.status.type !== "idle") return
68
+ if (!active.has(sessionID)) return
69
+ active.delete(sessionID)
70
+
71
+ if (errored.has(sessionID)) {
72
+ errored.delete(sessionID)
73
+ return
74
+ }
75
+
76
+ const session = api.state.session.get(sessionID)
77
+ notify(api, sessionID, "Session done", session?.parentID ? "subagent_done" : "done")
78
+ })
79
+
80
+ api.event.on("session.error", (event) => {
81
+ const sessionID = event.properties.sessionID
82
+ if (!sessionID) return
83
+ if (!active.has(sessionID)) return
84
+ errored.add(sessionID)
85
+ notify(api, sessionID, sessionErrorMessage(event.properties.error), "error")
86
+ })
87
+ }
88
+
89
+ const plugin: BuiltinTuiPlugin = {
90
+ id,
91
+ tui,
92
+ }
93
+
94
+ export default plugin
@@ -0,0 +1,269 @@
1
+ import type { TuiPlugin, TuiPluginApi, TuiPluginStatus } from "@neurocode-ai/plugin/tui"
2
+ import type { BuiltinTuiPlugin } from "../builtins"
3
+ import { useTerminalDimensions } from "@opentui/solid"
4
+ import { fileURLToPath } from "url"
5
+ import { DialogSelect, type DialogSelectOption } from "../../ui/dialog-select"
6
+ import { Show, createEffect, createMemo, createSignal } from "solid-js"
7
+ import { useBindings } from "../../keymap"
8
+
9
+ const id = "internal:plugin-manager"
10
+
11
+ function state(api: TuiPluginApi, item: TuiPluginStatus) {
12
+ if (!item.enabled) {
13
+ return <span style={{ fg: api.theme.current.textMuted }}>disabled</span>
14
+ }
15
+
16
+ return (
17
+ <span style={{ fg: item.active ? api.theme.current.success : api.theme.current.error }}>
18
+ {item.active ? "active" : "inactive"}
19
+ </span>
20
+ )
21
+ }
22
+
23
+ function source(spec: string) {
24
+ if (!spec.startsWith("file://")) return
25
+ return fileURLToPath(spec)
26
+ }
27
+
28
+ function meta(item: TuiPluginStatus, width: number) {
29
+ if (item.source === "internal") {
30
+ if (width >= 120) return "Built-in plugin"
31
+ return "Built-in"
32
+ }
33
+ const next = source(item.spec)
34
+ if (next) return next
35
+ return item.spec
36
+ }
37
+
38
+ function Install(props: { api: TuiPluginApi }) {
39
+ const [global, setGlobal] = createSignal(false)
40
+ const [busy, setBusy] = createSignal(false)
41
+
42
+ useBindings(() => ({
43
+ enabled: !busy(),
44
+ bindings: [{ key: "tab", desc: "Toggle install scope", group: "Plugins", cmd: () => setGlobal((value) => !value) }],
45
+ }))
46
+
47
+ return (
48
+ <props.api.ui.DialogPrompt
49
+ title="Install plugin"
50
+ placeholder="npm package name"
51
+ busy={busy()}
52
+ busyText="Installing plugin..."
53
+ description={() => (
54
+ <box flexDirection="row" gap={1}>
55
+ <text fg={props.api.theme.current.textMuted}>scope:</text>
56
+ <text fg={busy() ? props.api.theme.current.textMuted : props.api.theme.current.text}>
57
+ {global() ? "global" : "local"}
58
+ </text>
59
+ <Show when={!busy()}>
60
+ <text fg={props.api.theme.current.textMuted}>(tab toggle)</text>
61
+ </Show>
62
+ </box>
63
+ )}
64
+ onConfirm={(raw) => {
65
+ if (busy()) return
66
+ const mod = raw.trim()
67
+ if (!mod) {
68
+ props.api.ui.toast({
69
+ variant: "error",
70
+ message: "Plugin package name is required",
71
+ })
72
+ return
73
+ }
74
+
75
+ setBusy(true)
76
+ void props.api.plugins
77
+ .install(mod, { global: global() })
78
+ .then((out) => {
79
+ if (!out.ok) {
80
+ props.api.ui.toast({
81
+ variant: "error",
82
+ message: out.message,
83
+ })
84
+ if (out.missing) {
85
+ props.api.ui.toast({
86
+ variant: "info",
87
+ message: "Check npm registry/auth settings and try again.",
88
+ })
89
+ }
90
+ show(props.api)
91
+ return
92
+ }
93
+
94
+ props.api.ui.toast({
95
+ variant: "success",
96
+ message: `Installed ${mod} (${global() ? "global" : "local"}: ${out.dir})`,
97
+ })
98
+ if (!out.tui) {
99
+ props.api.ui.toast({
100
+ variant: "info",
101
+ message: "Package has no TUI target to load in this app.",
102
+ })
103
+ show(props.api)
104
+ return
105
+ }
106
+
107
+ return props.api.plugins.add(mod).then((ok) => {
108
+ if (!ok) {
109
+ props.api.ui.toast({
110
+ variant: "warning",
111
+ message: "Installed plugin, but runtime load failed. See console/logs; restart TUI to retry.",
112
+ })
113
+ show(props.api)
114
+ return
115
+ }
116
+
117
+ props.api.ui.toast({
118
+ variant: "success",
119
+ message: `Loaded ${mod} in current session.`,
120
+ })
121
+ show(props.api)
122
+ })
123
+ })
124
+ .finally(() => {
125
+ setBusy(false)
126
+ })
127
+ }}
128
+ onCancel={() => {
129
+ show(props.api)
130
+ }}
131
+ />
132
+ )
133
+ }
134
+
135
+ function row(api: TuiPluginApi, item: TuiPluginStatus, width: number): DialogSelectOption<string> {
136
+ return {
137
+ title: item.id,
138
+ value: item.id,
139
+ category: item.source === "internal" ? "Internal" : "External",
140
+ description: meta(item, width),
141
+ footer: state(api, item),
142
+ disabled: item.id === id,
143
+ }
144
+ }
145
+
146
+ function showInstall(api: TuiPluginApi) {
147
+ api.ui.dialog.replace(() => <Install api={api} />)
148
+ }
149
+
150
+ function View(props: { api: TuiPluginApi }) {
151
+ const size = useTerminalDimensions()
152
+ const [list, setList] = createSignal(props.api.plugins.list())
153
+ const [cur, setCur] = createSignal<string | undefined>()
154
+ const [lock, setLock] = createSignal(false)
155
+
156
+ createEffect(() => {
157
+ const width = size().width
158
+ if (width >= 128) {
159
+ props.api.ui.dialog.setSize("xlarge")
160
+ return
161
+ }
162
+ if (width >= 96) {
163
+ props.api.ui.dialog.setSize("large")
164
+ return
165
+ }
166
+ props.api.ui.dialog.setSize("medium")
167
+ })
168
+
169
+ const rows = createMemo(() =>
170
+ [...list()]
171
+ .sort((a, b) => {
172
+ const x = a.source === "internal" ? 1 : 0
173
+ const y = b.source === "internal" ? 1 : 0
174
+ if (x !== y) return x - y
175
+ return a.id.localeCompare(b.id)
176
+ })
177
+ .map((item) => row(props.api, item, size().width)),
178
+ )
179
+
180
+ const flip = (x: string) => {
181
+ if (lock()) return
182
+ const item = list().find((entry) => entry.id === x)
183
+ if (!item) return
184
+ setLock(true)
185
+ const task = item.active ? props.api.plugins.deactivate(x) : props.api.plugins.activate(x)
186
+ void task
187
+ .then((ok) => {
188
+ if (!ok) {
189
+ props.api.ui.toast({
190
+ variant: "error",
191
+ message: `Failed to update plugin ${item.id}`,
192
+ })
193
+ }
194
+ setList(props.api.plugins.list())
195
+ })
196
+ .finally(() => {
197
+ setLock(false)
198
+ })
199
+ }
200
+
201
+ return (
202
+ <DialogSelect
203
+ title="Plugins"
204
+ options={rows()}
205
+ current={cur()}
206
+ onMove={(item) => setCur(item.value)}
207
+ actions={[
208
+ {
209
+ title: "toggle",
210
+ command: "plugins.toggle",
211
+ hidden: lock(),
212
+ onTrigger: (item) => {
213
+ setCur(item.value)
214
+ flip(item.value)
215
+ },
216
+ },
217
+ {
218
+ title: "install",
219
+ command: "dialog.plugins.install",
220
+ hidden: lock(),
221
+ onTrigger: () => {
222
+ showInstall(props.api)
223
+ },
224
+ },
225
+ ]}
226
+ onSelect={(item) => {
227
+ setCur(item.value)
228
+ flip(item.value)
229
+ }}
230
+ />
231
+ )
232
+ }
233
+
234
+ function show(api: TuiPluginApi) {
235
+ api.ui.dialog.replace(() => <View api={api} />)
236
+ }
237
+
238
+ const tui: TuiPlugin = async (api) => {
239
+ api.keymap.registerLayer({
240
+ commands: [
241
+ {
242
+ name: "plugins.list",
243
+ title: "Plugins",
244
+ category: "System",
245
+ namespace: "palette",
246
+ run() {
247
+ show(api)
248
+ },
249
+ },
250
+ {
251
+ name: "plugins.install",
252
+ title: "Install plugin",
253
+ category: "System",
254
+ namespace: "palette",
255
+ run() {
256
+ showInstall(api)
257
+ },
258
+ },
259
+ ],
260
+ bindings: api.tuiConfig.keybinds.gather("plugins.palette", ["plugins.list", "plugins.install"]),
261
+ })
262
+ }
263
+
264
+ const plugin: BuiltinTuiPlugin = {
265
+ id,
266
+ tui,
267
+ }
268
+
269
+ export default plugin