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.
- package/lib/client.js +125 -0
- package/lib/client.js.map +1 -1
- package/lib/dsh-tidy-display.js +81 -1
- package/lib/types/client/config-bridge.d.ts +10 -0
- package/lib/types/client/config-bridge.d.ts.map +1 -0
- package/lib/types/client/config-bridge.js +89 -0
- package/lib/types/client/config-bridge.js.map +1 -0
- package/lib/types/client/config-card.d.ts +15 -0
- package/lib/types/client/config-card.d.ts.map +1 -0
- package/lib/types/client/config-card.js +17 -0
- package/lib/types/client/config-card.js.map +1 -0
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/index.js +2 -0
- package/lib/types/client/index.js.map +1 -1
- package/lib/types/client/settings-slots.d.ts +12 -0
- package/lib/types/client/settings-slots.d.ts.map +1 -1
- package/lib/types/client/settings.d.ts.map +1 -1
- package/lib/types/client/settings.js +2 -0
- package/lib/types/client/settings.js.map +1 -1
- package/lib/types/config.d.ts +7 -0
- package/lib/types/config.d.ts.map +1 -0
- package/lib/types/config.js +48 -0
- package/lib/types/config.js.map +1 -0
- package/lib/types/dsh-tidy-display.d.ts +2 -0
- package/lib/types/dsh-tidy-display.d.ts.map +1 -1
- package/lib/types/dsh-tidy-display.js +1 -0
- package/lib/types/dsh-tidy-display.js.map +1 -1
- package/lib/types/reader-prefs.d.ts +30 -0
- package/lib/types/reader-prefs.d.ts.map +1 -0
- package/lib/types/reader-prefs.js +44 -0
- package/lib/types/reader-prefs.js.map +1 -0
- package/package.json +142 -141
- package/src/client/config-bridge.ts +118 -0
- package/src/client/config-card.tsx +22 -0
- package/src/client/index.tsx +270 -268
- package/src/client/settings-slots.ts +8 -0
- package/src/client/settings.tsx +2 -0
- package/src/config.ts +53 -0
- package/src/dsh-tidy-display.ts +3 -0
- package/src/reader-prefs.ts +67 -0
package/src/client/index.tsx
CHANGED
|
@@ -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 {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
20
|
-
import type {
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
?? (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
export {
|
|
60
|
-
export
|
|
61
|
-
export const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
sidebar.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
await
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
return
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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;
|
package/src/client/settings.tsx
CHANGED
|
@@ -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
|
}
|