dsh-tidy-display 0.2.0 → 0.2.2

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 (40) hide show
  1. package/lib/client.js +125 -0
  2. package/lib/client.js.map +1 -1
  3. package/lib/dsh-tidy-display.js +81 -1
  4. package/lib/types/client/config-bridge.d.ts +10 -0
  5. package/lib/types/client/config-bridge.d.ts.map +1 -0
  6. package/lib/types/client/config-bridge.js +89 -0
  7. package/lib/types/client/config-bridge.js.map +1 -0
  8. package/lib/types/client/config-card.d.ts +15 -0
  9. package/lib/types/client/config-card.d.ts.map +1 -0
  10. package/lib/types/client/config-card.js +17 -0
  11. package/lib/types/client/config-card.js.map +1 -0
  12. package/lib/types/client/index.d.ts.map +1 -1
  13. package/lib/types/client/index.js +2 -0
  14. package/lib/types/client/index.js.map +1 -1
  15. package/lib/types/client/settings-slots.d.ts +12 -0
  16. package/lib/types/client/settings-slots.d.ts.map +1 -1
  17. package/lib/types/client/settings.d.ts.map +1 -1
  18. package/lib/types/client/settings.js +2 -0
  19. package/lib/types/client/settings.js.map +1 -1
  20. package/lib/types/config.d.ts +7 -0
  21. package/lib/types/config.d.ts.map +1 -0
  22. package/lib/types/config.js +48 -0
  23. package/lib/types/config.js.map +1 -0
  24. package/lib/types/dsh-tidy-display.d.ts +2 -0
  25. package/lib/types/dsh-tidy-display.d.ts.map +1 -1
  26. package/lib/types/dsh-tidy-display.js +1 -0
  27. package/lib/types/dsh-tidy-display.js.map +1 -1
  28. package/lib/types/reader-prefs.d.ts +30 -0
  29. package/lib/types/reader-prefs.d.ts.map +1 -0
  30. package/lib/types/reader-prefs.js +44 -0
  31. package/lib/types/reader-prefs.js.map +1 -0
  32. package/package.json +142 -141
  33. package/src/client/config-bridge.ts +118 -0
  34. package/src/client/config-card.tsx +22 -0
  35. package/src/client/index.tsx +270 -268
  36. package/src/client/settings-slots.ts +8 -0
  37. package/src/client/settings.tsx +2 -0
  38. package/src/config.ts +53 -0
  39. package/src/dsh-tidy-display.ts +3 -0
  40. package/src/reader-prefs.ts +67 -0
@@ -1,268 +1,270 @@
1
- import type { Context } from '@deepseek-ai/cordis';
2
- import type {} from '@deepseek-ai/dsh-api-remotes/client';
3
- import type {} from '@deepseek-ai/dsh-api-session-controller/client';
4
- import type {} from '@deepseek-ai/dsh-client-connection/client';
5
- import type { SessionId } from '@deepseek-ai/dsh-session/types';
6
- import { resolveWorkspacePath } from '@deepseek-ai/dsh-util-workspace-path';
7
- import * as workspacePathPkg from '@deepseek-ai/dsh-util-workspace-path';
8
- import { dirname } from './deliverables.js';
9
- import type {} from '@deepseek-ai/dsh-client-ui-conversation/client';
10
- import type {} from '@deepseek-ai/dsh-client-ui-renderer/client';
11
- import { Reader } from './Reader.js';
12
- import { createReaderStore } from './store.js';
13
- import { installReaderEntry } from './entry.js';
14
- import { installBetterDisplaySettings } from './settings.js';
15
- import { RailView } from './rail/RailView.js';
16
- import { installRailColors } from './rail/colors.js';
17
- import { fillComposerDom } from './mcp-app.js';
18
- import { fileAddressFor, modeFromSnapshot, openDeliverableFile } from './open-file.js';
19
- import type { ReaderInjected } from './types.js';
20
- import type { ImageAttachmentRef } from '@deepseek-ai/dsh-attachment';
21
- import * as React from 'react';
22
- import { installOfficialSlots, officialChildren, type CompositionRegistry } from './official-slots.js';
23
-
24
- /** Structural face of the sanctioned per-session composer writer. */
25
- interface ComposerShell {
26
- setDraft: (text: string) => void;
27
- }
28
- interface ConversationFace {
29
- input?: { shell?: (id: SessionId) => ComposerShell };
30
- }
31
-
32
- interface SidebarRightFace {
33
- openResource?: (address: string, options?: { params?: { line?: number } }) => void;
34
- }
35
-
36
- const officialFileAddressFor = (workspacePathPkg as {
37
- fileAddressFor?: typeof fileAddressFor;
38
- }).fileAddressFor;
39
-
40
- async function openWorkspacePath(
41
- ctx: Context,
42
- path: string,
43
- ): Promise<void> {
44
- const remote = ctx.remote as unknown as { session?: { openWorkspacePath: (arg: { path: string }) => Promise<{ ok: boolean; error?: { message: string } }> } } | undefined;
45
- const remoteSession = remote?.session
46
- ?? (ctx.get?.('remote.session') as unknown as { openWorkspacePath: (arg: { path: string }) => Promise<{ ok: boolean; error?: { message: string } }> } | undefined)
47
- ?? ((ctx.get?.('remote') as unknown as { session?: { openWorkspacePath: (arg: { path: string }) => Promise<{ ok: boolean; error?: { message: string } }> } })?.session);
48
- if (remoteSession?.openWorkspacePath) {
49
- const result = await remoteSession.openWorkspacePath({ path });
50
- if (!result?.ok) {
51
- console.warn('[dsh-tidy-display] openWorkspacePath failed:', result?.error?.message);
52
- }
53
- } else {
54
- console.warn('[dsh-tidy-display] remote.session is not available');
55
- }
56
- }
57
-
58
- export type { ReaderBlockOwner } from './types.js';
59
- export { McpAppFrame } from './McpAppFrame.js';
60
- export const name = 'dsh-tidy-display-client';
61
- export const inject = ['slots', 'sessions', 'conversation', 'uiConversation', 'remote', 'remote.session'];
62
-
63
- export function apply(ctx: Context): void {
64
- const store = createReaderStore();
65
- // conversation.view is session-scoped, so session persist keys are
66
- // `dsh.reader.v1.<sessionId>`. One root instance keeps glass, fold
67
- // intensity, and open-mode on the unsuffixed `dsh.reader.v1` key.
68
- const prefs = store.create();
69
- installBetterDisplaySettings(ctx, prefs);
70
- installRailColors({
71
- subscribe: prefs.subscribe,
72
- getSnapshot: () => {
73
- const s = prefs.getSnapshot();
74
- return {
75
- navColor: s.railColor,
76
- navColorCustom: s.railColorCustom,
77
- navColorLight: s.railColorLight,
78
- navAccent: s.railAccent,
79
- navAccentCustom: s.railAccentCustom,
80
- navAccentLight: s.railAccentLight,
81
- };
82
- },
83
- }, () => document.querySelector('[data-conversation-scroll]'));
84
-
85
- // 原生「对话」视图的轨挂载:视图选择按会话记忆,老会话常停在对话视图——
86
- // 轨若只挂阅读视图,这些会话就没有轨。两个视图都挂(同 tidychat 的 utilities 槽位)。
87
- function NativeRailView(): React.ReactElement | null {
88
- const snap = React.useSyncExternalStore(prefs.subscribe, () => prefs.getSnapshot());
89
- const loadEarlierPattern = /^(加载更早|Load earlier|Load older)/;
90
- const hasMore = [...document.querySelectorAll('button')]
91
- .some((b) => loadEarlierPattern.test((b.textContent || '').trim()));
92
- return React.createElement(RailView, {
93
- enabled: snap.railEnabled !== false,
94
- side: snap.railSide === 'right' ? 'right' : 'left',
95
- style: snap.railStyle === 'dot' ? 'dot' : 'bar',
96
- ring: snap.railRing === true,
97
- hideOfficialNav: snap.hideOfficialNav !== false,
98
- hasMore,
99
- loadOlder: () => {
100
- const btn = [...document.querySelectorAll('button')]
101
- .find((b) => loadEarlierPattern.test((b.textContent || '').trim()));
102
- (btn as HTMLButtonElement | undefined)?.click();
103
- },
104
- });
105
- }
106
- (ctx.slots as unknown as { inject: (name: string, cb: () => unknown) => void }).inject(
107
- 'conversation.session.header.utilities',
108
- () => (ctx.slots as unknown as { register: (options: Record<string, unknown>, component: unknown) => unknown }).register(
109
- { name: 'conversation.session.header.utilities', id: 'tidy-display-nav' },
110
- NativeRailView,
111
- ),
112
- );
113
- ctx.slots.inject('conversation.chat.node', function* () {
114
- yield ctx.slots.register({
115
- name: 'conversation.view',
116
- id: 'reader',
117
- order: -5,
118
- label: () => '阅读',
119
- locale: 'chat',
120
- children: {
121
- 'dsh-tidy-display.block': { kind: 'chain', scope: 'session' },
122
- ...officialChildren(ctx.slots as unknown as CompositionRegistry),
123
- },
124
- store,
125
- inject: (sessionId: SessionId): ReaderInjected => {
126
- const session = () => {
127
- const current = ctx.sessions.binding(sessionId)?.session;
128
- if (!current) throw new Error('阅读页对应的会话已关闭。');
129
- return current;
130
- };
131
- return {
132
- openPrefs: prefs,
133
- officialImageLoader: Object.assign(
134
- (attachment: ImageAttachmentRef) => ctx.uiConversation.imageUrl(sessionId, attachment),
135
- { peek: (attachment: ImageAttachmentRef) => ctx.uiConversation.peekImageUrl(sessionId, attachment) },
136
- ),
137
- officialFileMentions: owner => ctx.get('chatFileMentions')?.forClosing(owner, sessionId),
138
- officialPreviewFile: path => {
139
- const cwd = ctx.sessions.list.getSnapshot().byId[sessionId]?.cwd;
140
- const sidebar = ctx.get('sidebarRight') as SidebarRightFace | undefined;
141
- if (!sidebar?.openResource) throw new Error('文件预览面板不可用。');
142
- sidebar.openResource((officialFileAddressFor ?? fileAddressFor)(sessionId, cwd, path));
143
- },
144
- officialHost: {
145
- getSnapshot: () => ctx.remote.$host,
146
- subscribe: listener => ctx.on('connection/reset', listener),
147
- },
148
- loadOlder: async () => { await session().loadOlder(); },
149
- loadImage: async attachment => {
150
- const receipt = await session().readAttachment(attachment.attachmentId);
151
- if (!receipt.ok) throw new Error(receipt.error.message);
152
- return { data: Uint8Array.from(receipt.value.data), mediaType: receipt.value.attachment.mediaType };
153
- },
154
- openFile: async (path, options) => {
155
- try {
156
- const cwd = ctx.sessions?.list?.getSnapshot?.()?.byId[sessionId]?.cwd;
157
- const sidebar = (
158
- ctx.get?.('sidebarRight')
159
- ?? (ctx as unknown as { sidebarRight?: SidebarRightFace }).sidebarRight
160
- ) as SidebarRightFace | undefined;
161
- await openDeliverableFile({
162
- path,
163
- mode: modeFromSnapshot(prefs),
164
- sessionId,
165
- cwd,
166
- resolveWorkspacePath,
167
- openExternal: async (absolutePath) => { await openWorkspacePath(ctx, absolutePath); },
168
- openSidebar: typeof sidebar?.openResource === 'function'
169
- ? (address) => { sidebar.openResource!(address, options?.line === undefined ? undefined : { params: { line: options.line } }); }
170
- : undefined,
171
- fileAddressFor: officialFileAddressFor ?? fileAddressFor,
172
- warn: (message, extra) => { console.warn(message, extra); },
173
- });
174
- } catch (error) {
175
- console.warn('[dsh-tidy-display] openFile error:', error);
176
- }
177
- },
178
- revealFile: async (path: string) => {
179
- try {
180
- const cwd = ctx.sessions?.list?.getSnapshot?.()?.byId[sessionId]?.cwd;
181
- const targetPath = resolveWorkspacePath(cwd, path);
182
- // 1. Try dedicated host endpoint for native file highlighting (open -R / explorer /select)
183
- try {
184
- const res = await fetch('/tidy-display/reveal', {
185
- method: 'POST',
186
- headers: { 'Content-Type': 'application/json' },
187
- body: JSON.stringify({ path: targetPath }),
188
- });
189
- if (res.ok) {
190
- const data = await res.json();
191
- if (data.ok) return;
192
- }
193
- } catch {
194
- // Server endpoint not yet available, fallback to directory open
195
- }
196
-
197
- // 2. Fallback to official opener with parent directory
198
- const parentDir = dirname(targetPath);
199
- const remote = ctx.remote as unknown as { session?: { openWorkspacePath: (arg: { path: string }) => Promise<{ ok: boolean; error?: { message: string } }> } } | undefined;
200
- const remoteSession = remote?.session
201
- ?? (ctx.get?.('remote.session') as unknown as { openWorkspacePath: (arg: { path: string }) => Promise<{ ok: boolean; error?: { message: string } }> } | undefined);
202
- if (remoteSession?.openWorkspacePath) {
203
- await remoteSession.openWorkspacePath({ path: parentDir });
204
- }
205
- } catch (error) {
206
- console.warn('[dsh-tidy-display] revealFile error:', error);
207
- }
208
- },
209
- forkAt: (seq: number) => {
210
- // A missing anchor would silently fork the whole session instead of
211
- // the intended turn prefix, so refuse it loudly rather than guessing.
212
- if (typeof seq !== 'number' || !Number.isFinite(seq)) {
213
- console.warn('[dsh-tidy-display] fork refused: missing anchor seq');
214
- return;
215
- }
216
- try {
217
- const sessionsApi = ctx.sessions as unknown as {
218
- fork: (arg: { sessionId: string; atSeq: number; increaseTitle: boolean }) => Promise<string>;
219
- open: (sessionId: string) => void;
220
- } | undefined;
221
- if (sessionsApi?.fork) {
222
- sessionsApi.fork({ sessionId, atSeq: seq, increaseTitle: true })
223
- .then(childId => { sessionsApi.open?.(childId); })
224
- .catch(err => { console.warn('[dsh-tidy-display] fork failed:', err); });
225
- }
226
- } catch (error) {
227
- console.warn('[dsh-tidy-display] forkAt error:', error);
228
- }
229
- },
230
- loadThrough: async (seq: unknown) => {
231
- try {
232
- const current = session() as unknown as { loadThrough?: (seq: unknown) => Promise<void> };
233
- if (typeof current?.loadThrough === 'function') {
234
- await current.loadThrough(seq);
235
- } else {
236
- await session().loadOlder();
237
- }
238
- } catch (error) {
239
- console.warn('[dsh-tidy-display] loadThrough error:', error);
240
- }
241
- },
242
- fillComposer: (text: string) => {
243
- // Sanctioned path: the conversation input shell owns the Lexical
244
- // editor, so setDraft lands in the draft store deterministically.
245
- try {
246
- const conversation = (ctx as unknown as { conversation?: ConversationFace }).conversation;
247
- const shell = conversation?.input?.shell?.(sessionId);
248
- if (shell && typeof shell.setDraft === 'function') {
249
- shell.setDraft(text);
250
- return true;
251
- }
252
- } catch {
253
- // Fall through to the DOM path below.
254
- }
255
- try {
256
- return fillComposerDom(text);
257
- } catch {
258
- return false;
259
- }
260
- },
261
-
262
- };
263
- },
264
- }, Reader);
265
- yield installOfficialSlots(ctx);
266
- yield installReaderEntry(ctx);
267
- });
268
- }
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import type {} from '@deepseek-ai/dsh-api-remotes/client';
3
+ import type {} from '@deepseek-ai/dsh-api-session-controller/client';
4
+ import type {} from '@deepseek-ai/dsh-client-connection/client';
5
+ import type { SessionId } from '@deepseek-ai/dsh-session/types';
6
+ import { resolveWorkspacePath } from '@deepseek-ai/dsh-util-workspace-path';
7
+ import * as workspacePathPkg from '@deepseek-ai/dsh-util-workspace-path';
8
+ import { dirname } from './deliverables.js';
9
+ import type {} from '@deepseek-ai/dsh-client-ui-conversation/client';
10
+ import type {} from '@deepseek-ai/dsh-client-ui-renderer/client';
11
+ import { Reader } from './Reader.js';
12
+ import { createReaderStore } from './store.js';
13
+ import { installReaderEntry } from './entry.js';
14
+ import { installBetterDisplaySettings } from './settings.js';
15
+ import { installConfigBridge } from './config-bridge.js';
16
+ import { RailView } from './rail/RailView.js';
17
+ import { installRailColors } from './rail/colors.js';
18
+ import { fillComposerDom } from './mcp-app.js';
19
+ import { fileAddressFor, modeFromSnapshot, openDeliverableFile } from './open-file.js';
20
+ import type { ReaderInjected } from './types.js';
21
+ import type { ImageAttachmentRef } from '@deepseek-ai/dsh-attachment';
22
+ import * as React from 'react';
23
+ import { installOfficialSlots, officialChildren, type CompositionRegistry } from './official-slots.js';
24
+
25
+ /** Structural face of the sanctioned per-session composer writer. */
26
+ interface ComposerShell {
27
+ setDraft: (text: string) => void;
28
+ }
29
+ interface ConversationFace {
30
+ input?: { shell?: (id: SessionId) => ComposerShell };
31
+ }
32
+
33
+ interface SidebarRightFace {
34
+ openResource?: (address: string, options?: { params?: { line?: number } }) => void;
35
+ }
36
+
37
+ const officialFileAddressFor = (workspacePathPkg as {
38
+ fileAddressFor?: typeof fileAddressFor;
39
+ }).fileAddressFor;
40
+
41
+ async function openWorkspacePath(
42
+ ctx: Context,
43
+ path: string,
44
+ ): Promise<void> {
45
+ const remote = ctx.remote as unknown as { session?: { openWorkspacePath: (arg: { path: string }) => Promise<{ ok: boolean; error?: { message: string } }> } } | undefined;
46
+ const remoteSession = remote?.session
47
+ ?? (ctx.get?.('remote.session') as unknown as { openWorkspacePath: (arg: { path: string }) => Promise<{ ok: boolean; error?: { message: string } }> } | undefined)
48
+ ?? ((ctx.get?.('remote') as unknown as { session?: { openWorkspacePath: (arg: { path: string }) => Promise<{ ok: boolean; error?: { message: string } }> } })?.session);
49
+ if (remoteSession?.openWorkspacePath) {
50
+ const result = await remoteSession.openWorkspacePath({ path });
51
+ if (!result?.ok) {
52
+ console.warn('[dsh-tidy-display] openWorkspacePath failed:', result?.error?.message);
53
+ }
54
+ } else {
55
+ console.warn('[dsh-tidy-display] remote.session is not available');
56
+ }
57
+ }
58
+
59
+ export type { ReaderBlockOwner } from './types.js';
60
+ export { McpAppFrame } from './McpAppFrame.js';
61
+ export const name = 'dsh-tidy-display-client';
62
+ export const inject = ['slots', 'sessions', 'conversation', 'uiConversation', 'remote', 'remote.session'];
63
+
64
+ export function apply(ctx: Context): void {
65
+ const store = createReaderStore();
66
+ // conversation.view is session-scoped, so session persist keys are
67
+ // `dsh.reader.v1.<sessionId>`. One root instance keeps glass, fold
68
+ // intensity, and open-mode on the unsuffixed `dsh.reader.v1` key.
69
+ const prefs = store.create();
70
+ installBetterDisplaySettings(ctx, prefs);
71
+ installConfigBridge(ctx, prefs as unknown as Parameters<typeof installConfigBridge>[1]);
72
+ installRailColors({
73
+ subscribe: prefs.subscribe,
74
+ getSnapshot: () => {
75
+ const s = prefs.getSnapshot();
76
+ return {
77
+ navColor: s.railColor,
78
+ navColorCustom: s.railColorCustom,
79
+ navColorLight: s.railColorLight,
80
+ navAccent: s.railAccent,
81
+ navAccentCustom: s.railAccentCustom,
82
+ navAccentLight: s.railAccentLight,
83
+ };
84
+ },
85
+ }, () => document.querySelector('[data-conversation-scroll]'));
86
+
87
+ // 原生「对话」视图的轨挂载:视图选择按会话记忆,老会话常停在对话视图——
88
+ // 轨若只挂阅读视图,这些会话就没有轨。两个视图都挂(同 tidychat 的 utilities 槽位)。
89
+ function NativeRailView(): React.ReactElement | null {
90
+ const snap = React.useSyncExternalStore(prefs.subscribe, () => prefs.getSnapshot());
91
+ const loadEarlierPattern = /^(加载更早|Load earlier|Load older)/;
92
+ const hasMore = [...document.querySelectorAll('button')]
93
+ .some((b) => loadEarlierPattern.test((b.textContent || '').trim()));
94
+ return React.createElement(RailView, {
95
+ enabled: snap.railEnabled !== false,
96
+ side: snap.railSide === 'right' ? 'right' : 'left',
97
+ style: snap.railStyle === 'dot' ? 'dot' : 'bar',
98
+ ring: snap.railRing === true,
99
+ hideOfficialNav: snap.hideOfficialNav !== false,
100
+ hasMore,
101
+ loadOlder: () => {
102
+ const btn = [...document.querySelectorAll('button')]
103
+ .find((b) => loadEarlierPattern.test((b.textContent || '').trim()));
104
+ (btn as HTMLButtonElement | undefined)?.click();
105
+ },
106
+ });
107
+ }
108
+ (ctx.slots as unknown as { inject: (name: string, cb: () => unknown) => void }).inject(
109
+ 'conversation.session.header.utilities',
110
+ () => (ctx.slots as unknown as { register: (options: Record<string, unknown>, component: unknown) => unknown }).register(
111
+ { name: 'conversation.session.header.utilities', id: 'tidy-display-nav' },
112
+ NativeRailView,
113
+ ),
114
+ );
115
+ ctx.slots.inject('conversation.chat.node', function* () {
116
+ yield ctx.slots.register({
117
+ name: 'conversation.view',
118
+ id: 'reader',
119
+ order: -5,
120
+ label: () => '阅读',
121
+ locale: 'chat',
122
+ children: {
123
+ 'dsh-tidy-display.block': { kind: 'chain', scope: 'session' },
124
+ ...officialChildren(ctx.slots as unknown as CompositionRegistry),
125
+ },
126
+ store,
127
+ inject: (sessionId: SessionId): ReaderInjected => {
128
+ const session = () => {
129
+ const current = ctx.sessions.binding(sessionId)?.session;
130
+ if (!current) throw new Error('阅读页对应的会话已关闭。');
131
+ return current;
132
+ };
133
+ return {
134
+ openPrefs: prefs,
135
+ officialImageLoader: Object.assign(
136
+ (attachment: ImageAttachmentRef) => ctx.uiConversation.imageUrl(sessionId, attachment),
137
+ { peek: (attachment: ImageAttachmentRef) => ctx.uiConversation.peekImageUrl(sessionId, attachment) },
138
+ ),
139
+ officialFileMentions: owner => ctx.get('chatFileMentions')?.forClosing(owner, sessionId),
140
+ officialPreviewFile: path => {
141
+ const cwd = ctx.sessions.list.getSnapshot().byId[sessionId]?.cwd;
142
+ const sidebar = ctx.get('sidebarRight') as SidebarRightFace | undefined;
143
+ if (!sidebar?.openResource) throw new Error('文件预览面板不可用。');
144
+ sidebar.openResource((officialFileAddressFor ?? fileAddressFor)(sessionId, cwd, path));
145
+ },
146
+ officialHost: {
147
+ getSnapshot: () => ctx.remote.$host,
148
+ subscribe: listener => ctx.on('connection/reset', listener),
149
+ },
150
+ loadOlder: async () => { await session().loadOlder(); },
151
+ loadImage: async attachment => {
152
+ const receipt = await session().readAttachment(attachment.attachmentId);
153
+ if (!receipt.ok) throw new Error(receipt.error.message);
154
+ return { data: Uint8Array.from(receipt.value.data), mediaType: receipt.value.attachment.mediaType };
155
+ },
156
+ openFile: async (path, options) => {
157
+ try {
158
+ const cwd = ctx.sessions?.list?.getSnapshot?.()?.byId[sessionId]?.cwd;
159
+ const sidebar = (
160
+ ctx.get?.('sidebarRight')
161
+ ?? (ctx as unknown as { sidebarRight?: SidebarRightFace }).sidebarRight
162
+ ) as SidebarRightFace | undefined;
163
+ await openDeliverableFile({
164
+ path,
165
+ mode: modeFromSnapshot(prefs),
166
+ sessionId,
167
+ cwd,
168
+ resolveWorkspacePath,
169
+ openExternal: async (absolutePath) => { await openWorkspacePath(ctx, absolutePath); },
170
+ openSidebar: typeof sidebar?.openResource === 'function'
171
+ ? (address) => { sidebar.openResource!(address, options?.line === undefined ? undefined : { params: { line: options.line } }); }
172
+ : undefined,
173
+ fileAddressFor: officialFileAddressFor ?? fileAddressFor,
174
+ warn: (message, extra) => { console.warn(message, extra); },
175
+ });
176
+ } catch (error) {
177
+ console.warn('[dsh-tidy-display] openFile error:', error);
178
+ }
179
+ },
180
+ revealFile: async (path: string) => {
181
+ try {
182
+ const cwd = ctx.sessions?.list?.getSnapshot?.()?.byId[sessionId]?.cwd;
183
+ const targetPath = resolveWorkspacePath(cwd, path);
184
+ // 1. Try dedicated host endpoint for native file highlighting (open -R / explorer /select)
185
+ try {
186
+ const res = await fetch('/tidy-display/reveal', {
187
+ method: 'POST',
188
+ headers: { 'Content-Type': 'application/json' },
189
+ body: JSON.stringify({ path: targetPath }),
190
+ });
191
+ if (res.ok) {
192
+ const data = await res.json();
193
+ if (data.ok) return;
194
+ }
195
+ } catch {
196
+ // Server endpoint not yet available, fallback to directory open
197
+ }
198
+
199
+ // 2. Fallback to official opener with parent directory
200
+ const parentDir = dirname(targetPath);
201
+ const remote = ctx.remote as unknown as { session?: { openWorkspacePath: (arg: { path: string }) => Promise<{ ok: boolean; error?: { message: string } }> } } | undefined;
202
+ const remoteSession = remote?.session
203
+ ?? (ctx.get?.('remote.session') as unknown as { openWorkspacePath: (arg: { path: string }) => Promise<{ ok: boolean; error?: { message: string } }> } | undefined);
204
+ if (remoteSession?.openWorkspacePath) {
205
+ await remoteSession.openWorkspacePath({ path: parentDir });
206
+ }
207
+ } catch (error) {
208
+ console.warn('[dsh-tidy-display] revealFile error:', error);
209
+ }
210
+ },
211
+ forkAt: (seq: number) => {
212
+ // A missing anchor would silently fork the whole session instead of
213
+ // the intended turn prefix, so refuse it loudly rather than guessing.
214
+ if (typeof seq !== 'number' || !Number.isFinite(seq)) {
215
+ console.warn('[dsh-tidy-display] fork refused: missing anchor seq');
216
+ return;
217
+ }
218
+ try {
219
+ const sessionsApi = ctx.sessions as unknown as {
220
+ fork: (arg: { sessionId: string; atSeq: number; increaseTitle: boolean }) => Promise<string>;
221
+ open: (sessionId: string) => void;
222
+ } | undefined;
223
+ if (sessionsApi?.fork) {
224
+ sessionsApi.fork({ sessionId, atSeq: seq, increaseTitle: true })
225
+ .then(childId => { sessionsApi.open?.(childId); })
226
+ .catch(err => { console.warn('[dsh-tidy-display] fork failed:', err); });
227
+ }
228
+ } catch (error) {
229
+ console.warn('[dsh-tidy-display] forkAt error:', error);
230
+ }
231
+ },
232
+ loadThrough: async (seq: unknown) => {
233
+ try {
234
+ const current = session() as unknown as { loadThrough?: (seq: unknown) => Promise<void> };
235
+ if (typeof current?.loadThrough === 'function') {
236
+ await current.loadThrough(seq);
237
+ } else {
238
+ await session().loadOlder();
239
+ }
240
+ } catch (error) {
241
+ console.warn('[dsh-tidy-display] loadThrough error:', error);
242
+ }
243
+ },
244
+ fillComposer: (text: string) => {
245
+ // Sanctioned path: the conversation input shell owns the Lexical
246
+ // editor, so setDraft lands in the draft store deterministically.
247
+ try {
248
+ const conversation = (ctx as unknown as { conversation?: ConversationFace }).conversation;
249
+ const shell = conversation?.input?.shell?.(sessionId);
250
+ if (shell && typeof shell.setDraft === 'function') {
251
+ shell.setDraft(text);
252
+ return true;
253
+ }
254
+ } catch {
255
+ // Fall through to the DOM path below.
256
+ }
257
+ try {
258
+ return fillComposerDom(text);
259
+ } catch {
260
+ return false;
261
+ }
262
+ },
263
+
264
+ };
265
+ },
266
+ }, Reader);
267
+ yield installOfficialSlots(ctx);
268
+ yield installReaderEntry(ctx);
269
+ });
270
+ }
@@ -20,6 +20,14 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
20
20
  * standalone settings.section.
21
21
  */
22
22
  'dsh-family.tab': { kind: 'list'; scope: 'root'; owner: Record<string, unknown> };
23
+ /**
24
+ * Plugins-page configuration card (official ui-plugin-manager contract):
25
+ * keyed by the bundle's package name, rendered on the bundle's page with
26
+ * `{ view: 'page', form }` owner props. This plugin ignores the page's
27
+ * `form` (its namespace is the entry id `tidy-display`, not the package
28
+ * name) and renders over the shared OpenPrefs face instead.
29
+ */
30
+ 'plugins.bundle.config': { kind: 'keyed'; scope: 'root'; owner: Record<string, unknown> };
23
31
  }
24
32
  interface LocaleNamespaceMap {
25
33
  'tidy-display': SettingsCopyKey;
@@ -2,6 +2,7 @@ import type { Context } from '@deepseek-ai/cordis';
2
2
  import type {} from './settings-slots.js';
3
3
  import { settingsCopyFor, zh, en, fr, de, it, ru, es } from './settings-copy.js';
4
4
  import { SettingsSection, type BetterDisplaySettingsInjected, type OpenPrefs } from './SettingsSection.js';
5
+ import { installPluginConfigCard } from './config-card.js';
5
6
  import { firstSessionId, skillsFromListResult, type SkillStatusProbe } from './skill-status.js';
6
7
  import type { HostSkillStatus } from '../skill-status.js';
7
8
 
@@ -70,4 +71,5 @@ export function installBetterDisplaySettings(ctx: Context, prefs: OpenPrefs): vo
70
71
  locale: locale?.bind ? 'tidy-display' : undefined,
71
72
  inject: injected,
72
73
  }, SettingsSection));
74
+ installPluginConfigCard(ctx, injected);
73
75
  }