@chatcode/cco-better-sidebar 0.18.0-alpha.4 → 0.18.0-rc.11

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 (83) hide show
  1. package/README.md +24 -5
  2. package/README_EN.md +24 -5
  3. package/cordis.patch.yml +6 -5
  4. package/lib/client-editor.js +10920 -363
  5. package/lib/client-mermaid.js +10806 -271
  6. package/lib/client-registry.js +3733 -2150
  7. package/lib/client-terminal.js +398 -257
  8. package/lib/client.js +3734 -2151
  9. package/lib/index.js +264 -46
  10. package/lib/types/client/LogoutConfirmDialog.d.ts +5 -0
  11. package/lib/types/client/PluginMarketSettingsSection.d.ts +7 -0
  12. package/lib/types/client/PluginMarketView.d.ts +7 -0
  13. package/lib/types/client/PluginProjectPicker.d.ts +13 -0
  14. package/lib/types/client/api.d.ts +17 -0
  15. package/lib/types/client/builtins/tabs.d.ts +13 -1
  16. package/lib/types/client/icons.d.ts +26 -8
  17. package/lib/types/client/locales.d.ts +39 -0
  18. package/lib/types/client/plugin-market-catalog.d.ts +25 -0
  19. package/lib/types/client/service.d.ts +1 -1
  20. package/lib/types/client/ui-tweaks/archive.d.ts +3 -7
  21. package/lib/types/client/ui-tweaks/branding.d.ts +1 -1
  22. package/lib/types/client/ui-tweaks/index.d.ts +3 -3
  23. package/lib/types/client/ui-tweaks/sidebar-header.d.ts +6 -0
  24. package/lib/types/client/ui-tweaks/typography.d.ts +9 -0
  25. package/lib/types/config.d.ts +4 -3
  26. package/lib/types/context-types.d.ts +12 -14
  27. package/lib/types/login-page-script.d.ts +2 -0
  28. package/lib/types/login-route.d.ts +2 -0
  29. package/lib/types/plugin-market-api.d.ts +5 -0
  30. package/lib/types/plugin-market-shared.d.ts +59 -0
  31. package/lib/types/prefs-shared.d.ts +1 -1
  32. package/lib/types/pty-deps.d.ts +1 -1
  33. package/lib/types/ui-tweaks/config.d.ts +6 -7
  34. package/lib/types/ui-tweaks/index.d.ts +2 -3
  35. package/package.json +2 -2
  36. package/src/client/AccountMenu.tsx +12 -2
  37. package/src/client/BrowserView.tsx +1 -1
  38. package/src/client/DiffTab.tsx +1 -1
  39. package/src/client/EditorHost.tsx +1 -1
  40. package/src/client/FileTree.tsx +10 -5
  41. package/src/client/FreeWindow.tsx +2 -1
  42. package/src/client/GitView.tsx +7 -3
  43. package/src/client/LogoutConfirmDialog.tsx +39 -0
  44. package/src/client/PluginMarketSettingsSection.tsx +55 -0
  45. package/src/client/PluginMarketView.module.css +50 -0
  46. package/src/client/PluginMarketView.tsx +243 -0
  47. package/src/client/PluginProjectPicker.tsx +73 -0
  48. package/src/client/SideCardSection.tsx +2 -23
  49. package/src/client/Sidebar.tsx +2 -2
  50. package/src/client/TabBar.tsx +2 -4
  51. package/src/client/TextEditor.tsx +2 -1
  52. package/src/client/TreePanel.tsx +1 -2
  53. package/src/client/UsageHeatmapSection.tsx +1 -1
  54. package/src/client/api.ts +9 -0
  55. package/src/client/builtins/tabs.tsx +25 -5
  56. package/src/client/builtins/viewers.tsx +2 -1
  57. package/src/client/icons.tsx +57 -4
  58. package/src/client/index.tsx +10 -1
  59. package/src/client/intercept.tsx +1 -1
  60. package/src/client/locales-ja.ts +39 -0
  61. package/src/client/locales.ts +118 -1
  62. package/src/client/md-toc.tsx +1 -1
  63. package/src/client/mermaid.tsx +2 -1
  64. package/src/client/open-with-settings.tsx +1 -1
  65. package/src/client/plugin-market-catalog.ts +90 -0
  66. package/src/client/service.ts +1 -1
  67. package/src/client/sidebar.module.css +81 -19
  68. package/src/client/ui-tweaks/archive.tsx +6 -56
  69. package/src/client/ui-tweaks/branding.tsx +36 -29
  70. package/src/client/ui-tweaks/index.tsx +42 -105
  71. package/src/client/ui-tweaks/sidebar-header.ts +73 -0
  72. package/src/client/ui-tweaks/typography.ts +38 -0
  73. package/src/config.ts +22 -2
  74. package/src/context-types.ts +5 -15
  75. package/src/index.ts +24 -20
  76. package/src/login-page-script.ts +107 -0
  77. package/src/login-route.ts +7 -4
  78. package/src/plugin-market-api.ts +88 -0
  79. package/src/plugin-market-shared.ts +30 -0
  80. package/src/prefs-shared.ts +1 -1
  81. package/src/pty-deps.ts +2 -2
  82. package/src/ui-tweaks/config.ts +12 -12
  83. package/src/ui-tweaks/index.ts +7 -13
@@ -0,0 +1,243 @@
1
+ /** Two catalog levels with project/user actions directly on plugin cards. */
2
+ import { useEffect, useRef, useState, useSyncExternalStore } from 'react'
3
+ import { Button, Input, Modal, Pill } from '@deepseek-ai/dsh-client-ui-primitives'
4
+ import { api, type SessionScope } from './api.ts'
5
+ import { t } from './locales.ts'
6
+ import { IconChevronLeftOutline14, IconChevronRightOutline14, IconRefreshOutline14 } from './icons.tsx'
7
+ import type { PluginMarketCatalog } from './plugin-market-catalog.ts'
8
+ import type { InstalledMarketplacePlugin, MarketplacePlugin, PluginMarketScope } from '../plugin-market-shared.ts'
9
+ import css from './PluginMarketView.module.css'
10
+ import { PluginProjectPicker, type PluginProjectRequest } from './PluginProjectPicker.tsx'
11
+
12
+ interface ProjectInstallConfirmation { name: string; path: string; finish: (confirmed: boolean) => void }
13
+
14
+ export function PluginMarketView({ scope, visible, catalog }: { scope: SessionScope; visible: boolean; catalog: PluginMarketCatalog }): JSX.Element {
15
+ const snapshot = useSyncExternalStore(catalog.subscribe, catalog.getSnapshot)
16
+ const [marketId, setMarketId] = useState<string | null>(null)
17
+ const [tab, setTab] = useState<'markets' | 'installed'>('markets')
18
+ const [query, setQuery] = useState('')
19
+ const [recordState, setRecordState] = useState<{ key: string; records: InstalledMarketplacePlugin[]; ready: boolean; error: string }>()
20
+ const [message, setMessage] = useState<{ text: string; error: boolean }>()
21
+ const [working, setWorking] = useState<{ id: string; name: string; scope: PluginMarketScope; uninstall: boolean; confirming?: boolean }>()
22
+ const [confirmation, setConfirmation] = useState<ProjectInstallConfirmation>()
23
+ const confirmationRef = useRef<ProjectInstallConfirmation>()
24
+ const [selection, setSelection] = useState<{ key: string; path: string }>()
25
+ const [picker, setPicker] = useState<PluginProjectRequest>()
26
+ const pickerRef = useRef<PluginProjectRequest>()
27
+ const [revision, setRevision] = useState(0)
28
+ const pending = useRef(false)
29
+ const breadcrumbNode = useRef<HTMLDivElement>(null)
30
+ const mutationVersion = useRef(0)
31
+ const focusBack = useRef(false)
32
+ const scopeKey = `${scope.sessionId}\0${scope.cwd ?? ''}`
33
+ const projectPath = selection?.key === scopeKey ? selection.path : scope.cwd
34
+ const recordsKey = `${scopeKey}\0${projectPath ?? ''}`
35
+ const installed = recordState?.key === recordsKey ? recordState.records : []
36
+ const recordsReady = recordState?.key === recordsKey && recordState.ready
37
+ const recordsError = recordState?.key === recordsKey ? recordState.error : ''
38
+ const latestScope = useRef(scopeKey)
39
+ latestScope.current = scopeKey
40
+ const markets = snapshot.markets?.data?.marketplaces ?? []
41
+ const market = markets.find(item => item.id === marketId)
42
+ const catalogEntry = tab === 'markets' && marketId ? snapshot.plugins[marketId] : snapshot.markets
43
+ const loading = snapshot.refresh?.status === 'loading' || (tab === 'markets' && (!catalogEntry || catalogEntry.status === 'loading'))
44
+ const operating = !!working && !working.confirming
45
+ const blocked = loading || snapshot.refresh?.status === 'error' || !!working
46
+
47
+ useEffect(() => {
48
+ if (!visible) return
49
+ catalog.start()
50
+ if (tab === 'markets' && marketId) catalog.ensure(marketId)
51
+ }, [catalog, visible, tab, marketId])
52
+ useEffect(() => { setQuery('') }, [tab, marketId])
53
+ useEffect(() => { if (focusBack.current) { breadcrumbNode.current?.querySelector('button')?.focus(); focusBack.current = false } }, [marketId])
54
+
55
+ useEffect(() => { setMessage(undefined) }, [scopeKey])
56
+ useEffect(() => {
57
+ confirmationRef.current?.finish(false)
58
+ confirmationRef.current = undefined
59
+ setConfirmation(undefined)
60
+ }, [scopeKey, visible])
61
+ useEffect(() => () => {
62
+ pickerRef.current?.controller.abort()
63
+ pickerRef.current?.finish(null)
64
+ confirmationRef.current?.finish(false)
65
+ }, [])
66
+ useEffect(() => {
67
+ if (!visible) return
68
+ const controller = new AbortController()
69
+ let active = true
70
+ let reading = false
71
+ const read = async (): Promise<void> => {
72
+ if (pending.current || reading) return
73
+ reading = true
74
+ const version = mutationVersion.current
75
+ try {
76
+ const records = await api.pluginsInstalled(scope, controller.signal, projectPath)
77
+ if (active && !pending.current && version === mutationVersion.current) setRecordState({ key: recordsKey, records, ready: true, error: '' })
78
+ } catch (cause) {
79
+ if (active && version === mutationVersion.current) setRecordState(previous => ({ key: recordsKey, records: previous?.key === recordsKey ? previous.records : [], ready: previous?.key === recordsKey && previous.ready, error: cause instanceof Error ? cause.message : String(cause) }))
80
+ } finally { reading = false }
81
+ }
82
+ void read()
83
+ // Only local installation records are polled for CLI synchronization.
84
+ // Remote catalogs are never polled or refreshed by navigation.
85
+ const timer = setInterval(() => { void read() }, 2000)
86
+ return () => { active = false; clearInterval(timer); controller.abort() }
87
+ }, [recordsKey, visible, revision])
88
+
89
+ const chooseDirectory = (): Promise<string | null> => new Promise(finish => {
90
+ const controller = new AbortController()
91
+ const request = { result: api.pluginProjectPick(controller.signal), controller, finish }
92
+ pickerRef.current = request
93
+ setPicker(request)
94
+ })
95
+ const finishPicker = (path: string | null): void => {
96
+ pickerRef.current?.finish(path)
97
+ pickerRef.current?.controller.abort()
98
+ pickerRef.current = undefined
99
+ setPicker(undefined)
100
+ }
101
+ const confirmProjectInstall = (name: string, path: string): Promise<boolean> => new Promise(finish => {
102
+ const request = { name, path, finish }
103
+ confirmationRef.current = request
104
+ setConfirmation(request)
105
+ })
106
+ const finishConfirmation = (confirmed: boolean): void => {
107
+ const request = confirmationRef.current
108
+ confirmationRef.current = undefined
109
+ setConfirmation(undefined)
110
+ request?.finish(confirmed)
111
+ }
112
+ const chooseProject = async (): Promise<void> => {
113
+ if (pending.current || blocked) return
114
+ pending.current = true
115
+ mutationVersion.current++
116
+ setMessage(undefined)
117
+ const key = scopeKey
118
+ try {
119
+ const path = await chooseDirectory()
120
+ if (path && latestScope.current === key) setSelection({ key, path })
121
+ } finally { pending.current = false; setRevision(value => value + 1) }
122
+ }
123
+
124
+ const perform = async (plugin: MarketplacePlugin, installScope: PluginMarketScope): Promise<void> => {
125
+ const refreshStatus = catalog.getSnapshot().refresh?.status
126
+ if (pending.current || !recordsReady || blocked || refreshStatus === 'loading' || refreshStatus === 'error') return
127
+ const key = scopeKey
128
+ const record = installed.find(item => item.id === plugin.id && item.scope === installScope)
129
+ const present = !!record
130
+ if (installScope === 'project' && !present && !projectPath) {
131
+ setMessage({ text: t('pluginMarketProjectHint'), error: true })
132
+ return
133
+ }
134
+ pending.current = true
135
+ mutationVersion.current++
136
+ const operation = { id: plugin.id, name: plugin.name, scope: installScope, uninstall: present }
137
+ setWorking({ ...operation, confirming: installScope === 'project' && !present })
138
+ setMessage(undefined)
139
+ try {
140
+ let target = record?.scope === 'project' ? record.projectPath : projectPath
141
+ if (installScope === 'project' && !present) {
142
+ const confirmed = await confirmProjectInstall(plugin.name, target!)
143
+ if (!confirmed || latestScope.current !== key) return
144
+ setWorking(operation)
145
+ }
146
+ let installedPath = ''
147
+ if (present) await api.pluginUninstall(scope, plugin.id, installScope, target)
148
+ else {
149
+ const result = await api.pluginInstall(scope, plugin.id, installScope, target)
150
+ installedPath = result.installPath
151
+ if (installScope === 'project') {
152
+ target = result.projectPath
153
+ if (latestScope.current === key) setSelection({ key, path: target })
154
+ }
155
+ }
156
+ const records = await api.pluginsInstalled(scope, undefined, target)
157
+ if (latestScope.current === key) {
158
+ setRecordState({ key: `${key}\0${target ?? ''}`, records, ready: true, error: '' })
159
+ setMessage({ text: present ? t('pluginMarketUninstalled') : t('pluginMarketInstalledAt', { path: installedPath }), error: false })
160
+ }
161
+ } catch (cause) {
162
+ if (latestScope.current === key) setMessage({ text: cause instanceof Error ? cause.message : String(cause), error: true })
163
+ } finally { pending.current = false; setWorking(undefined); setRevision(value => value + 1) }
164
+ }
165
+ const refresh = (): void => {
166
+ if (loading || pending.current) return
167
+ catalog.refresh(tab === 'markets' && marketId ? marketId : undefined)
168
+ setRevision(value => value + 1)
169
+ setMessage(undefined)
170
+ }
171
+ const term = query.trim().toLocaleLowerCase()
172
+ const matches = (item: { name: string; description: string }): boolean => `${item.name} ${item.description}`.toLocaleLowerCase().includes(term)
173
+ // One installed card per plugin, with independent controls for both scopes.
174
+ const entries = tab === 'installed' ? [...new Map(installed.map(item => [item.id, item])).values()] : marketId ? snapshot.plugins[marketId]?.data ?? [] : []
175
+ const filteredPlugins = entries.filter(matches)
176
+ const filteredMarkets = markets.filter(matches)
177
+ const showMarkets = tab === 'markets' && !marketId
178
+ const error = snapshot.refresh?.error || (tab === 'markets' ? catalogEntry?.error : '') || recordsError
179
+ const warning = [snapshot.markets?.data?.warning, marketId ? snapshot.plugins[marketId]?.warning : ''].filter(Boolean).join('\n')
180
+ const hasData = tab === 'installed' ? recordsReady : !!catalogEntry?.data
181
+
182
+ return <section className={css.root} aria-label={t('pluginMarketTitle')} aria-busy={loading || operating} data-chatcode-plugin-market>
183
+ <header className={css.head}>
184
+ <div><h2 className={css.title}>{t('pluginMarketTitle')}</h2><p className={css.subtitle}>{t('pluginMarketSubtitle')}</p></div>
185
+ <Input disabled={blocked} value={query} onChange={event => setQuery(event.target.value)} placeholder={t('pluginMarketSearch')} aria-label={t('pluginMarketSearch')} />
186
+ </header>
187
+ <div className={css.projectRow}>
188
+ <p className={css.project}>{projectPath ? t('pluginMarketProjectDirectory', { path: projectPath }) : t('pluginMarketProjectHint')}</p>
189
+ <Button size="sm" variant="outline" disabled={blocked || !!working || !!picker} onClick={() => { void chooseProject() }}>{t('pluginMarketChooseProject')}</Button>
190
+ </div>
191
+ <div className={css.toolbar}>
192
+ <div className={css.tabs}>
193
+ <Button size="sm" variant="ghost" disabled={blocked} aria-pressed={tab === 'markets'} onClick={() => setTab('markets')}>{t('pluginMarketTitle')}</Button>
194
+ <Button size="sm" variant="ghost" disabled={blocked} aria-pressed={tab === 'installed'} onClick={() => setTab('installed')}>{t('pluginMarketInstalledTab')}</Button>
195
+ </div>
196
+ <Button size="sm" variant="outline" aria-label={t('pluginMarketRefresh')} disabled={snapshot.markets?.status === 'loading' || loading || !!working} onClick={refresh}><span aria-hidden="true" className={loading ? css.spinning : undefined}><IconRefreshOutline14 /></span>{t(loading ? 'pluginMarketRefreshing' : 'pluginMarketRefresh')}</Button>
197
+ </div>
198
+ {operating ? <div className={css.operation} role="status">
199
+ <span className={css.spinning} aria-hidden="true"><IconRefreshOutline14 /></span>
200
+ <span>{t(working.uninstall ? 'pluginMarketUninstallProgress' : 'pluginMarketInstallProgress', { name: working.name })}</span>
201
+ </div> : null}
202
+ {warning && tab === 'markets' ? <p className={css.warning} role="status">{warning}</p> : null}
203
+ {error ? <p className={css.error} role="status">{error}</p> : null}
204
+ {message ? <p className={message.error ? css.error : css.notice} role="status">{message.text}</p> : null}
205
+ {tab === 'markets' && marketId ? <div ref={breadcrumbNode} className={css.breadcrumb}>
206
+ <Button size="sm" variant="ghost" disabled={blocked} onClick={() => setMarketId(null)}><IconChevronLeftOutline14 />{t('pluginMarketBack')}</Button>
207
+ <span aria-hidden="true">/</span><span>{market?.name ?? marketId}</span>
208
+ </div> : null}
209
+ {loading ? <p className={css.state} role="status">{t(hasData ? 'pluginMarketRefreshing' : 'pluginMarketLoading')}</p> : null}
210
+ <div className={css.grid} aria-busy={loading || operating}>
211
+ {showMarkets ? filteredMarkets.map(item => <button key={item.id} type="button" disabled={blocked} className={`${css.card} ${css.marketCard}`} onClick={() => { focusBack.current = true; setMarketId(item.id) }}>
212
+ <div className={css.cardHead}><h3>{item.name}</h3>{item.official ? <Pill>{t('pluginMarketDefault')}</Pill> : null}</div>
213
+ <p className={css.description}>{item.description || t('pluginMarketNoDescription')}</p>
214
+ <span className={css.enter}>{t('pluginMarketBrowse')}<IconChevronRightOutline14 /></span>
215
+ </button>) : filteredPlugins.map(item => {
216
+ const records = installed.filter(record => record.id === item.id)
217
+ const marketName = markets.find(value => value.id === item.marketplaceId)?.name ?? item.marketplaceId
218
+ return <article key={item.id} className={css.card} aria-label={item.name} data-plugin-id={item.id}>
219
+ <div className={css.cardHead}><h3>{item.name}</h3>{records.length ? <Pill>{t('pluginMarketInstalledTab')}</Pill> : null}</div>
220
+ <p className={css.description}>{item.description || t('pluginMarketNoDescription')}</p>
221
+ <p className={css.meta}>{marketName}{tab === 'installed' && records[0]?.version ? ` · ${records[0].version}` : ''}</p>
222
+ {records.map(record => <p key={record.scope} className={css.installPath}>{t('pluginMarketInstallPath', { scope: t(record.scope === 'project' ? 'pluginMarketProject' : 'pluginMarketUser'), path: record.installPath })}</p>)}
223
+ <div className={css.actions}>
224
+ {(['project', 'user'] as const).map(installScope => {
225
+ const present = records.some(record => record.scope === installScope)
226
+ const busy = working?.id === item.id && working.scope === installScope
227
+ return <Button key={installScope} size="sm" variant={installScope === 'project' && !present ? 'primary' : 'outline'} className={installScope === 'project' && !present ? css.projectInstall : undefined} disabled={blocked || !!working || !recordsReady} onClick={() => { void perform(item, installScope) }}>
228
+ {busy && operating ? <span className={css.spinning} aria-hidden="true"><IconRefreshOutline14 /></span> : null}
229
+ {t(busy ? working?.confirming ? 'pluginMarketAwaitingConfirmation' : working?.uninstall ? 'pluginMarketUninstalling' : 'pluginMarketInstalling' : present ? 'pluginMarketUninstall' : 'pluginMarketInstall')} · {t(installScope === 'project' ? 'pluginMarketProject' : 'pluginMarketUser')}
230
+ </Button>
231
+ })}
232
+ </div>
233
+ </article>
234
+ })}
235
+ </div>
236
+ {!loading && hasData && (showMarkets ? filteredMarkets : filteredPlugins).length === 0 ? <p className={css.state}>{t('pluginMarketEmpty')}</p> : null}
237
+ {confirmation ? <Modal open title={t('pluginMarketConfirmProjectInstall')} description={t('pluginMarketConfirmProjectDescription', { name: confirmation.name })} closeLabel={t('cancel')} onClose={() => finishConfirmation(false)} className={css.projectPicker}
238
+ footer={<><Button variant="outline" data-modal-autofocus onClick={() => finishConfirmation(false)}>{t('cancel')}</Button><Button variant="primary" onClick={() => finishConfirmation(true)}>{t('pluginMarketConfirmInstall')}</Button></>}>
239
+ <p className={css.confirmPath}>{confirmation.path}</p>
240
+ </Modal> : null}
241
+ {picker ? <PluginProjectPicker request={picker} initialPath={projectPath} onPicked={finishPicker} onCancel={() => finishPicker(null)} onError={text => { setMessage({ text, error: true }); finishPicker(null) }} /> : null}
242
+ </section>
243
+ }
@@ -0,0 +1,73 @@
1
+ /** Native chooser first; the host browse backend supplies the remote Web dialog. */
2
+ import { useEffect, useRef, useState } from 'react'
3
+ import { Button, Input, Modal } from '@deepseek-ai/dsh-client-ui-primitives'
4
+ import { api } from './api.ts'
5
+ import { t } from './locales.ts'
6
+ import { IconFolderOpen16 } from './icons.tsx'
7
+ import type { PluginProjectDirectories, PluginProjectPick } from '../plugin-market-shared.ts'
8
+ import css from './PluginMarketView.module.css'
9
+
10
+ export interface PluginProjectRequest {
11
+ result: Promise<PluginProjectPick>
12
+ controller: AbortController
13
+ finish: (path: string | null) => void
14
+ }
15
+
16
+ export function PluginProjectPicker({ request, initialPath, onPicked, onCancel, onError }: {
17
+ request: PluginProjectRequest
18
+ initialPath?: string
19
+ onPicked: (path: string) => void
20
+ onCancel: () => void
21
+ onError: (message: string) => void
22
+ }): JSX.Element | null {
23
+ const [browse, setBrowse] = useState(false)
24
+ const [path, setPath] = useState(initialPath ?? '')
25
+ const [draft, setDraft] = useState(initialPath ?? '')
26
+ const [listing, setListing] = useState<PluginProjectDirectories>()
27
+ const [loading, setLoading] = useState(true)
28
+ const [error, setError] = useState('')
29
+ const [revision, setRevision] = useState(0)
30
+ const callbacks = useRef({ onPicked, onCancel, onError })
31
+ callbacks.current = { onPicked, onCancel, onError }
32
+ useEffect(() => {
33
+ let active = true
34
+ void request.result.then(result => {
35
+ if (!active) return
36
+ if (result.kind === 'browse') setBrowse(true)
37
+ else if (result.path === null) callbacks.current.onCancel()
38
+ else callbacks.current.onPicked(result.path)
39
+ }).catch(cause => { if (active) callbacks.current.onError(cause instanceof Error ? cause.message : String(cause)) })
40
+ return () => { active = false }
41
+ }, [request])
42
+ useEffect(() => {
43
+ if (!browse) return
44
+ const controller = new AbortController()
45
+ let active = true
46
+ setLoading(true); setListing(undefined); setError('')
47
+ void api.pluginProjectDirectories(path || undefined, controller.signal).then(value => {
48
+ if (active) { setListing(value); setDraft(value.path); setLoading(false) }
49
+ }).catch(cause => {
50
+ if (active) { setError(cause instanceof Error ? cause.message : String(cause)); setLoading(false) }
51
+ })
52
+ return () => { active = false; controller.abort() }
53
+ }, [browse, path, revision])
54
+ const navigate = (next: string): void => { setLoading(true); setListing(undefined); setPath(next); setRevision(value => value + 1) }
55
+ if (!browse) return null
56
+ return <Modal open title={t('pluginMarketChooseProject')} description={t('pluginMarketProjectHint')} closeLabel={t('cancel')} onClose={onCancel} className={css.projectPicker}
57
+ footer={<><Button variant="outline" onClick={onCancel}>{t('cancel')}</Button><Button variant="primary" disabled={loading || !listing} onClick={() => { if (listing) onPicked(listing.path) }}>{t('pluginMarketSelectDirectory')}</Button></>}>
58
+ <form className={css.directoryPath} onSubmit={event => { event.preventDefault(); navigate(draft) }}>
59
+ <Input data-modal-autofocus disabled={loading} aria-label={t('pluginMarketDirectoryPath')} value={draft} onChange={event => setDraft(event.target.value)} />
60
+ <Button type="submit" variant="outline" disabled={loading}>{t('pluginMarketOpenDirectory')}</Button>
61
+ </form>
62
+ <nav className={css.directoryCrumbs} aria-label={t('pluginMarketDirectoryPath')}>
63
+ <Button size="sm" variant="ghost" disabled={loading} onClick={() => navigate('')}>{t('pluginMarketHomeDirectory')}</Button>
64
+ {listing?.crumbs.map(crumb => <Button key={crumb.path} size="sm" variant="ghost" disabled={loading} onClick={() => navigate(crumb.path)}>{crumb.name}</Button>)}
65
+ </nav>
66
+ {error ? <p className={css.error} role="alert">{error}</p> : null}
67
+ {loading ? <p className={css.state} role="status">{t('pluginMarketLoading')}</p> : null}
68
+ <div className={css.directoryList} aria-busy={loading}>
69
+ {listing?.entries.map(entry => <button key={entry.path} type="button" onClick={() => navigate(entry.path)}><IconFolderOpen16 />{entry.name}</button>)}
70
+ </div>
71
+ {listing?.truncated ? <p className={css.state}>{t('pluginMarketDirectoryTruncated')}</p> : null}
72
+ </Modal>
73
+ }
@@ -41,14 +41,7 @@
41
41
  * shell.
42
42
  */
43
43
  import { Fragment, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
44
- import {
45
- IconChevronDownOutline14,
46
- IconPlusOutline16,
47
- IconSettingsOutline16,
48
- Input,
49
- Menu,
50
- Modal,
51
- } from '@deepseek-ai/dsh-client-ui-primitives'
44
+ import { Input, Menu, Modal } from '@deepseek-ai/dsh-client-ui-primitives'
52
45
  import clsx from 'clsx'
53
46
  // Type-only: pulls the settings shell's SlotMap merges ('settings.section').
54
47
  import type {} from '@deepseek-ai/dsh-client-ui-settings/client'
@@ -63,13 +56,9 @@ import {
63
56
  type TitleBarScheme,
64
57
  } from '../prefs-shared.ts'
65
58
  import { api } from './api.ts'
59
+ import { IconChevronDownOutline14, IconPlusOutline16, IconSettingsOutline16 } from './icons.tsx'
66
60
  import { parsePrefs } from './prefs.ts'
67
61
  import { AddPluginModal, type PluginKind } from './add-plugin-modal.tsx'
68
- import {
69
- CODING_PLAN_SELECTED_MODEL_KEY,
70
- CODING_PLAN_SETTINGS_ID,
71
- CodingPlanModelsSettings,
72
- } from './CodingPlanModelsSettings.tsx'
73
62
  import { t } from './locales.ts'
74
63
  import { parseDesktopEnv } from './desktop-env.ts'
75
64
  import { getShellPreset, getShellPresets } from './shell-presets.ts'
@@ -966,16 +955,6 @@ export function SideCardSection({ store, service }: SideCardSectionProps) {
966
955
  </div>
967
956
  </div>
968
957
 
969
- {/* CodingPlan lives in the established settings page rather than a
970
- separate sidebar tab. The catalogue itself is fetched/cached by the
971
- host, and its selected logical id persists in pluginSettings. */}
972
- <CodingPlanModelsSettings
973
- selectedModelId={typeof prefs.pluginSettings[CODING_PLAN_SETTINGS_ID]?.[CODING_PLAN_SELECTED_MODEL_KEY] === 'string'
974
- ? prefs.pluginSettings[CODING_PLAN_SETTINGS_ID]?.[CODING_PLAN_SELECTED_MODEL_KEY] as string
975
- : undefined}
976
- onSelect={(modelId) => { applyPluginSetting(CODING_PLAN_SETTINGS_ID, CODING_PLAN_SELECTED_MODEL_KEY, modelId) }}
977
- />
978
-
979
958
  {/* 侧边栏内容: one small card per registered tab type in a responsive
980
959
  grid; features declaring `settings.toggles` open their settings in
981
960
  the popup (gear corner button) instead of nested inline rows. */}
@@ -36,7 +36,7 @@ import { createElement, memo, useCallback, useEffect, useMemo, useRef, useState,
36
36
  import { useSyncExternalStore } from 'react'
37
37
  import { createPortal } from 'react-dom'
38
38
  import clsx from 'clsx'
39
- import { IconCloseFill14, Tooltip } from '@deepseek-ai/dsh-client-ui-primitives'
39
+ import { Tooltip } from '@deepseek-ai/dsh-client-ui-primitives'
40
40
  import type { Context } from '../context-types.ts'
41
41
  import { appendToDraft } from './conversation-draft.ts'
42
42
  import {
@@ -47,7 +47,7 @@ import {
47
47
  type DropZone, type SidebarState, type SidebarStore, type SidebarTab, type SplitNode,
48
48
  } from './state.ts'
49
49
  import { collectPinnedTabs, createPinnedVirtualTab, getPinnedHomeScope, injectPinnedIntoTree, isPinnedVirtualId, isPinnedVirtualTab, parsePinnedVirtualId, type PinnedTabEntry } from './pinned.ts'
50
- import { IconBookOutline16, IconPinOutline16 } from './icons.tsx'
50
+ import { IconBookOutline16, IconCloseFill14, IconPinOutline16 } from './icons.tsx'
51
51
  import { IconPanelBottomOutline16, IconPanelRightOutline16 } from './icons.tsx'
52
52
  import { Workbench, type WorkbenchActions } from './split-pane.tsx'
53
53
  import { isNarrowWidth, useViewportSize } from './breakpoints.ts'
@@ -10,13 +10,11 @@
10
10
  */
11
11
  import { useEffect, useRef, useState, type ReactNode } from 'react'
12
12
  import clsx from 'clsx'
13
- import {
14
- IconCloseFill14, IconPlusOutline16, Menu,
15
- } from '@deepseek-ai/dsh-client-ui-primitives'
13
+ import { Menu } from '@deepseek-ai/dsh-client-ui-primitives'
16
14
  import type { SidebarTab } from './state.ts'
17
15
  import { isAgentTabId } from './state.ts'
18
16
  import { isPinnedVirtualTab } from './pinned.ts'
19
- import { IconPinOutline16 } from './icons.tsx'
17
+ import { IconCloseFill14, IconPinOutline16, IconPlusOutline16 } from './icons.tsx'
20
18
  import { t } from './locales.ts'
21
19
  import css from './sidebar.module.css'
22
20
 
@@ -19,7 +19,8 @@ import clsx from 'clsx'
19
19
  import { EditorState } from '@codemirror/state'
20
20
  import { EditorView as CodeMirrorView, keymap, lineNumbers } from '@codemirror/view'
21
21
  import { defaultKeymap, history, historyKeymap } from '@codemirror/commands'
22
- import { IconCheckOutline16, MarkdownText } from '@deepseek-ai/dsh-client-ui-primitives'
22
+ import { MarkdownText } from '@deepseek-ai/dsh-client-ui-primitives'
23
+ import { IconCheckOutline16 } from './icons.tsx'
23
24
  import { markdownTextProps } from './markdown-labels.tsx'
24
25
  import { api, htmlUrl } from './api.ts'
25
26
  import { rewriteLocalImageUrls } from './markdown-images.ts'
@@ -17,11 +17,10 @@
17
17
  */
18
18
  import { useEffect, useRef, useState, type InputHTMLAttributes } from 'react'
19
19
  import clsx from 'clsx'
20
- import { IconFolderOpen16, IconRefreshOutline16 } from '@deepseek-ai/dsh-client-ui-primitives'
21
20
  import { api } from './api.ts'
22
21
  import type { SidebarStore } from './state.ts'
23
22
  import { FileTree } from './FileTree.tsx'
24
- import { IconUploadOutline16 } from './icons.tsx'
23
+ import { IconFolderOpen16, IconRefreshOutline16, IconUploadOutline16 } from './icons.tsx'
25
24
  import type { OpenWithTarget } from './open-with.ts'
26
25
  import { t } from './locales.ts'
27
26
  import { resolveSidebarPath } from './produced-files.ts'
@@ -4,7 +4,7 @@ import {
4
4
  IconChevronRightOutline14,
5
5
  IconLoadingOutline16,
6
6
  IconRefreshOutline14,
7
- } from '@deepseek-ai/dsh-client-ui-primitives'
7
+ } from './icons.tsx'
8
8
  import clsx from 'clsx'
9
9
  // Type-only: pulls the settings shell's SlotMap merges ('settings.section').
10
10
  import type {} from '@deepseek-ai/dsh-client-ui-settings/client'
package/src/client/api.ts CHANGED
@@ -8,6 +8,7 @@
8
8
  */
9
9
  import { encodeHtmlUrl } from '../html-route.ts'
10
10
  import type { BrowserProbeResult } from './browser.ts'
11
+ import type { MarketplaceCatalog, MarketplacePlugin, InstalledMarketplacePlugin, PluginMarketScope, PluginProjectPick, PluginProjectDirectories } from '../plugin-market-shared.ts'
11
12
 
12
13
  /** One wire failure. */
13
14
  export class SidebarApiError extends Error {
@@ -287,6 +288,14 @@ function gitPayload(scope: SessionScope, worktree: string | undefined, extra: Re
287
288
 
288
289
  /** The sidebar API surface (session scope threaded through every call). */
289
290
  export const api = {
291
+ pluginMarketContext: (scope: SessionScope, signal?: AbortSignal) => call<{ sessionId: string; cwd?: string }>('plugins.context', scopePayload(scope, {}), signal),
292
+ pluginProjectPick: (signal?: AbortSignal) => call<PluginProjectPick>('plugins.project.pick', {}, signal),
293
+ pluginProjectDirectories: (path?: string, signal?: AbortSignal) => call<PluginProjectDirectories>('plugins.project.directories', { path }, signal),
294
+ pluginMarketplaces: (signal?: AbortSignal) => call<MarketplaceCatalog>('plugins.marketplaces', {}, signal),
295
+ pluginCatalog: (marketplaceId: string, signal?: AbortSignal) => call<MarketplacePlugin[] | { plugins: MarketplacePlugin[]; warning: string }>('plugins.catalog', { marketplaceId, includeMetadata: true }, signal),
296
+ pluginsInstalled: (scope: SessionScope, signal?: AbortSignal, projectPath?: string) => call<InstalledMarketplacePlugin[]>('plugins.installed', scopePayload(scope, { projectPath }), signal),
297
+ pluginInstall: (scope: SessionScope, pluginId: string, installScope: PluginMarketScope, projectPath?: string) => call<InstalledMarketplacePlugin>('plugins.install', scopePayload(scope, { pluginId, scope: installScope, projectPath })),
298
+ pluginUninstall: (scope: SessionScope, pluginId: string, installScope: PluginMarketScope, projectPath?: string) => call<{ ok: true }>('plugins.uninstall', scopePayload(scope, { pluginId, scope: installScope, projectPath })),
290
299
  chatcodeStatus: (signal?: AbortSignal) => call<ChatCodeAuthState>('chatcode.status', {}, signal),
291
300
  chatcodeStart: () => call<{ sessionId: string; url: string }>('chatcode.start', {}),
292
301
  chatcodeCancel: (sessionId: string) => call<{ ok: true }>('chatcode.cancel', { sessionId }),
@@ -1,13 +1,12 @@
1
1
  /**
2
- * The 7 built-in tab descriptors: the plugin registers its own pages
3
- * (editor / git / terminal / browser / diff) through
2
+ * The 6 built-in tab descriptors: the plugin registers its own pages
3
+ * (editor / git / terminal / browser / diff / plugin-market) through
4
4
  * the same {@link BetterSidebarService} external plugins use — eating its
5
5
  * own dogfood. The terminal descriptor owns its quota (`TERMINAL_LIMIT`)
6
6
  * and mints `terminal:<uuid>` ids through `createTab`; the browser mints
7
7
  * `browser:<n>` the same way (no quota). The editor IS the files window
8
8
  * (the old standalone explorer merged into it).
9
9
  */
10
- import { IconBranchOutline16, IconCodeOutline16, IconFolderOpen16, IconPanelLeftOutline16 } from '@deepseek-ai/dsh-client-ui-primitives'
11
10
  import type { Context } from '../../context-types.ts'
12
11
  import { allLeaves, isAgentTabId, type SidebarState } from '../state.ts'
13
12
  import { t } from '../locales.ts'
@@ -18,7 +17,17 @@ import { lazyChunkComponent } from '../lazy-chunk.tsx'
18
17
  import { GitView } from '../GitView.tsx'
19
18
  import { DiffTab } from '../DiffTab.tsx'
20
19
  import { BrowserView } from '../BrowserView.tsx'
21
- import { IconTerminalOutline16, IconDiffOutline16, IconGlobeOutline16 } from '../icons.tsx'
20
+ import { PluginMarketView } from '../PluginMarketView.tsx'
21
+ import { createPluginMarketCatalog, type PluginMarketCatalog } from '../plugin-market-catalog.ts'
22
+ import {
23
+ IconBranchOutline16,
24
+ IconCodeOutline16,
25
+ IconDiffOutline16,
26
+ IconFolderOpen16,
27
+ IconGlobeOutline16,
28
+ IconPanelLeftOutline16,
29
+ IconTerminalOutline16,
30
+ } from '../icons.tsx'
22
31
  import { TERMINAL_FONT_SIZE_MAX, TERMINAL_FONT_SIZE_MIN } from '../../prefs-shared.ts'
23
32
  import type { ComponentType } from 'react'
24
33
  import type { SessionScope } from '../api.ts'
@@ -56,6 +65,8 @@ export const TERMINAL_LIMIT = 3
56
65
  export interface BuiltinTabOptions {
57
66
  /** Returns the display title for newly opened terminal tabs. */
58
67
  terminalTitle?: () => string
68
+ /** Shared app-lifetime catalog; production supplies the activation's store. */
69
+ pluginMarketCatalog?: PluginMarketCatalog
59
70
  }
60
71
 
61
72
  /** A client-side uuid for terminal tab identity (not shown in the UI). */
@@ -73,8 +84,9 @@ function uiTerminalCount(state: SidebarState): number {
73
84
  .filter(tab => tab.type === 'terminal' && !isAgentTabId(tab.id)).length
74
85
  }
75
86
 
76
- /** The 5 built-in tab descriptors. */
87
+ /** The 6 built-in tab descriptors. */
77
88
  export function builtinTabs(ctx: Context, options: BuiltinTabOptions = {}): readonly TabDescriptor[] {
89
+ const pluginMarketCatalog = options.pluginMarketCatalog ?? createPluginMarketCatalog()
78
90
  return [
79
91
  {
80
92
  id: 'editor',
@@ -259,6 +271,14 @@ export function builtinTabs(ctx: Context, options: BuiltinTabOptions = {}): read
259
271
  }),
260
272
  component: (props) => <BrowserView {...props} />,
261
273
  },
274
+ {
275
+ id: 'plugin-market',
276
+ title: () => t('pluginMarketTitle'),
277
+ icon: (size: number) => <IconGlobeOutline16 size={size} />,
278
+ order: 60,
279
+ single: true,
280
+ component: ({ scope, visible }) => <PluginMarketView scope={scope} visible={visible} catalog={pluginMarketCatalog} />,
281
+ },
262
282
  {
263
283
  id: 'diff',
264
284
  title: () => t('git'),
@@ -22,11 +22,12 @@
22
22
  * and `icon` — so the Side card settings page can render the enable/disable
23
23
  * inventory without hardcoding (eating our own dogfood).
24
24
  */
25
- import { IconCodeOutline16, IconDownloadOutline16 } from '@deepseek-ai/dsh-client-ui-primitives'
26
25
  import { lazyChunkComponent } from '../lazy-chunk.tsx'
27
26
  import { PdfView } from '../PdfView.tsx'
28
27
  import { BinaryDownload } from '../binary-download.tsx'
29
28
  import {
29
+ IconCodeOutline16,
30
+ IconDownloadOutline16,
30
31
  IconImageOutline16,
31
32
  IconMarkdownOutline16,
32
33
  IconPdfOutline16,
@@ -1,11 +1,64 @@
1
1
  /**
2
- * Icons the sidebar needs beyond the primitives set: a terminal glyph (the
3
- * icon library has none), a diff glyph, and the two panel-toggle glyphs for
4
- * the top-right cluster. Per-tab icons live on the tab descriptors
2
+ * Icons owned by the sidebar. DSH 0.1.7 stopped exporting the old Icon*
3
+ * components from dsh-client-ui-primitives, so keeping every glyph local
4
+ * makes the browser bundle work against both the 0.1.2 and 0.1.7 hosts.
5
+ * Per-tab icons live on the tab descriptors
5
6
  * (`descriptor.icon`), not in a type-keyed switch — the icon mapping was
6
7
  * registry-ized with the tab types.
7
8
  */
8
- import type { IconProps } from '@deepseek-ai/dsh-client-ui-primitives'
9
+ import {
10
+ FiAlertTriangle,
11
+ FiCheck,
12
+ FiChevronDown,
13
+ FiChevronLeft,
14
+ FiChevronRight,
15
+ FiCode,
16
+ FiCopy,
17
+ FiDownload,
18
+ FiFolder,
19
+ FiGitBranch,
20
+ FiLink,
21
+ FiList,
22
+ FiLoader,
23
+ FiPlus,
24
+ FiRefreshCw,
25
+ FiSettings,
26
+ FiSidebar,
27
+ FiTrash2,
28
+ FiX,
29
+ } from 'react-icons/fi'
30
+ import type { IconType } from 'react-icons'
31
+
32
+ export interface IconProps {
33
+ size?: number
34
+ className?: string
35
+ }
36
+
37
+ const wrapIcon = (Icon: IconType, defaultSize: number) =>
38
+ ({ size = defaultSize, className }: IconProps) => <Icon size={size} className={className} />
39
+
40
+ export const IconListPenOutline16 = wrapIcon(FiList, 16)
41
+ export const IconRefreshOutline16 = wrapIcon(FiRefreshCw, 16)
42
+ export const IconRefreshOutline14 = wrapIcon(FiRefreshCw, 14)
43
+ export const IconChevronRightOutline14 = wrapIcon(FiChevronRight, 14)
44
+ export const IconChevronLeftOutline14 = wrapIcon(FiChevronLeft, 14)
45
+ export const IconChevronDownOutline14 = wrapIcon(FiChevronDown, 14)
46
+ export const IconCodeOutline16 = wrapIcon(FiCode, 16)
47
+ export const IconCopyOutline16 = wrapIcon(FiCopy, 16)
48
+ export const IconDownloadOutline16 = wrapIcon(FiDownload, 16)
49
+ export const IconLinkOutline16 = wrapIcon(FiLink, 16)
50
+ export const IconLinkOutline14 = wrapIcon(FiLink, 14)
51
+ export const IconBranchOutline16 = wrapIcon(FiGitBranch, 16)
52
+ export const IconTrashOutline16 = wrapIcon(FiTrash2, 16)
53
+ export const IconWarningOutline16 = wrapIcon(FiAlertTriangle, 16)
54
+ export const IconCloseFill14 = wrapIcon(FiX, 14)
55
+ export const IconCloseOutline16 = wrapIcon(FiX, 16)
56
+ export const IconLoadingOutline16 = wrapIcon(FiLoader, 16)
57
+ export const IconPlusOutline16 = wrapIcon(FiPlus, 16)
58
+ export const IconSettingsOutline16 = wrapIcon(FiSettings, 16)
59
+ export const IconFolderOpen16 = wrapIcon(FiFolder, 16)
60
+ export const IconPanelLeftOutline16 = wrapIcon(FiSidebar, 16)
61
+ export const IconCheckOutline16 = wrapIcon(FiCheck, 16)
9
62
 
10
63
  /** User-manual glyph: an open book in the sidebar's 1.5px outline style. */
11
64
  export const IconBookOutline16 = ({ size = 16, className }: IconProps) => (