@chatcode/cco-better-sidebar 0.18.0-rc.12 → 0.18.0-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.
@@ -16,6 +16,7 @@ import { createBetterSidebarService, matchUrlTarget, SIDEBAR_SERVICE_VERSION } f
16
16
  import { revalidateChunksOnReactivate, setChunkModuleSystem } from './chunk-loader.ts'
17
17
  import { registerBuiltins } from './builtins/index.ts'
18
18
  import { Sidebar } from './Sidebar.tsx'
19
+ import { AccountMenu } from './AccountMenu.tsx'
19
20
  import { ChatcodeGate } from './ChatcodeGate.tsx'
20
21
  import { hasPriorSidebarInstall, ReleaseNotesDialog } from './ReleaseNotesDialog.tsx'
21
22
  import { RenderBoundary } from './RenderBoundary.tsx'
@@ -26,7 +27,7 @@ import {
26
27
  AI_RATIO_NAV_MARKER,
27
28
  GENERAL_NAV_MARKER,
28
29
  PLUGIN_MARKET_NAV_MARKER,
29
- registerSettingsNavIcon,
30
+ SETTINGS_NAV_MARKER,
30
31
  SKILL_MARKET_NAV_MARKER,
31
32
  UI_TWEAKS_NAV_MARKER,
32
33
  UPDATE_NAV_MARKER,
@@ -143,6 +144,10 @@ export function apply(ctx: Context): void {
143
144
  // then hands it to the mounted panel and closes over it in the slot
144
145
  // registrations (the official createXXXStore() factory rule — no
145
146
  // module-level singleton).
147
+ ctx.slots.inject('settings.launcher', () => ctx.slots.register({
148
+ name: 'settings.launcher', priority: -10,
149
+ }, AccountMenu))
150
+
146
151
  const sidebarStore = createSidebarStore()
147
152
  const pluginMarketCatalog = createPluginMarketCatalog()
148
153
  ctx.effect(() => {
@@ -448,45 +453,18 @@ export function apply(ctx: Context): void {
448
453
  'dsh-better-sidebar: IME composition guard',
449
454
  )
450
455
 
451
- // DSH 0.1.x does not yet carry an icon through the settings.section
452
- // registration contract: its shell renders a generic gear for every
453
- // external section. Mark only this plugin's localized nav row so
454
- // layout.css can paint the requested Side card SVG; the disposer clears
455
- // the marker for HMR / plugin disable.
456
- ctx.effect(
457
- () => registerSettingsNavIcon(() => t('settingsNav')),
458
- 'dsh-better-sidebar: settings navigation icon',
459
- )
460
- // Same adaptation for the "Token 用量" heatmap row, under its own marker
461
- // so the two registrations never strip each other's rows.
462
- ctx.effect(
463
- () => registerSettingsNavIcon(() => t('usageNav'), USAGE_NAV_MARKER),
464
- 'dsh-better-sidebar: usage settings navigation icon',
465
- )
466
- ctx.effect(
467
- () => registerSettingsNavIcon(() => t('aiRatioNav'), AI_RATIO_NAV_MARKER),
468
- 'dsh-better-sidebar: AI ratio settings navigation icon',
469
- )
470
- ctx.effect(
471
- () => registerSettingsNavIcon(() => t('updateNav'), UPDATE_NAV_MARKER),
472
- 'dsh-better-sidebar: update settings navigation icon',
473
- )
474
- ctx.effect(
475
- () => registerSettingsNavIcon(() => ['通用设置', 'General'], GENERAL_NAV_MARKER),
476
- 'dsh-better-sidebar: general settings navigation icon fallback',
477
- )
478
- ctx.effect(
479
- () => registerSettingsNavIcon(() => ['插件市场', 'Plugin marketplace', 'Plugin Market'], PLUGIN_MARKET_NAV_MARKER),
480
- 'dsh-better-sidebar: plugin market navigation icon fallback',
481
- )
482
- ctx.effect(
483
- () => registerSettingsNavIcon(() => ['界面调整', 'UI Tweaks'], UI_TWEAKS_NAV_MARKER),
484
- 'dsh-better-sidebar: UI tweaks navigation icon fallback',
485
- )
486
- ctx.effect(
487
- () => registerSettingsNavIcon(() => ['技能市场', 'Skill marketplace', 'Skill Market'], SKILL_MARKET_NAV_MARKER),
488
- 'dsh-better-sidebar: skill market navigation icon fallback',
489
- )
456
+ // The host owns navigation geometry; icons use the public section seat.
457
+ for (const [id, marker] of [
458
+ ['better-sidebar', SETTINGS_NAV_MARKER], ['better-sidebar-usage', USAGE_NAV_MARKER],
459
+ ['better-sidebar-ai-ratio', AI_RATIO_NAV_MARKER], ['better-sidebar-update', UPDATE_NAV_MARKER],
460
+ ['general', GENERAL_NAV_MARKER], ['market', PLUGIN_MARKET_NAV_MARKER],
461
+ ['ui-tweaks', UI_TWEAKS_NAV_MARKER], ['skill-market', SKILL_MARKET_NAV_MARKER],
462
+ ] as const) {
463
+ ctx.slots.inject('settings.section.icon', () => ctx.slots.register({
464
+ name: 'settings.section.icon', id, priority: -10,
465
+ }, () => createElement('span', { [marker]: '', 'aria-hidden': true,
466
+ style: { display: 'flex', width: 16, height: 16, flex: 'none' } })))
467
+ }
490
468
 
491
469
  registerPluginMarketSettings(ctx, pluginMarketCatalog)
492
470
 
@@ -472,7 +472,7 @@ export function matchUrlTarget(tabs: readonly TabDescriptor[], url: URL): TabDes
472
472
  * The plugin version this service instance reports. Keep in lockstep with
473
473
  * `package.json`'s version — `tests/service.spec.ts` asserts the pair.
474
474
  */
475
- export const SIDEBAR_SERVICE_VERSION = '0.18.0-alpha.4'
475
+ export const SIDEBAR_SERVICE_VERSION = '0.18.0-rc.13.022-rc1'
476
476
 
477
477
  /**
478
478
  * Monotonic capability list consumers use to gate new API usage (features
@@ -52,7 +52,7 @@ export interface ShellPreset {
52
52
  */
53
53
  const DSH_DESKTOP: ShellPreset = {
54
54
  id: 'dsh-desktop',
55
- title: 'DeepSeek Harness Desktop',
55
+ title: 'ChatCode CLI Desktop',
56
56
  desc: 'Electron 高级模式(无边框):macOS 顶栏 20px、Windows 无 WCO 时 32px 标题栏让位',
57
57
  stripFor: (env) => {
58
58
  if (env.mode !== 'advanced') return undefined
@@ -470,11 +470,12 @@
470
470
  flex: none;
471
471
  place-items: center;
472
472
  border-radius: 50%;
473
- background: var(--dsw-alias-bg-layer-3);
473
+ corner-shape: round;
474
+ background: var(--dsw-alias-bg-layer-2);
474
475
  border: 1px solid var(--dsw-alias-border-l2);
475
- color: var(--dsw-alias-fg-accent);
476
+ color: var(--dsw-alias-fg-base);
476
477
  font: var(--dsw-font-xxs-12);
477
- font-weight: 600;
478
+ font-weight: 400;
478
479
  }
479
480
 
480
481
  .accountName {
@@ -543,7 +544,7 @@
543
544
  }
544
545
 
545
546
  .accountTrigger .accountPresence {
546
- border-color: var(--dsw-alias-bg-layer-1);
547
+ display: none;
547
548
  }
548
549
 
549
550
  /* The native top layer is viewport-centered even though the account rail is positioned. */
@@ -3365,8 +3366,7 @@ body[data-dsh-sidebar-dragging] .bottomPanel {
3365
3366
 
3366
3367
  /* The file tree "open with" menu rows: the label area is a BLOCK-level flex
3367
3368
  row that fills the primitives `.itemLabel` span (which is itself `flex: 1`
3368
- inside the row), so the trailing control — the pushpin on submenu rows,
3369
- the chevron on the submenu parent — docks at the row's far right, exactly
3369
+ inside the row), so the pushpin on submenu rows docks at the far right, exactly
3370
3370
  like the trailing check on selected rows of every other menu. */
3371
3371
  .openWithLabel {
3372
3372
  display: flex;
@@ -3384,13 +3384,6 @@ body[data-dsh-sidebar-dragging] .bottomPanel {
3384
3384
  white-space: nowrap;
3385
3385
  }
3386
3386
 
3387
- /* The trailing "expands into a submenu" chevron on the open-with parent row
3388
- (the primitives Menu renders no arrow for submenu parents). */
3389
- .openWithChevron {
3390
- flex: none;
3391
- color: var(--dsw-alias-label-tertiary);
3392
- }
3393
-
3394
3387
  /* The pushpin toggle on an "open with" submenu row: brand ink once the
3395
3388
  target is pinned to the menu's top level. */
3396
3389
  .openWithPin {
@@ -3667,3 +3660,20 @@ body[data-dsh-sidebar-dragging] .bottomPanel {
3667
3660
  .chatcodeGateActions { align-items: stretch; flex-direction: column; }
3668
3661
  .chatcodeGateActions button, .chatcodeGateCard a { justify-content: center; }
3669
3662
  }
3663
+
3664
+ /* Native settings seat owns the rail geometry and the Settings callback. */
3665
+ .accountMenu[data-settings-launcher] {
3666
+ position: relative;
3667
+ width: 100%;
3668
+ border: 0;
3669
+ }
3670
+ .accountMenu[data-settings-launcher]:not([data-rail]) {
3671
+ /* Continue through the rail's side inset, 6px bottom padding and 4px launcher margin. */
3672
+ width: calc(100% + 2 * var(--dsh-sidebar-inline-padding, 8px));
3673
+ margin-inline: calc(-1 * var(--dsh-sidebar-inline-padding, 8px));
3674
+ margin-bottom: -10px;
3675
+ border-top: 1px solid var(--dsw-alias-border-l2);
3676
+ }
3677
+ .accountMenu[data-settings-launcher][data-rail] .accountName {
3678
+ display: none;
3679
+ }
@@ -767,12 +767,18 @@ function installBaseStyles(): () => void {
767
767
  return () => { style.remove() }
768
768
  }
769
769
 
770
+ class SettingsRequestError extends Error {
771
+ constructor(readonly code: string, message: string) {
772
+ super(message)
773
+ }
774
+ }
775
+
770
776
  async function apiRequest<T>(init?: RequestInit): Promise<T> {
771
777
  const response = await fetch(SETTINGS_ROUTE, { credentials: 'same-origin', ...init })
772
778
  const body = await response.json() as ApiSuccess<T> | ApiFailure
773
779
  if (!response.ok || !body.ok) {
774
780
  const failure = body as ApiFailure
775
- throw new Error(failure.error?.message ?? `UI Tweaks request failed with HTTP ${response.status}`)
781
+ throw new SettingsRequestError(failure.error?.code ?? 'request-failed', failure.error?.message ?? `UI Tweaks request failed with HTTP ${response.status}`)
776
782
  }
777
783
  return body.value
778
784
  }
@@ -791,6 +797,7 @@ export class SettingsClient {
791
797
  private state: SettingsState = { status: 'loading', writable: false, value: undefined, revision: undefined }
792
798
  private listeners = new Set<() => void>()
793
799
  private generation = 0
800
+ private writes: Promise<void> = Promise.resolve()
794
801
 
795
802
  subscribe = (listener: () => void): (() => void) => {
796
803
  this.listeners.add(listener)
@@ -822,33 +829,48 @@ export class SettingsClient {
822
829
  }
823
830
  }
824
831
 
825
- private async post(payload: unknown): Promise<void> {
826
- const generation = ++this.generation
827
- const snapshot = await apiRequest<UITweaksSnapshot>({
828
- method: 'POST',
829
- headers: { 'Content-Type': 'application/json' },
830
- body: JSON.stringify(payload),
831
- })
832
- if (generation !== this.generation) return
833
- this.publish({
834
- status: 'ready',
835
- writable: snapshot.writable,
836
- value: snapshot.value,
837
- revision: snapshot.revision,
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
+ }
838
851
  })
852
+ this.writes = write.catch(() => {})
853
+ return write
839
854
  }
840
855
 
841
856
  async set(field: string, value: unknown): Promise<void> {
842
- await this.post({ action: 'set', field, value, expectedRevision: this.state.revision ?? 0 })
857
+ await this.post(() => ({ action: 'set', field, value }))
843
858
  }
844
859
 
845
860
  async unset(field: string): Promise<void> {
846
- await this.post({ action: 'unset', field, expectedRevision: this.state.revision ?? 0 })
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
+ }))
847
869
  }
848
870
  }
849
871
 
850
872
  /** Required client services: slots (settings.section), locale, sessions (git bar, whale, archive, notifier), the slash-command registry, and the scope-addressed conversation face. */
851
- export const inject = ['slots', 'locale', 'sessions', 'commandUi', 'conversation']
873
+ export const inject = ['slots', 'locale', 'sessions', 'uiSession', 'uiWorkspace', 'commandUi', 'conversation']
852
874
 
853
875
  /**
854
876
  * Hover/focus hint: a small ⓘ next to the field label; the hint text renders
@@ -951,19 +973,19 @@ function SettingsSection({ controller, t }: SettingsSectionProps) {
951
973
  const stepFontSize = (delta: number): void => {
952
974
  const next = Math.min(MAX_FONT_SIZE, Math.max(MIN_FONT_SIZE, resolved.fontSize + delta))
953
975
  setDraft(String(next))
954
- void controller.set('fontSize', next).then(() => { setStatus('applied') }).catch(() => { setStatus('unavailable') })
976
+ void controller.step('fontSize', delta, MIN_FONT_SIZE, MAX_FONT_SIZE).then(() => { setStatus('applied') }).catch(() => { setStatus('unavailable') })
955
977
  }
956
978
 
957
979
  const stepLineHeight = (delta: number): void => {
958
980
  const next = Math.min(MAX_LINE_HEIGHT, Math.max(MIN_LINE_HEIGHT, resolved.lineHeight + delta))
959
981
  setLineHeightDraft(String(next))
960
- void controller.set('lineHeight', next).then(() => { setStatus('applied') }).catch(() => { setStatus('unavailable') })
982
+ void controller.step('lineHeight', delta, MIN_LINE_HEIGHT, MAX_LINE_HEIGHT).then(() => { setStatus('applied') }).catch(() => { setStatus('unavailable') })
961
983
  }
962
984
 
963
985
  const stepCodeSize = (delta: number): void => {
964
986
  const next = Math.min(MAX_CODE_FONT_SIZE, Math.max(MIN_CODE_FONT_SIZE, resolved.codeFontSize + delta))
965
987
  setCodeDraft(String(next))
966
- void controller.set('codeFontSize', next).then(() => { setStatus('applied') }).catch(() => { setStatus('unavailable') })
988
+ void controller.step('codeFontSize', delta, MIN_CODE_FONT_SIZE, MAX_CODE_FONT_SIZE).then(() => { setStatus('applied') }).catch(() => { setStatus('unavailable') })
967
989
  }
968
990
 
969
991
  const setGitBar = (value: boolean): void => {
@@ -1343,7 +1365,7 @@ function registerInitCommand(ctx: UITweaksClientContext): () => void {
1343
1365
  const t = ctx.locale.bind(NS)
1344
1366
  return ctx.commandUi.register({
1345
1367
  name: 'init',
1346
- description: t('initDesc'),
1368
+ description: () => t('initDesc'),
1347
1369
  available: () => true,
1348
1370
  ui: {
1349
1371
  kind: 'popupSelect',
@@ -1628,7 +1650,8 @@ export function apply(ctx: UITweaksClientContext): void {
1628
1650
  if (enabled && disposeNotifier === undefined) {
1629
1651
  disposeNotifier = installTaskNotifier({
1630
1652
  sessionsService: ctx.sessions,
1631
- pendingInteractions: ctx.uiSession.pendingInteractions,
1653
+ sessionStatus: ctx.uiSession.sessionStatus,
1654
+ openSession: id => ctx.uiWorkspace.openSession(id),
1632
1655
  text: {
1633
1656
  notifyTitleDone: t('notifyTitleDone'),
1634
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 { SessionPendingInteractionSnapshot } from '@deepseek-ai/dsh-client-ui-session/client'
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
- pendingInteractions: HostObservable<SessionPendingInteractionSnapshot>
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: SessionPendingInteractionSnapshot,
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, pendingInteractions, text, readState } = input
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 { sessionsService.open(sessionId) } catch { /* session already gone — focus alone is fine */ }
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 = pendingInteractions.getSnapshot()
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.completed === true,
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 = pendingInteractions.getSnapshot()
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.completed === true, outcome })
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.completed === true
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 = pendingInteractions.subscribe(check)
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 ?? snapshot.current
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
- return () => { controller.abort(); clearTimeout(timer); document.removeEventListener('visibilitychange', visible) }
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
- return { chatcode, busy, error, loginUrl, startLogin, logout, cancelLogin }
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
@@ -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', 'webRuntime', 'tools', 'settings']
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> = {
@@ -853,7 +853,11 @@ export function apply(ctx: Context, config?: SidebarConfig): void {
853
853
  // plus --trusted-host authorities) — the authoritative source the /api
854
854
  // gateway fence derives its list from. Read per request from the live
855
855
  // service value; a replaced list takes effect without a plugin restart.
856
- const fence = (req: SidebarHttpRequest): boolean => isTrustedApiRequest(req, ctx.webRuntime.trustedHosts)
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
+ }
857
861
  // node-pty is loaded lazily, never at module top level (issue #140): a
858
862
  // missing or broken install must degrade THIS plugin — terminal tab shows
859
863
  // a repair command, agent terminal tools stay unregistered — instead of
@@ -987,7 +987,7 @@ export class GitBackend {
987
987
  }
988
988
  }
989
989
  try {
990
- const stored = this.ctx.settings?.get(AGENT_DEFAULT_MODEL_NAMESPACE) as { provider?: string; model?: string } | undefined
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
  }
@@ -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,