@lincyaw/dsh 0.2.0-rc.12 → 0.2.0-rc.121

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 (46) hide show
  1. package/README.md +1 -1
  2. package/build/client.mjs +0 -2
  3. package/build/dist/client.js +309 -297
  4. package/build/dist/client.json +95 -41
  5. package/cordis.patch.yml +20 -0
  6. package/entries/deltabox-runtime.mjs +3 -0
  7. package/package.json +13 -9
  8. package/src/client/DesktopUpdate.tsx +31 -0
  9. package/src/client/RootLayout.tsx +44 -18
  10. package/src/client/agent-requests.ts +54 -0
  11. package/src/client/brand.tsx +2 -2
  12. package/src/client/contract.ts +0 -6
  13. package/src/client/desktop-messages.ts +16 -0
  14. package/src/client/dsh.d.ts +12 -0
  15. package/src/client/fallback.tsx +6 -4
  16. package/src/client/frame.css +4 -10
  17. package/src/client/index.tsx +8 -7
  18. package/src/client/layout.ts +19 -11
  19. package/src/client/messages.ts +10 -12
  20. package/src/client/navigation-shell.tsx +3 -3
  21. package/src/client/runtime-diagnostics.tsx +1 -1
  22. package/src/client/settings-launcher.tsx +19 -0
  23. package/src/client/settings-opener.ts +6 -0
  24. package/src/client/speech-settings.tsx +2 -1
  25. package/src/client/startup.css +47 -0
  26. package/src/client/startup.ts +17 -0
  27. package/src/client/styles.css +0 -42
  28. package/src/client/theme.ts +7 -7
  29. package/src/client/workspace-events.ts +10 -8
  30. package/src/node/bindings.ts +136 -8
  31. package/src/node/context.ts +16 -26
  32. package/src/node/deltabox-runtime.ts +19 -0
  33. package/src/node/dsh-types.ts +31 -1
  34. package/src/node/launch.ts +40 -11
  35. package/src/node/policy.ts +14 -3
  36. package/src/node/routes.ts +11 -3
  37. package/src/node/service.ts +7 -1
  38. package/src/node/startup.ts +73 -0
  39. package/src/node/tools.ts +121 -8
  40. package/src/node/turns.ts +23 -8
  41. package/src/node/workbench.ts +10 -3
  42. package/src/node/workspace-events.ts +9 -4
  43. package/src/startup-messages.ts +15 -0
  44. package/src/workspace-events.ts +3 -2
  45. package/web.patch.yml +18 -6
  46. package/src/client/mascot.tsx +0 -37
@@ -9,8 +9,18 @@ import { CLIENT_MESSAGES } from './messages.ts'
9
9
  * the repair of the selected document's diagnostics. Each is prompted on the session after its document context is
10
10
  * set, and the conversation is shown. Without a usable model nothing is sent: the conversation is shown, where the
11
11
  * composer offers to set one up, and the request answers with that in the author's terms.
12
+ *
13
+ * Drafts (the slash menu's animation request) go into the session's composer instead, for the author to finish and
14
+ * send. Without a model the composer's takeover shows over the draft, which waits beneath it.
12
15
  */
13
16
  export function registerAgentRequests(ctx: DshClientContext, workbench: Workbench, setup: AssistantSetup): void {
17
+ // The workbench offers what only the AI can do (writing a document from source material) by the model's readiness.
18
+ ctx.effect(() => {
19
+ const tell = () => workbench.setAgentReadiness(setup.readiness.getSnapshot(), setup.openModels)
20
+ tell()
21
+ const off = setup.readiness.subscribe(tell)
22
+ return () => { off(); workbench.setAgentReadiness('unknown') }
23
+ }, 'presmium: tell the workbench whether the AI has a model')
14
24
  ctx.inject(['sessions', 'layout'], inner => inner.effect(() => {
15
25
  let active: DshSessionBinding | undefined
16
26
  let offRequests: (() => void) | undefined
@@ -61,4 +71,48 @@ export function registerAgentRequests(ctx: DshClientContext, workbench: Workbenc
61
71
  update()
62
72
  return () => { off(); offRequests?.() }
63
73
  }, 'presmium: hand the author\'s requests to the current session'))
74
+
75
+ ctx.inject(['sessions', 'layout', 'conversation'], inner => inner.effect(() => {
76
+ let offDrafts: (() => void) | undefined
77
+ let active: DshSessionBinding | undefined
78
+ const update = () => {
79
+ const row = mainViewAgentSession(inner.sessions.list.getSnapshot().byId)
80
+ const binding = row && inner.sessions.binding(row.id)
81
+ if (binding === active) return
82
+ offDrafts?.()
83
+ offDrafts = undefined
84
+ active = binding
85
+ if (!row || !binding) return
86
+ // Whatever the author wrote stays above the draft; a draft put here and not changed since is replaced by the next.
87
+ let last: { kept: string, text: string } | undefined
88
+ offDrafts = workbench.onAgentDraft(draft => {
89
+ if (active !== binding || inner.sessions.binding(row.id) !== binding) throw new Error('no-conversation')
90
+ const input = inner.conversation.input.for(binding.ctx)
91
+ const { draft: current, phase } = input.state.getSnapshot()
92
+ if (phase !== 'plain') throw new Error('no-conversation')
93
+ const kept = last && current.trim() === (last.kept + last.text).trim() ? last.kept : current.trim() ? `${current.trimEnd()}\n` : ''
94
+ const text = kept + draft.text
95
+ last = { kept, text: draft.text }
96
+ input.setDraft(text)
97
+ inner.layout.selectPanel(null)
98
+ // The composer takes the keyboard once the conversation is shown (under the takeover it stays where it was).
99
+ // Focus brings back the caret the composer last held, which the draft does not move: the browser's selection
100
+ // goes to the end of the focused editor, and the composer's editor follows it.
101
+ const frame = (then: () => void) => requestAnimationFrame(() => requestAnimationFrame(then))
102
+ if (setup.readiness.getSnapshot() !== 'missing') frame(() => {
103
+ input.focus()
104
+ frame(() => {
105
+ const editor = document.activeElement
106
+ if (!(editor instanceof HTMLElement) || !editor.isContentEditable || input.state.getSnapshot().draft !== text) return
107
+ const selection = getSelection()
108
+ selection?.selectAllChildren(editor)
109
+ selection?.collapseToEnd()
110
+ })
111
+ })
112
+ })
113
+ }
114
+ const off = inner.sessions.list.subscribe(update)
115
+ update()
116
+ return () => { off(); offDrafts?.() }
117
+ }, 'presmium: put the author\'s drafts in the current session\'s composer'))
64
118
  }
@@ -9,8 +9,8 @@ import { rememberOpenSection } from './settings-opener.ts'
9
9
  export function Logo({ size = 24, className }: { size?: number, className?: string }) {
10
10
  return (
11
11
  <svg className={className ? `pmw-logo ${className}` : 'pmw-logo'} width={size} height={size} viewBox="0 0 32 32" role="img" aria-label="Presmium">
12
- <rect width="32" height="32" rx="7" fill="#0F5F5C" />
13
- <path d="M11 8h7.5a6.5 6.5 0 0 1 0 13H15v4h-4zM15 12v5h3.5a2.5 2.5 0 0 0 0-5z" fill="#F7F5F0" fillRule="evenodd" />
12
+ <rect width="32" height="32" rx="7" fill="#2F5BD3" />
13
+ <path d="M11 8h7.5a6.5 6.5 0 0 1 0 13H15v4h-4zM15 12v5h3.5a2.5 2.5 0 0 0 0-5z" fill="#FFFFFF" fillRule="evenodd" />
14
14
  </svg>
15
15
  )
16
16
  }
@@ -23,12 +23,6 @@ export const ONBOARDING = { slot: 'settings.onboarding', steps: ['welcome-notice
23
23
  */
24
24
  export const ASSISTANT_SLOTS = ['conversation.composer', { name: 'conversation.chat.node', key: 'turn-error' }] as const
25
25
 
26
- /** Where the kitten sits beside the conversation: an added entry (its own id) among the session header's actions. */
27
- export const MASCOT_SLOT = { name: 'conversation.session.header.actions', id: 'presmium-mascot' } as const
28
-
29
- /** Where the author turns the kitten on or off: an added row (its own id) in Settings → General. */
30
- export const MASCOT_SETTING = { name: 'settings.general.item', id: 'presmium-mascot' } as const
31
-
32
26
  /**
33
27
  * Settings → Models, and when the model catalog is read again: on the Host's events that change what can be routed,
34
28
  * whenever the window regains focus, and on a slow poll while no model is usable (Settings is a modal over this page,
@@ -0,0 +1,16 @@
1
+ export const DESKTOP_MESSAGES = {
2
+ 'zh-CN': {
3
+ currentVersion: (version: string) => `当前版本 ${version}`,
4
+ candidate: (version: string) => `可更新至 ${version}`,
5
+ idle: '检查更新', checking: '正在检查', current: '已是最新版', available: '发现更新',
6
+ downloading: (progress?: number) => progress === undefined ? '正在下载' : `正在下载 ${progress}%`,
7
+ ready: '重启安装', installing: '正在安装', error: '重试更新',
8
+ },
9
+ en: {
10
+ currentVersion: (version: string) => `Current version ${version}`,
11
+ candidate: (version: string) => `Update to ${version}`,
12
+ idle: 'Check for Updates', checking: 'Checking', current: 'Up to Date', available: 'Update Available',
13
+ downloading: (progress?: number) => progress === undefined ? 'Downloading' : `Downloading ${progress}%`,
14
+ ready: 'Restart and Install', installing: 'Installing', error: 'Retry Update',
15
+ },
16
+ }
@@ -125,6 +125,17 @@ interface DshSessionBinding {
125
125
  beginSubmission(input: { mode: 'queue', text: string, attachments: [] }): { requestId: string, abandon(): void }
126
126
  prompt(content: { type: 'text', text: string }[], mode: 'queue', signal: AbortSignal | undefined, requestId: string): Promise<{ ok: true, value: { accepted: true } } | { ok: false, error: { code: string, message: string } }>
127
127
  }
128
+ /** The session's scope, which addresses its composer through `conversation.input`. */
129
+ ctx: unknown
130
+ }
131
+
132
+ /** A session's composer (`SessionInput` of `@deepseek-ai/dsh-client-ui-conversation`), as far as it is used here. */
133
+ interface DshSessionInput {
134
+ /** Replaces the whole draft with plain text; the caret lands at its end. */
135
+ setDraft(text: string): void
136
+ /** Gives the keyboard back to the composer, with the caret it last held. */
137
+ focus(): void
138
+ readonly state: DshObservable<{ draft: string, phase: 'plain' | 'adjudicating' | 'claimed' | 'submitting' }>
128
139
  }
129
140
 
130
141
  interface DshClientContext {
@@ -141,6 +152,7 @@ interface DshClientContext {
141
152
  sidebarRight: { active(): { id: string, kind: string, contentId: string } | undefined, close(id: string): void, isExpanded(): boolean, toggleExpanded(): void }
142
153
  layout: { selectPanel(id: string | null): void }
143
154
  sessions: { list: DshObservable<{ byId: Record<string, { id: string, cwd?: string, retainedBy: { mainView?: number } }> }>, binding(id: string): DshSessionBinding | undefined }
155
+ conversation: { input: { for(scope: unknown): DshSessionInput } }
144
156
  uiWorkspace: { openWorkspace(id: string, beforeOpen?: (sessionId: string) => void): Promise<void>, startSession(id?: string): void }
145
157
  workspaces: { list: DshObservable<{ items: readonly { workspaceId: string, path: string }[] }> }
146
158
  configForms: {
@@ -1,4 +1,5 @@
1
- import { DocumentView, HistoryPanel, HomePanel, PreviewPanel, useWorkbench, useWorkbenchState, WorkbenchProvider } from '@lincyaw/workbench'
1
+ import { useStartupReady } from './startup.ts'
2
+ import { AgentActivityBar, DocumentView, HistoryPanel, HomePanel, PreviewPanel, useWorkbench, useWorkbenchState, WorkbenchProvider, WorkbenchApprovals } from '@lincyaw/workbench'
2
3
  import type { Workbench } from '@lincyaw/workbench'
3
4
  import { useRef } from 'react'
4
5
  import type { ComponentType } from 'react'
@@ -11,15 +12,16 @@ export const FALLBACK_PANEL = 'presmium'
11
12
 
12
13
  function Centre() {
13
14
  const workbench = useWorkbench()
15
+ useStartupReady(workbench)
14
16
  const document_ = useWorkbenchState(state => state.document)
15
17
  const retainedDocument = useRef(false)
16
18
  if (document_ !== undefined) retainedDocument.current = true
17
19
  return (
18
20
  <div className="pmw-fallback pm-ui" data-pmw-fallback="">
19
21
  <RuntimeDiagnosticsNotice workbench={workbench} />
20
- {document_ === undefined && <HomePanel />}
22
+ {document_ === undefined && <HomePanel actions={<AgentActivityBar />} />}
21
23
  {retainedDocument.current && <div className="pmw-fallback__doc" hidden={document_ === undefined}>
22
- <DocumentView active={document_ !== undefined} />
24
+ <DocumentView active={document_ !== undefined} actions={<AgentActivityBar />} />
23
25
  </div>}
24
26
  </div>
25
27
  )
@@ -30,7 +32,7 @@ export function registerFallbackLayout(ctx: DshClientContext, workbench: Workben
30
32
  const t = () => CLIENT_MESSAGES[workbench.state.locale]
31
33
  const provided = (Component: ComponentType, className?: string) => function PresmiumPanel() {
32
34
  return (
33
- <WorkbenchProvider workbench={workbench}>
35
+ <WorkbenchProvider workbench={workbench} dialogActions={<WorkbenchApprovals />}>
34
36
  <WorkbenchRuntimeBoundary workbench={workbench}>{className ? <div className={className}><Component /></div> : <Component />}</WorkbenchRuntimeBoundary>
35
37
  </WorkbenchProvider>
36
38
  )
@@ -43,11 +43,7 @@ body,
43
43
  align-items: center;
44
44
  gap: var(--pm-space-px);
45
45
  min-width: 0;
46
- height: var(--pm-appbar-height);
47
46
  padding: 0 var(--pm-space-2) 0 var(--pm-space-3);
48
- border-bottom: var(--pm-size-hairline) solid var(--pm-color-line);
49
- background: var(--pm-color-chrome);
50
- font-size: var(--pm-text-sm);
51
47
  }
52
48
 
53
49
  .pmw-appbar__brand {
@@ -59,6 +55,10 @@ body,
59
55
  font-size: var(--pm-text-md);
60
56
  }
61
57
 
58
+ html[data-pm-desktop='darwin']:not([data-pm-desktop-fullscreen]) .pmw-appbar {
59
+ padding-inline-start: var(--pm-desktop-controls-inset);
60
+ }
61
+
62
62
  .pmw-appbar__places {
63
63
  display: flex;
64
64
  align-items: center;
@@ -172,12 +172,6 @@ span.pmw-appbar__place {
172
172
  height: var(--pm-size-logo);
173
173
  }
174
174
 
175
- .pmw-appbar__more > .pm-ui-icon-button {
176
- width: var(--pm-size-tool);
177
- height: var(--pm-size-tool);
178
- border-radius: var(--pm-radius-tool);
179
- }
180
-
181
175
  .pmw-appbar__busy {
182
176
  position: absolute;
183
177
  top: var(--pm-space-1);
@@ -1,11 +1,11 @@
1
- import { connectAuthoringClient, localeOf, Workbench, workspaceClient } from '@lincyaw/workbench'
1
+ import { openAppSettings, registerSettingsLauncher } from './settings-launcher.tsx'
2
+ import { connectAgentActivity, connectAuthoringClient, connectAuthoringWindow, localeOf, Workbench, workspaceClient } from '@lincyaw/workbench'
2
3
  import type { Locale } from '@lincyaw/workbench'
3
4
  import { workspaceSubscriptions } from './workspace-events.ts'
4
5
  import { registerAuthorSettings } from './author-settings.ts'
5
6
  import { registerSpeechSettings } from './speech-settings.tsx'
6
7
  import { openSpeechSettings } from './settings-opener.ts'
7
8
  import { registerBrand } from './brand.tsx'
8
- import { registerMascot } from './mascot.tsx'
9
9
  import { CLIENT_ID, isBootEntryLoaded, ROOT_CHILDREN, UI_LAYOUT, UI_SIDEBAR } from './contract.ts'
10
10
  import { syncDocumentContext } from './document-context.ts'
11
11
  import { FALLBACK_PANEL, registerFallbackLayout } from './fallback.tsx'
@@ -56,6 +56,8 @@ export function apply(ctx: DshClientContext): void {
56
56
  const workbench = new Workbench({ client: workspaceClient('api/presmium/', workspaceSubscriptions(ctx)), locale: workbenchLocale(ctx.locale.getLocale().active) })
57
57
  workbench.client.openSpeechSettings = openSpeechSettings
58
58
  ctx.effect(() => connectAuthoringClient(workbench), 'presmium: authoring client control')
59
+ ctx.effect(() => connectAuthoringWindow(workbench), 'presmium: authoring window control')
60
+ ctx.effect(() => connectAgentActivity(workbench), 'presmium: agent activity')
59
61
  ctx.effect(() => runtimeDiagnostics(workbench).start(), 'presmium: runtime diagnostics')
60
62
  let showEditor = (layout: DshClientContext['layout']) => layout.selectPanel(FALLBACK_PANEL)
61
63
  registerSourceLinks(ctx, workbench, layout => showEditor(layout))
@@ -75,6 +77,8 @@ export function apply(ctx: DshClientContext): void {
75
77
  }, 'presmium: light and dark')
76
78
 
77
79
  if (nativeLayout) {
80
+ // Its default conversation view does not mount HomePanel, so the host owns this first read.
81
+ void workbench.loadDocuments()
78
82
  registerFallbackLayout(ctx, workbench)
79
83
  } else {
80
84
  ctx.effect(() => {
@@ -102,10 +106,7 @@ export function apply(ctx: DshClientContext): void {
102
106
  subscribe: listener => instance.subscribe(listener),
103
107
  })
104
108
  showEditor = () => layout.showDocument()
105
- const openSettings = () => {
106
- const triggers = document.querySelectorAll<HTMLElement>('[data-pmw-slot="sidebar"] button[aria-haspopup="dialog"]')
107
- triggers[triggers.length - 1]?.click()
108
- }
109
+ const openSettings = openAppSettings
109
110
  const disposePanelInfo = ctx.slots.provideRoot({ hooks: { panelInfo: layout.panelInfo } })
110
111
  const disposeRoot = ctx.slots.register({ name: 'root', locale: 'common', children: {
111
112
  ...ROOT_CHILDREN,
@@ -148,8 +149,8 @@ export function apply(ctx: DshClientContext): void {
148
149
  }, 'presmium: the root layout and ctx.layout')
149
150
  }
150
151
  registerBrand(ctx, workbench)
151
- registerMascot(ctx, workbench)
152
152
  registerAuthorSettings(ctx)
153
+ registerSettingsLauncher(ctx, workbench)
153
154
  registerSpeechSettings(ctx, workbench)
154
155
  ctx.inject(['layout'], inner => inner.effect(() => connectLaunchTarget(workbench,
155
156
  () => nativeLayout ? () => {} : restoreRootReturnPoint(workbench, reload.point),
@@ -1,11 +1,11 @@
1
1
  import { defineStore } from '@deepseek-ai/dsh-client-store'
2
+ import { designLength } from '@lincyaw/design'
2
3
 
3
- export const CENTRE_MIN = 400
4
+ export const centreMinWidth = () => designLength('--pm-canvas-min-width')
4
5
  export const RIGHTBAR_MIN = 300
5
6
  export const RIGHTBAR_MAX_RATIO = 0.7
6
7
  export const RIGHTBAR_DEFAULT_RATIO = 0.45
7
8
  export const SIDE_COLLAPSE = 1024
8
- export const NARROW = 768
9
9
  export const SIDE_DEFAULT = 264
10
10
  export const SIDE_MIN = 200
11
11
  export const SIDE_MAX = 420
@@ -15,15 +15,18 @@ export const CONVERSATION_MAX = 640
15
15
  /** The width of one resize handle between two columns: a hairline, with a wider area to grab. */
16
16
  export const HANDLE = 1
17
17
 
18
+ /** A split view needs both panes and its divider; use one pane before constraints become impossible. */
19
+ export const singlePaneWidth = () => Math.max(designLength('--pm-layout-narrow-width'), centreMinWidth() + CONVERSATION_MIN + HANDLE)
20
+
18
21
  export const clamp = (px: number, min: number, max: number) => Math.min(max, Math.max(min, Math.round(px)))
19
22
 
20
23
  /** The width left for the rightbar column: the viewport less the side panel, the conversation, the centre's minimum and `handles` resize handles. */
21
24
  export function rightbarRoom(viewport: number, side: number, conversation: number, handles: number): number {
22
- return viewport - side - conversation - CENTRE_MIN - handles * HANDLE
25
+ return viewport - side - conversation - centreMinWidth() - handles * HANDLE
23
26
  }
24
27
 
25
- /** What the side panel shows: the chat history (DeepSeek Harness's sessions). */
26
- export type Activity = 'sessions'
28
+ /** What the side panel shows: the workspace's document tree, or the chat history (DeepSeek Harness's sessions). */
29
+ export type Activity = 'documents' | 'sessions'
27
30
  /** What a narrow screen shows, one at a time. */
28
31
  export type NarrowPane = 'documents' | 'preview' | 'sessions' | 'conversation'
29
32
 
@@ -61,7 +64,7 @@ function showHistory(d: LayoutState): void {
61
64
  d.layoutInfo.isSideOpen = true
62
65
  d.layoutInfo.narrowPane = 'sessions'
63
66
  if (d.layoutInfo.viewportWidth < SIDE_COLLAPSE) {
64
- d.layoutInfo.isSideExpanded = d.layoutInfo.viewportWidth >= NARROW
67
+ d.layoutInfo.isSideExpanded = d.layoutInfo.viewportWidth >= singlePaneWidth()
65
68
  d.layoutInfo.isConversationOpen = false
66
69
  } else d.layoutInfo.isConversationOpen = true
67
70
  }
@@ -72,7 +75,7 @@ export function createLayoutStore() {
72
75
  panelInfo: { activePanelId: null },
73
76
  layoutInfo: {
74
77
  viewportWidth: window.innerWidth,
75
- isSideOpen: false,
78
+ isSideOpen: true,
76
79
  isSideExpanded: false,
77
80
  sideWidth: SIDE_DEFAULT,
78
81
  conversationWidth: CONVERSATION_DEFAULT,
@@ -81,7 +84,7 @@ export function createLayoutStore() {
81
84
  isRightbarOpen: false,
82
85
  hasRightbarTrack: false,
83
86
  isRightbarFullscreen: false,
84
- activity: 'sessions',
87
+ activity: 'documents',
85
88
  narrowPane: 'documents',
86
89
  },
87
90
  }),
@@ -121,13 +124,13 @@ export function createLayoutStore() {
121
124
  showHistory,
122
125
  toggleConversations: (d: LayoutState) => {
123
126
  const info = d.layoutInfo
124
- if (info.viewportWidth < NARROW) {
127
+ if (info.viewportWidth < singlePaneWidth()) {
125
128
  if (info.narrowPane === 'conversation') showHistory(d)
126
129
  else revealConversation(d)
127
130
  } else {
128
131
  const historyShown = info.activity === 'sessions' && (info.viewportWidth < SIDE_COLLAPSE ? info.isSideExpanded : info.isSideOpen)
129
132
  if (historyShown && info.viewportWidth < SIDE_COLLAPSE) revealConversation(d)
130
- else if (historyShown && info.isConversationOpen) info.isSideOpen = false
133
+ else if (historyShown && info.isConversationOpen) info.activity = 'documents'
131
134
  else showHistory(d)
132
135
  }
133
136
  },
@@ -157,11 +160,16 @@ export function createLayoutStore() {
157
160
  else d.layoutInfo.isSideOpen = true
158
161
  d.layoutInfo.activity = activity
159
162
  if (d.layoutInfo.viewportWidth < SIDE_COLLAPSE) {
160
- d.layoutInfo.isSideExpanded = d.layoutInfo.viewportWidth >= NARROW
163
+ d.layoutInfo.isSideExpanded = d.layoutInfo.viewportWidth >= singlePaneWidth()
161
164
  if (d.layoutInfo.isSideExpanded) d.layoutInfo.isConversationOpen = false
162
165
  }
163
166
  d.layoutInfo.narrowPane = activity
164
167
  },
168
+ /** Back from the chat history to the document tree, keeping the side panel open. */
169
+ showDocumentTree: (d: LayoutState) => {
170
+ d.layoutInfo.activity = 'documents'
171
+ if (d.layoutInfo.narrowPane === 'sessions') d.layoutInfo.narrowPane = 'conversation'
172
+ },
165
173
  showNarrowPane: (d: LayoutState, pane: NarrowPane) => {
166
174
  d.layoutInfo.narrowPane = pane
167
175
  d.layoutInfo.isSideExpanded = false
@@ -17,11 +17,9 @@ const zh = {
17
17
  preview: '文稿',
18
18
  history: '版本历史',
19
19
  settings: '设置',
20
+ preferences: '通用设置',
21
+ mcp: 'MCP 连接',
20
22
  help: '帮助',
21
- mascot: '小猫',
22
- mascotHint: 'AI 助手工作时,对话和文稿旁的小猫会演示它在做什么:思考、阅读、修改或等你确认。',
23
- mascotShow: '显示',
24
- mascotHide: '隐藏',
25
23
  close: '关闭',
26
24
  toggleSide: '显示或隐藏对话记录',
27
25
  keys: {
@@ -41,9 +39,10 @@ const zh = {
41
39
  models: '设置模型',
42
40
  helpItems: [
43
41
  '直接在文稿中输入即可修改。修改自动保存,文稿上方显示“已保存”。',
44
- '选中文字会出现格式工具栏:段落样式、加粗、对齐、颜色、“插入链接”与“新建批注”。“新建批注”在选中的文字上留下批注,“批注”窗格列出全部批注。',
42
+ '选中文字会出现格式工具栏:段落样式、加粗、对齐、颜色、“插入链接”与“新建批注”。“新建批注”在选中的文字上留下批注,“批注”窗格列出全部批注。动画、图表的预览工具栏里有“本步批注”,可以对整个内容块或其中一步批注。',
45
43
  '鼠标移到一段内容上,旁边的“插入内容块”可插入标题、列表、表格、图片等内容,“打开内容块菜单”可删除这一段或修改它的颜色。',
46
- '“导航窗格”列出全部页面:“新建页面”添加一页,页面旁的“更多”可以重命名、复制、上移、下移或删除这一页。',
44
+ '右栏的“目录”列出全部页面:“新建页面”添加一页,页面旁的“更多”可以重命名、复制、上移、下移或删除这一页。“引用”列出引用了本文的文稿。',
45
+ '左侧的文稿树列出工作区的全部文稿:拖动可调整上下级与顺序,行上的“+”新建子文稿,“更多”可以重命名、移动或移到回收站。在正文中输入 @ 可插入指向另一份文稿的引用。',
47
46
  '“撤消”({undo})与“恢复”({redo})逐步撤消或恢复修改。“版本历史”列出保存过的每次修改,“撤消此更改”单独撤消其中一次。',
48
47
  '“放映”按幻灯片逐步展示文稿;“导出”可导出网站、幻灯片网站、Notebook、幻灯片 PDF、幻灯片图片或幻灯片 PowerPoint;“视频制作”制作讲授视频。',
49
48
  '“AI 助手”显示或隐藏与 AI 的对话。用自己的话告诉它要改什么,它处理的是当前打开的文稿。第一次使用前,请在“设置”的“模型”中设置模型。',
@@ -93,11 +92,9 @@ const en: ClientMessages = {
93
92
  preview: 'Document',
94
93
  history: 'Version History',
95
94
  settings: 'Settings',
95
+ preferences: 'General Settings',
96
+ mcp: 'MCP Connection',
96
97
  help: 'Help',
97
- mascot: 'Kitten',
98
- mascotHint: 'While the AI Assistant works, a kitten beside the chat and the document acts out what it is doing: thinking, reading, changing the document, or waiting for you.',
99
- mascotShow: 'Show',
100
- mascotHide: 'Hide',
101
98
  close: 'Close',
102
99
  toggleSide: 'Show or Hide Chat History',
103
100
  keys: {
@@ -117,9 +114,10 @@ const en: ClientMessages = {
117
114
  models: 'Set Up a Model',
118
115
  helpItems: [
119
116
  'Type directly in the document to change it. Changes save automatically, and the top of the document shows Saved.',
120
- 'Select text to show the formatting toolbar: paragraph style, Bold, alignment, Colors, Insert Link, and New Comment. New Comment leaves a comment on the selected text; the Comments pane lists them all.',
117
+ 'Select text to show the formatting toolbar: paragraph style, Bold, alignment, Colors, Insert Link, and New Comment. New Comment leaves a comment on the selected text; the Comments pane lists them all. An animation or chart preview also has Comment on step, for the whole content block or one step.',
121
118
  'Point at a paragraph: Insert Block, beside it, inserts a heading, list, table, picture, and more; Open Block Menu deletes the paragraph or changes its colors.',
122
- 'The Navigation Pane lists the pages: New Page adds one, and More beside a page renames, duplicates, moves, or deletes it.',
119
+ 'Outline in the right pane lists the pages: New Page adds one, and More beside a page renames, duplicates, moves, or deletes it. References lists the documents that cite this one.',
120
+ 'The document tree on the left lists every document in the workspace: drag to change parents and order, + on a row adds a child document, and More renames, moves, or moves it to the trash. Type @ in the text to insert a reference to another document.',
123
121
  'Undo ({undo}) and Redo ({redo}) step back and forth through your changes. Version History lists every saved change; Undo This Change reverses one of them.',
124
122
  'Present shows the document as slides, step by step; Export makes a website, slides website, Notebook, slides as PDF, slides as pictures, or slides as PowerPoint; Video Production makes a lecture video with voiceover.',
125
123
  'AI Assistant shows or hides the chat with the AI. Tell it in your own words what to change; it works on the document you have open. Before the first use, set up a model under Models in Settings.',
@@ -3,7 +3,7 @@ import type { Workbench } from '@lincyaw/workbench'
3
3
  import type { ReactNode } from 'react'
4
4
  import { isBootEntryLoaded, UI_SIDEBAR } from './contract.ts'
5
5
  import type { LayoutActions, LayoutState } from './layout.ts'
6
- import { NARROW, SIDE_COLLAPSE } from './layout.ts'
6
+ import { singlePaneWidth, SIDE_COLLAPSE } from './layout.ts'
7
7
  import { useClientMessages } from './messages.ts'
8
8
 
9
9
  interface SidebarProps {
@@ -24,7 +24,7 @@ export function registerNavigationShell(ctx: DshClientContext, workbench: Workbe
24
24
  ctx.slots.inject('sidebar.panellist', updatePanels)
25
25
  const closeHistory = () => {
26
26
  if (layout.getSnapshot().layoutInfo.viewportWidth < SIDE_COLLAPSE) actions.revealConversation()
27
- else actions.toggleSidebar()
27
+ else actions.showDocumentTree()
28
28
  }
29
29
  function Sidebar({ renderSlot }: SidebarProps) {
30
30
  const t = useClientMessages(workbench)
@@ -55,7 +55,7 @@ export function registerNavigationShell(ctx: DshClientContext, workbench: Workbe
55
55
  <PmIconButton icon="plus" label={t.newConversation} small onClick={() => void startSession()} />
56
56
  <PmIconButton icon="history" label={t.conversationHistory} small onClick={() => actions.showHistory()} />
57
57
  <PmIconButton icon="close" label={t.hideConversation} small onClick={() => {
58
- if (layout.getSnapshot().layoutInfo.viewportWidth < NARROW) actions.showNarrowPane(workbench.state.document === undefined ? 'documents' : 'preview')
58
+ if (layout.getSnapshot().layoutInfo.viewportWidth < singlePaneWidth()) actions.showNarrowPane(workbench.state.document === undefined ? 'documents' : 'preview')
59
59
  else actions.setConversationOpen(false)
60
60
  }} />
61
61
  </div>
@@ -221,7 +221,7 @@ export function RuntimeDiagnosticsNotice({ workbench, fatal = false }: { workben
221
221
  export class WorkbenchRuntimeBoundary extends Component<{ workbench: Workbench, children: ReactNode }, { failed: boolean }> {
222
222
  state = { failed: false }
223
223
  static getDerivedStateFromError() { return { failed: true } }
224
- componentDidCatch(error: Error): void { runtimeDiagnostics(this.props.workbench).capture(error) }
224
+ componentDidCatch(error: Error): void { runtimeDiagnostics(this.props.workbench).capture(error); window.dispatchEvent(new Event('presmium:startup-failed')) }
225
225
  render() {
226
226
  return this.state.failed ? <main className="pmw-runtime-fallback pm-ui"><RuntimeDiagnosticsNotice workbench={this.props.workbench} fatal /></main> : this.props.children
227
227
  }
@@ -0,0 +1,19 @@
1
+ import { useStartupReady } from './startup.ts'
2
+ import { useLayoutEffect } from 'react'
3
+ import { PmIconButton } from '@lincyaw/workbench'
4
+ import type { Workbench } from '@lincyaw/workbench'
5
+ import { CLIENT_MESSAGES } from './messages.ts'
6
+
7
+ let current: (() => void) | undefined
8
+ /** Public settings.launcher contract; no hidden sidebar DOM or dependency internals. */
9
+ export function openAppSettings(): void { current?.() }
10
+ export function registerSettingsLauncher(ctx: DshClientContext, workbench: Workbench): void {
11
+ ctx.effect(() => ctx.slots.inject('settings.launcher', () => ctx.slots.register({ name: 'settings.launcher' }, function SettingsLauncher({ openSettings }: { openSettings(): void }) {
12
+ useStartupReady(workbench)
13
+ useLayoutEffect(() => {
14
+ current = openSettings
15
+ return () => { if (current === openSettings) current = undefined }
16
+ }, [openSettings])
17
+ return <PmIconButton icon="sliders" label={CLIENT_MESSAGES[workbench.state.locale].settings} onClick={openSettings} />
18
+ })), 'presmium: settings launcher')
19
+ }
@@ -24,3 +24,9 @@ export function openSpeechSettings(): boolean {
24
24
  remembered('presmium-speech')
25
25
  return true
26
26
  }
27
+
28
+ export function openMcpSettings(): boolean {
29
+ if (!remembered) return false
30
+ remembered('presmium-mcp')
31
+ return true
32
+ }
@@ -1,7 +1,8 @@
1
- import { SpeechSettingsPanel, SPEECH_SETTINGS_MESSAGES, WorkbenchProvider } from '@lincyaw/workbench'
1
+ import { McpSettingsPanel, MCP_SETTINGS_MESSAGES, SpeechSettingsPanel, SPEECH_SETTINGS_MESSAGES, WorkbenchProvider } from '@lincyaw/workbench'
2
2
  import type { Workbench } from '@lincyaw/workbench'
3
3
 
4
4
  /** The framework owns Settings navigation; Presmium owns its operator service page. */
5
5
  export function registerSpeechSettings(ctx: DshClientContext, workbench: Workbench): void {
6
+ ctx.effect(() => ctx.slots.inject('settings.section', () => ctx.slots.register({ name: 'settings.section', id: 'presmium-mcp', order: 40, label: () => MCP_SETTINGS_MESSAGES[workbench.state.locale].title }, () => <WorkbenchProvider workbench={workbench}><McpSettingsPanel /></WorkbenchProvider>)), 'presmium: MCP connection settings')
6
7
  ctx.effect(() => ctx.slots.inject('settings.section', () => ctx.slots.register({ name: 'settings.section', id: 'presmium-speech', order: 30, label: () => SPEECH_SETTINGS_MESSAGES[workbench.state.locale].title }, () => <WorkbenchProvider workbench={workbench}><SpeechSettingsPanel /></WorkbenchProvider>)), 'presmium: voice service settings')
7
8
  }
@@ -0,0 +1,47 @@
1
+ .pm-startup {
2
+ position: fixed;
3
+ inset: 0;
4
+ width: 100%;
5
+ height: 100%;
6
+ max-width: none;
7
+ max-height: none;
8
+ margin: 0;
9
+ border: 0;
10
+ z-index: var(--pm-z-startup);
11
+ display: grid;
12
+ place-items: center;
13
+ box-sizing: border-box;
14
+ padding: var(--pm-space-6);
15
+ background: var(--pm-color-bg);
16
+ color: var(--pm-color-ink);
17
+ font-family: var(--pm-font-sans);
18
+ font-size: var(--pm-text-sm);
19
+ }
20
+ .pm-startup__content {
21
+ display: grid;
22
+ justify-items: center;
23
+ gap: var(--pm-space-3);
24
+ max-width: var(--pm-dialog-width);
25
+ text-align: center;
26
+ }
27
+ .pm-startup__brand {
28
+ display: flex;
29
+ align-items: center;
30
+ gap: var(--pm-space-3);
31
+ margin: 0;
32
+ font-size: var(--pm-text-lg);
33
+ font-weight: var(--pm-weight-semibold);
34
+ }
35
+ .pm-startup__brand svg { width: var(--pm-size-logo); height: var(--pm-size-logo); }
36
+ .pm-startup__status, .pm-startup__actions {
37
+ display: flex;
38
+ align-items: center;
39
+ justify-content: center;
40
+ flex-wrap: wrap;
41
+ gap: var(--pm-space-2);
42
+ }
43
+ .pm-startup__status { margin: 0; color: var(--pm-color-muted); }
44
+ .pm-startup__status svg { width: var(--pm-size-icon); height: var(--pm-size-icon); }
45
+
46
+ .pm-startup__spinner { display: inline-flex; }
47
+ .pm-startup:target { display: none; }
@@ -0,0 +1,17 @@
1
+ import { useEffect, useSyncExternalStore } from 'react'
2
+ import type { Workbench } from '@lincyaw/workbench'
3
+
4
+ /** A committed shell plus its usable document list ends the product startup screen; AI history is independent. */
5
+ export function useStartupReady(workbench: Workbench): void {
6
+ const ready = useSyncExternalStore(workbench.subscribe, () => Boolean(workbench.state.documents || workbench.state.documentsFailure))
7
+ const locale = useSyncExternalStore(workbench.subscribe, () => workbench.state.locale)
8
+ const dark = useSyncExternalStore(workbench.subscribe, () => workbench.state.isDark)
9
+ useEffect(() => {
10
+ if (!ready) return
11
+ try {
12
+ localStorage.setItem('presmium.startup.locale', locale)
13
+ localStorage.setItem('presmium.startup.dark', String(dark))
14
+ } catch { /* Storage is optional. */ }
15
+ window.dispatchEvent(new Event('presmium:workspace-ready'))
16
+ }, [ready, locale, dark])
17
+ }
@@ -1,45 +1,3 @@
1
1
  @import '@lincyaw/design/design.css';
2
2
  @import '@lincyaw/workbench/styles.css';
3
3
  @import './frame.css';
4
-
5
- /* The kitten among the conversation header's actions. */
6
- .pmw-conversation-mascot {
7
- display: inline-flex;
8
- align-items: center;
9
- }
10
-
11
- /* The kitten's row in Settings → General, laid out as Harness's own rows: its name and note, then its choice. */
12
- .pmw-mascot-setting {
13
- display: flex;
14
- align-items: center;
15
- justify-content: space-between;
16
- gap: var(--pm-space-4);
17
- padding-block: var(--pm-space-4);
18
- border-top: var(--pm-size-hairline) solid var(--pm-color-line);
19
- }
20
-
21
- .pmw-mascot-setting__copy {
22
- display: grid;
23
- gap: var(--pm-space-1);
24
- min-width: 0;
25
- }
26
-
27
- .pmw-mascot-setting__title {
28
- margin: 0;
29
- color: var(--pm-color-ink);
30
- font-size: var(--pm-text-sm);
31
- }
32
-
33
- .pmw-mascot-setting__hint {
34
- margin: 0;
35
- color: var(--pm-color-muted);
36
- font-size: var(--pm-text-xs);
37
- }
38
-
39
- .pmw-mascot-setting .pm-ui-segmented {
40
- flex: none;
41
- }
42
-
43
- @media (max-width: 767px) {
44
- .pmw-mascot-setting { flex-wrap: wrap; }
45
- }
@@ -13,8 +13,8 @@ export const DSH_THEME_TOKENS: Record<string, Pair> = {
13
13
  '--dsw-alias-bg-layer-1': pm('surface'),
14
14
  '--dsw-alias-bg-layer-2': pm('surface'),
15
15
  '--dsw-alias-bg-layer-3': pm('sunk'),
16
- '--dsw-alias-bg-mask-1': { light: 'rgba(28, 27, 25, 0.32)', dark: 'rgba(0, 0, 0, 0.55)' },
17
- '--dsw-alias-bg-mask-drop': { light: 'rgba(247, 245, 240, 0.7)', dark: 'rgba(22, 22, 20, 0.7)' },
16
+ '--dsw-alias-bg-mask-1': pm('backdrop'),
17
+ '--dsw-alias-bg-mask-drop': mix('bg', 70),
18
18
  '--dsw-alias-bg-module-platform': pm('sunk'),
19
19
  '--dsw-alias-bg-overlay': pm('surface'),
20
20
  '--dsw-alias-bg-skeleton': mix('ink', 6),
@@ -32,10 +32,10 @@ export const DSH_THEME_TOKENS: Record<string, Pair> = {
32
32
  '--dsw-alias-button-floating-hover': pm('sunk'),
33
33
  '--dsw-alias-button-ghost-active-border': pm('line-strong'),
34
34
  '--dsw-alias-button-ghost-active-fill': pm('selected'),
35
- '--dsw-alias-button-info-fill': { light: '#0f5f5c', dark: '#2c7a74' },
36
- '--dsw-alias-button-info-hover': { light: '#0b4a47', dark: '#256963' },
37
- '--dsw-alias-button-primary-fill': pm('ink'),
38
- '--dsw-alias-button-primary-hover': mix('ink', 85, color('bg')),
35
+ '--dsw-alias-button-info-fill': pm('accent'),
36
+ '--dsw-alias-button-info-hover': pm('accent-hover'),
37
+ '--dsw-alias-button-primary-fill': pm('accent'),
38
+ '--dsw-alias-button-primary-hover': pm('accent-hover'),
39
39
  '--dsw-alias-file-diff-added-bg': pm('ok-soft'),
40
40
  '--dsw-alias-file-diff-added-gutter': pm('ok-soft'),
41
41
  '--dsw-alias-file-diff-added-marker': pm('add'),
@@ -83,7 +83,7 @@ export const DSH_THEME_TOKENS: Record<string, Pair> = {
83
83
  '--dsw-alias-state-warn-primary': pm('warn'),
84
84
  '--dsw-alias-state-warn-secondary': pm('warn'),
85
85
  '--dsw-alias-state-warn-tertiary': pm('warn-soft'),
86
- '--dsw-alias-tooltip-bg': { light: '#1c1b19', dark: '#3a3833' },
86
+ '--dsw-alias-tooltip-bg': pm('inverse'),
87
87
  '--dsw-alias-turn-trigger-bg': pm('code'),
88
88
  '--dsw-alias-turn-trigger-bg-hover': mix('ink', 6),
89
89
  '--dsw-specific-sidebar-fill': pm('sunk'),