@chatcode/cco-better-sidebar 0.18.0-rc.8 → 0.18.1-rc.13.022-rc1
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 +19 -9
- package/README_EN.md +19 -9
- package/lib/client-editor.js +300 -299
- package/lib/client-mermaid.js +295 -296
- package/lib/client-registry.js +2115 -2075
- package/lib/client-terminal.js +298 -297
- package/lib/client.js +2115 -2075
- package/lib/index.js +28 -7
- package/lib/types/client/AccountMenu.d.ts +4 -1
- package/lib/types/client/ContextMenu.d.ts +15 -0
- package/lib/types/client/api.d.ts +4 -0
- package/lib/types/client/locales-ja.d.ts +25 -0
- package/lib/types/client/service.d.ts +1 -1
- package/lib/types/client/ui-tweaks/archive.d.ts +9 -28
- package/lib/types/client/ui-tweaks/branding.d.ts +1 -1
- package/lib/types/client/ui-tweaks/dom-text.d.ts +2 -0
- package/lib/types/client/ui-tweaks/index.d.ts +10 -0
- package/lib/types/client/ui-tweaks/notifier.d.ts +4 -2
- package/lib/types/client/useChatcodeAccount.d.ts +1 -0
- package/lib/types/ui-tweaks/config.d.ts +1 -1
- package/lib/types/ui-tweaks/turn-outcome.d.ts +1 -1
- package/package.json +84 -86
- package/src/client/AccountMenu.tsx +13 -17
- package/src/client/ContextMenu.tsx +22 -0
- package/src/client/FileTree.tsx +6 -13
- package/src/client/FreeWindow.tsx +4 -3
- package/src/client/GitView.tsx +8 -5
- package/src/client/SideCardSection.tsx +0 -15
- package/src/client/Sidebar.tsx +0 -3
- package/src/client/TabBar.tsx +5 -4
- package/src/client/api.ts +3 -0
- package/src/client/index.tsx +18 -40
- package/src/client/locales-ja.ts +26 -0
- package/src/client/service.ts +1 -1
- package/src/client/shell-presets.ts +1 -1
- package/src/client/sidebar.module.css +23 -13
- package/src/client/ui-tweaks/archive.tsx +118 -140
- package/src/client/ui-tweaks/branding.tsx +85 -24
- package/src/client/ui-tweaks/cachehit.tsx +24 -14
- package/src/client/ui-tweaks/dom-text.ts +12 -0
- package/src/client/ui-tweaks/index.tsx +84 -26
- package/src/client/ui-tweaks/notifier.ts +13 -12
- package/src/client/ui-tweaks/whale.tsx +1 -1
- package/src/client/useChatcodeAccount.ts +12 -2
- package/src/index.ts +10 -3
- package/src/ui-tweaks/config.ts +1 -1
- package/src/ui-tweaks/git.ts +1 -1
- package/src/ui-tweaks/turn-outcome.ts +3 -3
- package/src/ui-tweaks/web.ts +1 -0
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import { useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from 'react'
|
|
11
11
|
import { createPortal } from 'react-dom'
|
|
12
|
+
import type { SessionId } from '@deepseek-ai/dsh-session/types'
|
|
12
13
|
import type { ISessions } from '@deepseek-ai/dsh-api-session-controller/client'
|
|
13
14
|
import type { Context as ClientContext } from '../../context-types.ts'
|
|
14
15
|
import type {} from '@deepseek-ai/dsh-client-locale/client'
|
|
@@ -37,6 +38,7 @@ import { PreciseCacheHitEntry } from './cachehit.tsx'
|
|
|
37
38
|
import { installTaskNotifier, previewAlerts, requestNotifyPermission } from './notifier.ts'
|
|
38
39
|
import { HeroProjectLogo, installBranding, ProjectLogoIcon, SidebarProjectLogo, SidebarProjectName } from './branding.tsx'
|
|
39
40
|
import { buildFontCss } from './typography.ts'
|
|
41
|
+
import { uiTweaksArchiveJa } from '../locales-ja.ts'
|
|
40
42
|
|
|
41
43
|
const NS = 'ui-tweaks'
|
|
42
44
|
const SETTINGS_ROUTE = '/_dsh/ui-tweaks/settings'
|
|
@@ -246,8 +248,16 @@ const en = {
|
|
|
246
248
|
archiveEmpty: 'No archived sessions.',
|
|
247
249
|
archiveRestore: 'Restore',
|
|
248
250
|
archiveRestoring: 'Working…',
|
|
251
|
+
archiveConfirmTitle: 'Permanently delete sessions?',
|
|
252
|
+
archiveConfirmDescription: 'Delete {count} session records including owned subagents? This cannot be undone. Independent forks, workspace files and Git data are retained.',
|
|
253
|
+
archiveCancel: 'Cancel',
|
|
249
254
|
archiveDelete: 'Delete',
|
|
250
255
|
archiveDeleteAll: 'Delete all',
|
|
256
|
+
archiveSelectAll: 'Select all',
|
|
257
|
+
archiveSelectedCount: '{count} sessions selected',
|
|
258
|
+
archiveClearSelection: 'Clear selection',
|
|
259
|
+
archiveDeleteSelected: 'Delete selected ({count})',
|
|
260
|
+
archiveDeleteFailed: '{title}: {error}',
|
|
251
261
|
archiveRestoreAll: 'Restore all',
|
|
252
262
|
archiveCount: 'sessions',
|
|
253
263
|
archiveUnavailable: 'Archive unavailable.',
|
|
@@ -347,7 +357,7 @@ const zh: Record<LocaleKey, string> = {
|
|
|
347
357
|
gitBarOn: '开启',
|
|
348
358
|
gitBarOff: '关闭',
|
|
349
359
|
archiveManager: '归档管理',
|
|
350
|
-
archiveManagerHint: '
|
|
360
|
+
archiveManagerHint: '在设置中显示「归档」页面:恢复或永久删除已归档会话。',
|
|
351
361
|
archiveManagerOn: '开启',
|
|
352
362
|
archiveManagerOff: '关闭',
|
|
353
363
|
mcpManager: 'MCP 管理',
|
|
@@ -446,13 +456,21 @@ const zh: Record<LocaleKey, string> = {
|
|
|
446
456
|
archiveEmpty: '暂无归档会话。',
|
|
447
457
|
archiveRestore: '恢复',
|
|
448
458
|
archiveRestoring: '处理中…',
|
|
459
|
+
archiveConfirmTitle: '永久删除会话?',
|
|
460
|
+
archiveConfirmDescription: '将永久删除共 {count} 条会话记录(含所属子代理),无法撤销。独立分叉、工作区文件与 Git 数据保留。',
|
|
461
|
+
archiveCancel: '取消',
|
|
449
462
|
archiveDelete: '删除',
|
|
450
463
|
archiveDeleteAll: '全部删除',
|
|
464
|
+
archiveSelectAll: '全选',
|
|
465
|
+
archiveSelectedCount: '已选择 {count} 个会话',
|
|
466
|
+
archiveClearSelection: '取消选择',
|
|
467
|
+
archiveDeleteSelected: '删除所选({count})',
|
|
468
|
+
archiveDeleteFailed: '「{title}」:{error}',
|
|
451
469
|
archiveRestoreAll: '全部恢复',
|
|
452
470
|
archiveCount: '个会话',
|
|
453
471
|
archiveUnavailable: '归档暂不可用。',
|
|
454
472
|
archiveLiveError: '该会话正在运行,无法彻底删除,请先关闭该会话。',
|
|
455
|
-
archiveDisabledHint: '
|
|
473
|
+
archiveDisabledHint: '归档管理尚未开启。在「界面调整」中开启“归档管理”后,可在此恢复或永久删除已归档会话。',
|
|
456
474
|
archiveEnable: '开启归档管理',
|
|
457
475
|
archiveRestored: '已恢复。',
|
|
458
476
|
defaultAction: '默认',
|
|
@@ -749,12 +767,18 @@ function installBaseStyles(): () => void {
|
|
|
749
767
|
return () => { style.remove() }
|
|
750
768
|
}
|
|
751
769
|
|
|
770
|
+
class SettingsRequestError extends Error {
|
|
771
|
+
constructor(readonly code: string, message: string) {
|
|
772
|
+
super(message)
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
|
|
752
776
|
async function apiRequest<T>(init?: RequestInit): Promise<T> {
|
|
753
777
|
const response = await fetch(SETTINGS_ROUTE, { credentials: 'same-origin', ...init })
|
|
754
778
|
const body = await response.json() as ApiSuccess<T> | ApiFailure
|
|
755
779
|
if (!response.ok || !body.ok) {
|
|
756
780
|
const failure = body as ApiFailure
|
|
757
|
-
throw new
|
|
781
|
+
throw new SettingsRequestError(failure.error?.code ?? 'request-failed', failure.error?.message ?? `UI Tweaks request failed with HTTP ${response.status}`)
|
|
758
782
|
}
|
|
759
783
|
return body.value
|
|
760
784
|
}
|
|
@@ -773,6 +797,7 @@ export class SettingsClient {
|
|
|
773
797
|
private state: SettingsState = { status: 'loading', writable: false, value: undefined, revision: undefined }
|
|
774
798
|
private listeners = new Set<() => void>()
|
|
775
799
|
private generation = 0
|
|
800
|
+
private writes: Promise<void> = Promise.resolve()
|
|
776
801
|
|
|
777
802
|
subscribe = (listener: () => void): (() => void) => {
|
|
778
803
|
this.listeners.add(listener)
|
|
@@ -804,33 +829,48 @@ export class SettingsClient {
|
|
|
804
829
|
}
|
|
805
830
|
}
|
|
806
831
|
|
|
807
|
-
private
|
|
808
|
-
const
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
832
|
+
private post(payload: () => Record<string, unknown>): Promise<void> {
|
|
833
|
+
const write = this.writes.then(async () => {
|
|
834
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
835
|
+
++this.generation
|
|
836
|
+
try {
|
|
837
|
+
const snapshot = await apiRequest<UITweaksSnapshot>({
|
|
838
|
+
method: 'POST',
|
|
839
|
+
headers: { 'Content-Type': 'application/json' },
|
|
840
|
+
body: JSON.stringify({ ...payload(), expectedRevision: this.state.revision ?? 0 }),
|
|
841
|
+
})
|
|
842
|
+
++this.generation
|
|
843
|
+
this.publish({ status: 'ready', writable: snapshot.writable, value: snapshot.value, revision: snapshot.revision })
|
|
844
|
+
return
|
|
845
|
+
} catch (error) {
|
|
846
|
+
if (!(error instanceof SettingsRequestError) || error.code !== 'settings-conflict' || attempt > 0) throw error
|
|
847
|
+
await this.load()
|
|
848
|
+
if (this.state.status !== 'ready') throw new Error(this.state.error ?? 'UI Tweaks settings could not be refreshed')
|
|
849
|
+
}
|
|
850
|
+
}
|
|
820
851
|
})
|
|
852
|
+
this.writes = write.catch(() => {})
|
|
853
|
+
return write
|
|
821
854
|
}
|
|
822
855
|
|
|
823
856
|
async set(field: string, value: unknown): Promise<void> {
|
|
824
|
-
await this.post({ action: 'set', field, value
|
|
857
|
+
await this.post(() => ({ action: 'set', field, value }))
|
|
825
858
|
}
|
|
826
859
|
|
|
827
860
|
async unset(field: string): Promise<void> {
|
|
828
|
-
await this.post({ action: 'unset', field
|
|
861
|
+
await this.post(() => ({ action: 'unset', field }))
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
async step(field: 'fontSize' | 'lineHeight' | 'codeFontSize', delta: number, minimum: number, maximum: number): Promise<void> {
|
|
865
|
+
await this.post(() => ({
|
|
866
|
+
action: 'set', field,
|
|
867
|
+
value: Math.min(maximum, Math.max(minimum, resolveValue(this.state.value)[field] + delta)),
|
|
868
|
+
}))
|
|
829
869
|
}
|
|
830
870
|
}
|
|
831
871
|
|
|
832
872
|
/** Required client services: slots (settings.section), locale, sessions (git bar, whale, archive, notifier), the slash-command registry, and the scope-addressed conversation face. */
|
|
833
|
-
export const inject = ['slots', 'locale', 'sessions', 'commandUi', 'conversation']
|
|
873
|
+
export const inject = ['slots', 'locale', 'sessions', 'uiSession', 'uiWorkspace', 'commandUi', 'conversation']
|
|
834
874
|
|
|
835
875
|
/**
|
|
836
876
|
* Hover/focus hint: a small ⓘ next to the field label; the hint text renders
|
|
@@ -933,19 +973,19 @@ function SettingsSection({ controller, t }: SettingsSectionProps) {
|
|
|
933
973
|
const stepFontSize = (delta: number): void => {
|
|
934
974
|
const next = Math.min(MAX_FONT_SIZE, Math.max(MIN_FONT_SIZE, resolved.fontSize + delta))
|
|
935
975
|
setDraft(String(next))
|
|
936
|
-
void controller.
|
|
976
|
+
void controller.step('fontSize', delta, MIN_FONT_SIZE, MAX_FONT_SIZE).then(() => { setStatus('applied') }).catch(() => { setStatus('unavailable') })
|
|
937
977
|
}
|
|
938
978
|
|
|
939
979
|
const stepLineHeight = (delta: number): void => {
|
|
940
980
|
const next = Math.min(MAX_LINE_HEIGHT, Math.max(MIN_LINE_HEIGHT, resolved.lineHeight + delta))
|
|
941
981
|
setLineHeightDraft(String(next))
|
|
942
|
-
void controller.
|
|
982
|
+
void controller.step('lineHeight', delta, MIN_LINE_HEIGHT, MAX_LINE_HEIGHT).then(() => { setStatus('applied') }).catch(() => { setStatus('unavailable') })
|
|
943
983
|
}
|
|
944
984
|
|
|
945
985
|
const stepCodeSize = (delta: number): void => {
|
|
946
986
|
const next = Math.min(MAX_CODE_FONT_SIZE, Math.max(MIN_CODE_FONT_SIZE, resolved.codeFontSize + delta))
|
|
947
987
|
setCodeDraft(String(next))
|
|
948
|
-
void controller.
|
|
988
|
+
void controller.step('codeFontSize', delta, MIN_CODE_FONT_SIZE, MAX_CODE_FONT_SIZE).then(() => { setStatus('applied') }).catch(() => { setStatus('unavailable') })
|
|
949
989
|
}
|
|
950
990
|
|
|
951
991
|
const setGitBar = (value: boolean): void => {
|
|
@@ -1325,7 +1365,7 @@ function registerInitCommand(ctx: UITweaksClientContext): () => void {
|
|
|
1325
1365
|
const t = ctx.locale.bind(NS)
|
|
1326
1366
|
return ctx.commandUi.register({
|
|
1327
1367
|
name: 'init',
|
|
1328
|
-
description: t('initDesc'),
|
|
1368
|
+
description: () => t('initDesc'),
|
|
1329
1369
|
available: () => true,
|
|
1330
1370
|
ui: {
|
|
1331
1371
|
kind: 'popupSelect',
|
|
@@ -1395,6 +1435,7 @@ export function apply(ctx: UITweaksClientContext): void {
|
|
|
1395
1435
|
ctx.effect(installArchiveStyles, 'dsh-ui-tweaks: archive styles')
|
|
1396
1436
|
ctx.effect(installMcpStyles, 'dsh-ui-tweaks: mcp styles')
|
|
1397
1437
|
ctx.effect(() => ctx.locale.register(NS, { en, zh }), 'dsh-ui-tweaks: locale')
|
|
1438
|
+
ctx.effect(() => ctx.locale.register(NS, 'ja', uiTweaksArchiveJa), 'dsh-ui-tweaks: archive Japanese locale')
|
|
1398
1439
|
const t = ctx.locale.bind(NS)
|
|
1399
1440
|
|
|
1400
1441
|
const controller = new SettingsClient()
|
|
@@ -1482,7 +1523,7 @@ export function apply(ctx: UITweaksClientContext): void {
|
|
|
1482
1523
|
ctx.effect(() => installHeroChip(controller, t), 'dsh-ui-tweaks: hero branch chip')
|
|
1483
1524
|
|
|
1484
1525
|
// Archive manager: a Settings section ("归档") that lists archived sessions
|
|
1485
|
-
// and
|
|
1526
|
+
// and uses the shared Host operations to restore or delete them. Registered only while the
|
|
1486
1527
|
// archiveManagerEnabled toggle in the UI Tweaks section is on, so the nav
|
|
1487
1528
|
// row appears / disappears live with the switch (the settings shell
|
|
1488
1529
|
// projects its nav from the section ledger).
|
|
@@ -1492,7 +1533,23 @@ export function apply(ctx: UITweaksClientContext): void {
|
|
|
1492
1533
|
order: 50,
|
|
1493
1534
|
label: () => t('archiveNav'),
|
|
1494
1535
|
locale: NS,
|
|
1495
|
-
inject: () => ({ controller, t,
|
|
1536
|
+
inject: () => ({ controller, t,
|
|
1537
|
+
restoreSession: async (id: string) => {
|
|
1538
|
+
const service = ctx.workspaces as typeof ctx.workspaces & { unarchiveSession?: (id: SessionId) => Promise<void> }
|
|
1539
|
+
if (service.unarchiveSession === undefined) throw new Error(t('archiveUnavailable'))
|
|
1540
|
+
await service.unarchiveSession(id as SessionId)
|
|
1541
|
+
},
|
|
1542
|
+
previewDeletion: async (id: string) => {
|
|
1543
|
+
const service = ctx.workspaces as typeof ctx.workspaces & { sessionDeletionScope?: (id: SessionId) => Promise<readonly SessionId[]> }
|
|
1544
|
+
if (service.sessionDeletionScope === undefined) throw new Error(t('archiveUnavailable'))
|
|
1545
|
+
return service.sessionDeletionScope(id as SessionId)
|
|
1546
|
+
},
|
|
1547
|
+
deleteSession: async (id: string, scope: readonly string[]) => {
|
|
1548
|
+
const service = ctx.workspaces as typeof ctx.workspaces & { deleteSession?: (id: SessionId, scope: readonly SessionId[]) => Promise<readonly SessionId[]> }
|
|
1549
|
+
if (service.deleteSession === undefined) throw new Error(t('archiveUnavailable'))
|
|
1550
|
+
await service.deleteSession(id as SessionId, scope as readonly SessionId[])
|
|
1551
|
+
},
|
|
1552
|
+
}),
|
|
1496
1553
|
}, ArchiveSection))
|
|
1497
1554
|
|
|
1498
1555
|
// MCP manager: a Settings section ("MCP 管理") that lists the configured MCP
|
|
@@ -1593,7 +1650,8 @@ export function apply(ctx: UITweaksClientContext): void {
|
|
|
1593
1650
|
if (enabled && disposeNotifier === undefined) {
|
|
1594
1651
|
disposeNotifier = installTaskNotifier({
|
|
1595
1652
|
sessionsService: ctx.sessions,
|
|
1596
|
-
|
|
1653
|
+
sessionStatus: ctx.uiSession.sessionStatus,
|
|
1654
|
+
openSession: id => ctx.uiWorkspace.openSession(id),
|
|
1597
1655
|
text: {
|
|
1598
1656
|
notifyTitleDone: t('notifyTitleDone'),
|
|
1599
1657
|
notifyTitleAborted: t('notifyTitleAborted'),
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
*/
|
|
41
41
|
|
|
42
42
|
import type { ISessions } from '@deepseek-ai/dsh-api-session-controller/client'
|
|
43
|
-
import type {
|
|
43
|
+
import type { SessionStatusSnapshot } from '@deepseek-ai/dsh-client-ui-session/client'
|
|
44
44
|
import type { HostObservable } from '@deepseek-ai/dsh-client-ui-slots'
|
|
45
45
|
import type { SessionId } from '@deepseek-ai/dsh-session/types'
|
|
46
46
|
import type { TurnOutcomeValue } from '../../ui-tweaks/turn-outcome.ts'
|
|
@@ -112,7 +112,8 @@ export interface TaskNotifierInput {
|
|
|
112
112
|
/** The client sessions service whose list feed carries the watch states. */
|
|
113
113
|
sessionsService: ISessions
|
|
114
114
|
/** Current Session-scoped interactions, published separately from list rows. */
|
|
115
|
-
|
|
115
|
+
sessionStatus: HostObservable<SessionStatusSnapshot>
|
|
116
|
+
openSession(sessionId: SessionId): void
|
|
116
117
|
/** Localized copy snapshot used across the notifier's lifetime. */
|
|
117
118
|
text: NotifierText
|
|
118
119
|
/** Fresh behavior switches + channel toggles, read on every tick. */
|
|
@@ -129,10 +130,10 @@ interface WatchState {
|
|
|
129
130
|
|
|
130
131
|
/** Narrow the extensible host interaction roster to the notification copy we own. */
|
|
131
132
|
function pendingKind(
|
|
132
|
-
snapshot:
|
|
133
|
+
snapshot: SessionStatusSnapshot,
|
|
133
134
|
sessionId: SessionId,
|
|
134
135
|
): NotifyPendingKind | undefined {
|
|
135
|
-
switch (snapshot.get(sessionId)?.kind) {
|
|
136
|
+
switch (snapshot.get(sessionId)?.pendingInteraction?.kind) {
|
|
136
137
|
case 'approval':
|
|
137
138
|
return 'approval'
|
|
138
139
|
case 'plan-review':
|
|
@@ -296,7 +297,7 @@ function playChime(shape: 'up' | 'down'): void {
|
|
|
296
297
|
* @returns disposer — unsubscribes, restores the tab title and tears the channels down.
|
|
297
298
|
*/
|
|
298
299
|
export function installTaskNotifier(input: TaskNotifierInput): () => void {
|
|
299
|
-
const { sessionsService,
|
|
300
|
+
const { sessionsService, sessionStatus, openSession, text, readState } = input
|
|
300
301
|
const list = sessionsService.list
|
|
301
302
|
|
|
302
303
|
// --- detector state ------------------------------------------------------
|
|
@@ -366,7 +367,7 @@ export function installTaskNotifier(input: TaskNotifierInput): () => void {
|
|
|
366
367
|
const n = new Notification(heading, options)
|
|
367
368
|
n.onclick = (): void => {
|
|
368
369
|
try { window.focus() } catch { /* ignore */ }
|
|
369
|
-
try {
|
|
370
|
+
try { openSession(sessionId) } catch { /* session already gone — focus alone is fine */ }
|
|
370
371
|
n.close()
|
|
371
372
|
}
|
|
372
373
|
} catch {
|
|
@@ -420,14 +421,14 @@ export function installTaskNotifier(input: TaskNotifierInput): () => void {
|
|
|
420
421
|
/** Seed the watch map without firing: fresh installs and reloads stay quiet. */
|
|
421
422
|
const armBaseline = (): void => {
|
|
422
423
|
watch.clear()
|
|
423
|
-
const interactions =
|
|
424
|
+
const interactions = sessionStatus.getSnapshot()
|
|
424
425
|
for (const row of Object.values(list.getSnapshot().byId)) {
|
|
425
426
|
if (row.parentId !== undefined || row.blank) continue
|
|
426
427
|
const outcome = row.projectionValues?.[TURN_OUTCOME_KEY] ?? undefined
|
|
427
428
|
watch.set(row.id, {
|
|
428
429
|
running: row.running,
|
|
429
430
|
pending: pendingKind(interactions, row.id),
|
|
430
|
-
completed: row.
|
|
431
|
+
completed: interactions.get(row.id)?.completionUnread === true,
|
|
431
432
|
outcome,
|
|
432
433
|
})
|
|
433
434
|
}
|
|
@@ -439,7 +440,7 @@ export function installTaskNotifier(input: TaskNotifierInput): () => void {
|
|
|
439
440
|
const deliverable = !options.onlyWhenHidden || !visibleAndFocused()
|
|
440
441
|
const now = Date.now()
|
|
441
442
|
const snap = list.getSnapshot()
|
|
442
|
-
const interactions =
|
|
443
|
+
const interactions = sessionStatus.getSnapshot()
|
|
443
444
|
const seen = new Set<SessionId>()
|
|
444
445
|
|
|
445
446
|
for (const row of Object.values(snap.byId)) {
|
|
@@ -448,7 +449,7 @@ export function installTaskNotifier(input: TaskNotifierInput): () => void {
|
|
|
448
449
|
const prev = watch.get(row.id)
|
|
449
450
|
const outcome = row.projectionValues?.[TURN_OUTCOME_KEY] ?? undefined
|
|
450
451
|
const pending = pendingKind(interactions, row.id)
|
|
451
|
-
watch.set(row.id, { running: row.running, pending, completed: row.
|
|
452
|
+
watch.set(row.id, { running: row.running, pending, completed: interactions.get(row.id)?.completionUnread === true, outcome })
|
|
452
453
|
if (prev === undefined) continue
|
|
453
454
|
|
|
454
455
|
// Interaction outranks completion: a turn ending ON a question must
|
|
@@ -461,7 +462,7 @@ export function installTaskNotifier(input: TaskNotifierInput): () => void {
|
|
|
461
462
|
}
|
|
462
463
|
|
|
463
464
|
const finished = prev.running && !row.running && pending === undefined
|
|
464
|
-
const completedReminder = !prev.completed && row.
|
|
465
|
+
const completedReminder = !prev.completed && interactions.get(row.id)?.completionUnread === true
|
|
465
466
|
if (finished || completedReminder) {
|
|
466
467
|
// The green `completed` reminder often arrives a re-pull AFTER the
|
|
467
468
|
// running-drop already announced the same finish — inside the
|
|
@@ -496,7 +497,7 @@ export function installTaskNotifier(input: TaskNotifierInput): () => void {
|
|
|
496
497
|
|
|
497
498
|
armBaseline()
|
|
498
499
|
const disposeFeed = list.subscribe(check)
|
|
499
|
-
const disposeInteractions =
|
|
500
|
+
const disposeInteractions = sessionStatus.subscribe(check)
|
|
500
501
|
|
|
501
502
|
return () => {
|
|
502
503
|
disposeFeed()
|
|
@@ -134,7 +134,7 @@ export function WhaleIndicator({ sessionId, input, sessionsService }: WhaleIndic
|
|
|
134
134
|
subscribe,
|
|
135
135
|
() => {
|
|
136
136
|
const snapshot = list.getSnapshot()
|
|
137
|
-
const id = sessionId
|
|
137
|
+
const id = sessionId
|
|
138
138
|
return id !== undefined && (snapshot.byId[id]?.running ?? false)
|
|
139
139
|
},
|
|
140
140
|
() => false,
|
|
@@ -53,8 +53,17 @@ export function useChatcodeAccount() {
|
|
|
53
53
|
}
|
|
54
54
|
void refresh()
|
|
55
55
|
const visible = (): void => { if (document.visibilityState === 'visible') void refresh() }
|
|
56
|
+
const refreshNow = (): void => { void refresh() }
|
|
56
57
|
document.addEventListener('visibilitychange', visible)
|
|
57
|
-
|
|
58
|
+
window.addEventListener('focus', refreshNow)
|
|
59
|
+
window.addEventListener('online', refreshNow)
|
|
60
|
+
return () => {
|
|
61
|
+
controller.abort()
|
|
62
|
+
clearTimeout(timer)
|
|
63
|
+
document.removeEventListener('visibilitychange', visible)
|
|
64
|
+
window.removeEventListener('focus', refreshNow)
|
|
65
|
+
window.removeEventListener('online', refreshNow)
|
|
66
|
+
}
|
|
58
67
|
}, [revision])
|
|
59
68
|
|
|
60
69
|
const operate = (action: () => Promise<void>): void => {
|
|
@@ -99,5 +108,6 @@ export function useChatcodeAccount() {
|
|
|
99
108
|
const sessionId = chatcode?.login?.sessionId
|
|
100
109
|
if (sessionId) operate(async () => { await api.chatcodeCancel(sessionId) })
|
|
101
110
|
}
|
|
102
|
-
|
|
111
|
+
const refresh = (): void => { setRevision(value => value + 1) }
|
|
112
|
+
return { chatcode, busy, error, loginUrl, startLogin, logout, cancelLogin, refresh }
|
|
103
113
|
}
|
package/src/index.ts
CHANGED
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
import { registerTools } from './tools.ts'
|
|
52
52
|
import { AgentOpenRegistry, registerOpenTool, type AgentOpenRequest } from './agent-opens.ts'
|
|
53
53
|
import { CodingPlanCatalogue } from './codingplan.ts'
|
|
54
|
-
import { checkOneUpdate, CHATCODE_UPDATE_PACKAGES, performAllUpdates } from './chatcode-update.ts'
|
|
54
|
+
import { checkOneUpdate, CHATCODE_CLI_PKG, CHATCODE_UPDATE_PACKAGES, installedGlobalVersion, performAllUpdates } from './chatcode-update.ts'
|
|
55
55
|
import { readJsonBody, requireString, SidebarError, writeError, writeJson, writeOk } from './wire.ts'
|
|
56
56
|
import { apply as applyUiTweaksHost } from './ui-tweaks/index.ts'
|
|
57
57
|
import { buildPluginMarketApi } from './plugin-market-api.ts'
|
|
@@ -78,7 +78,7 @@ export type {
|
|
|
78
78
|
export const name = 'dsh-better-sidebar'
|
|
79
79
|
|
|
80
80
|
/** Services required before mounting: the webserver routes, the session store, the web runtime's trusted hosts, and the tool registry. */
|
|
81
|
-
export const inject = ['webServer', 'sessions', '
|
|
81
|
+
export const inject = ['webServer', 'sessions', 'connection', 'tools', 'settings']
|
|
82
82
|
|
|
83
83
|
/** Content types for the media route, by extension. */
|
|
84
84
|
const MEDIA_TYPES: Record<string, string> = {
|
|
@@ -664,6 +664,9 @@ function buildApi(
|
|
|
664
664
|
'chatcode.start': () => requireChatcodeAuth().startLogin(),
|
|
665
665
|
'chatcode.cancel': payload => requireChatcodeAuth().cancelLogin(requireString(payload, 'sessionId')).then(() => ({ ok: true })),
|
|
666
666
|
'chatcode.logout': () => requireChatcodeAuth().logout().then(() => ({ ok: true })),
|
|
667
|
+
// The globally installed CLI version the sidebar shows beside its wordmark.
|
|
668
|
+
// Reads npm global modules directly (no registry network like chatcode.update.check).
|
|
669
|
+
'chatcode.installed-version': async () => ({ version: await installedGlobalVersion(CHATCODE_CLI_PKG) }),
|
|
667
670
|
// Check both ChatCode packages (web runtime + CLI) against the npm
|
|
668
671
|
// registry and the globally installed version. Runs on the DSH host; a
|
|
669
672
|
// package not globally installed degrades to `current: null`.
|
|
@@ -850,7 +853,11 @@ export function apply(ctx: Context, config?: SidebarConfig): void {
|
|
|
850
853
|
// plus --trusted-host authorities) — the authoritative source the /api
|
|
851
854
|
// gateway fence derives its list from. Read per request from the live
|
|
852
855
|
// service value; a replaced list takes effect without a plugin restart.
|
|
853
|
-
const fence = (req: SidebarHttpRequest): boolean =>
|
|
856
|
+
const fence = (req: SidebarHttpRequest): boolean => {
|
|
857
|
+
const connection = ctx.get('connection') as { requestRejection?(request: SidebarHttpRequest): number | undefined } | undefined
|
|
858
|
+
if (typeof connection?.requestRejection === 'function') return connection.requestRejection(req) === undefined
|
|
859
|
+
return ctx.webRuntime !== undefined && isTrustedApiRequest(req, ctx.webRuntime.trustedHosts)
|
|
860
|
+
}
|
|
854
861
|
// node-pty is loaded lazily, never at module top level (issue #140): a
|
|
855
862
|
// missing or broken install must degrade THIS plugin — terminal tab shows
|
|
856
863
|
// a repair command, agent terminal tools stay unregistered — instead of
|
package/src/ui-tweaks/config.ts
CHANGED
|
@@ -53,7 +53,7 @@ export interface UITweaksConfig {
|
|
|
53
53
|
gitBarEnabled?: boolean
|
|
54
54
|
/**
|
|
55
55
|
* Whether the Archive manager is shown: the "归档" Settings page that lists
|
|
56
|
-
* archived sessions and can restore or
|
|
56
|
+
* archived sessions and can restore or confirm permanent deletion through the shared Host. Off by
|
|
57
57
|
* default; users turn it on in Settings.
|
|
58
58
|
*/
|
|
59
59
|
archiveManagerEnabled?: boolean
|
package/src/ui-tweaks/git.ts
CHANGED
|
@@ -987,7 +987,7 @@ export class GitBackend {
|
|
|
987
987
|
}
|
|
988
988
|
}
|
|
989
989
|
try {
|
|
990
|
-
const stored = this.ctx.settings?.
|
|
990
|
+
const stored = this.ctx.settings?.describe().find(item => item.ns === AGENT_DEFAULT_MODEL_NAMESPACE)?.value as { provider?: string; model?: string } | undefined
|
|
991
991
|
const provider = stored?.provider
|
|
992
992
|
const model = stored?.model
|
|
993
993
|
if (typeof provider === 'string' && provider !== '' && typeof model === 'string' && model !== ''
|
|
@@ -25,7 +25,7 @@ import type { ZodType } from 'zod'
|
|
|
25
25
|
export const TURN_OUTCOME_PROJECTION_KEY = 'dshTurnOutcome'
|
|
26
26
|
|
|
27
27
|
/** The stock `TurnEndReason` kinds (the map is merge-extensible upstream). */
|
|
28
|
-
export type TurnOutcomeKind = 'completed' | 'aborted' | 'blocked' | 'error' | 'max-tokens' | 'interrupted'
|
|
28
|
+
export type TurnOutcomeKind = 'completed' | 'aborted' | 'blocked' | 'error' | 'max-tokens' | 'interrupted' | 'forked'
|
|
29
29
|
|
|
30
30
|
/** Whole projection value: why the latest turn ended. */
|
|
31
31
|
export interface TurnOutcomeValue {
|
|
@@ -99,7 +99,7 @@ export const turnOutcomeProjectionDefinition: TurnOutcomeProjectionUnit = {
|
|
|
99
99
|
* @param ctx - plugin context owning the registration effect.
|
|
100
100
|
*/
|
|
101
101
|
export function installTurnOutcomeProjection(ctx: Context): void {
|
|
102
|
-
ctx.inject(['sessionProjections'], (projectionCtx) => {
|
|
103
|
-
projectionCtx.sessionProjections.register(turnOutcomeProjectionDefinition)
|
|
102
|
+
ctx.inject(['sessionProjections'], async (projectionCtx) => {
|
|
103
|
+
await projectionCtx.sessionProjections.register(turnOutcomeProjectionDefinition)
|
|
104
104
|
})
|
|
105
105
|
}
|
package/src/ui-tweaks/web.ts
CHANGED
|
@@ -188,6 +188,7 @@ export class UITweaksWebBackend {
|
|
|
188
188
|
json(res, 200, { ok: true, value: this.snapshot() })
|
|
189
189
|
} catch (error) {
|
|
190
190
|
const conflict = error instanceof SettingsConflictError
|
|
191
|
+
|| (error instanceof Error && Reflect.get(error, 'code') === 'SETTINGS_CONFLICT')
|
|
191
192
|
requestError(
|
|
192
193
|
res,
|
|
193
194
|
conflict ? 409 : 400,
|