dsh-better-sidebar 0.10.0
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/LICENSE +21 -0
- package/README.md +139 -0
- package/README_EN.md +139 -0
- package/lib/client-docx.js +7649 -0
- package/lib/client-editor.js +32677 -0
- package/lib/client-pptx.js +63438 -0
- package/lib/client-registry.js +8021 -0
- package/lib/client-terminal.js +8060 -0
- package/lib/client-xlsx.js +359755 -0
- package/lib/client.js +8021 -0
- package/lib/index.js +2604 -0
- package/lib/invariant.js +22 -0
- package/lib/types/agent-pty.d.ts +220 -0
- package/lib/types/browser-probe.d.ts +15 -0
- package/lib/types/bundle-route.d.ts +13 -0
- package/lib/types/client/BrowserView.d.ts +22 -0
- package/lib/types/client/DiffTab.d.ts +6 -0
- package/lib/types/client/DiffView.d.ts +51 -0
- package/lib/types/client/EditorHost.d.ts +10 -0
- package/lib/types/client/ExplorerView.d.ts +9 -0
- package/lib/types/client/GitView.d.ts +8 -0
- package/lib/types/client/OrphanedTab.d.ts +11 -0
- package/lib/types/client/PdfView.d.ts +6 -0
- package/lib/types/client/PptxView.d.ts +6 -0
- package/lib/types/client/SandboxStatusBar.d.ts +10 -0
- package/lib/types/client/SideCardSection.d.ts +27 -0
- package/lib/types/client/Sidebar.d.ts +6 -0
- package/lib/types/client/SubagentView.d.ts +16 -0
- package/lib/types/client/TabBar.d.ts +38 -0
- package/lib/types/client/TerminalView.d.ts +8 -0
- package/lib/types/client/TextEditor.d.ts +10 -0
- package/lib/types/client/api.d.ts +170 -0
- package/lib/types/client/binary-download.d.ts +12 -0
- package/lib/types/client/breakpoints.d.ts +12 -0
- package/lib/types/client/browser.d.ts +50 -0
- package/lib/types/client/builtins/index.d.ts +17 -0
- package/lib/types/client/builtins/tabs.d.ts +6 -0
- package/lib/types/client/builtins/viewers.d.ts +3 -0
- package/lib/types/client/chunk-loader.d.ts +74 -0
- package/lib/types/client/chunks/docx.d.ts +8 -0
- package/lib/types/client/chunks/editor.d.ts +9 -0
- package/lib/types/client/chunks/pptx.d.ts +8 -0
- package/lib/types/client/chunks/terminal.d.ts +9 -0
- package/lib/types/client/chunks/xlsx.d.ts +9 -0
- package/lib/types/client/cm-themes.d.ts +24 -0
- package/lib/types/client/conversation-draft.d.ts +14 -0
- package/lib/types/client/docx-view.d.ts +8 -0
- package/lib/types/client/editor-load.d.ts +66 -0
- package/lib/types/client/icons.d.ts +47 -0
- package/lib/types/client/image-types.d.ts +3 -0
- package/lib/types/client/ime-guard.d.ts +36 -0
- package/lib/types/client/index.d.ts +10 -0
- package/lib/types/client/intercept.d.ts +20 -0
- package/lib/types/client/lang.d.ts +12 -0
- package/lib/types/client/lazy-chunk.d.ts +25 -0
- package/lib/types/client/link-intercept.d.ts +35 -0
- package/lib/types/client/locales.d.ts +237 -0
- package/lib/types/client/office-shared.d.ts +33 -0
- package/lib/types/client/office-types.d.ts +36 -0
- package/lib/types/client/office-view.d.ts +12 -0
- package/lib/types/client/openpath-intercept.d.ts +41 -0
- package/lib/types/client/paths.d.ts +19 -0
- package/lib/types/client/pdf-types.d.ts +2 -0
- package/lib/types/client/prefs.d.ts +30 -0
- package/lib/types/client/produced-files.d.ts +27 -0
- package/lib/types/client/selection-payload.d.ts +27 -0
- package/lib/types/client/service.d.ts +214 -0
- package/lib/types/client/split-pane.d.ts +29 -0
- package/lib/types/client/state.d.ts +322 -0
- package/lib/types/client/subagent-activity.d.ts +35 -0
- package/lib/types/client/subagent-detect.d.ts +47 -0
- package/lib/types/client/subagent-jobs.d.ts +63 -0
- package/lib/types/client/theme.d.ts +28 -0
- package/lib/types/client/xlsx-to-univer.d.ts +33 -0
- package/lib/types/client/xlsx-view.d.ts +10 -0
- package/lib/types/config.d.ts +41 -0
- package/lib/types/context-types.d.ts +431 -0
- package/lib/types/fs-tree.d.ts +41 -0
- package/lib/types/git.d.ts +75 -0
- package/lib/types/html-route.d.ts +48 -0
- package/lib/types/index.d.ts +39 -0
- package/lib/types/invariant.d.ts +15 -0
- package/lib/types/jobs-routes.d.ts +45 -0
- package/lib/types/prefs-shared.d.ts +106 -0
- package/lib/types/pty-manager.d.ts +76 -0
- package/lib/types/tools.d.ts +28 -0
- package/lib/types/trust-fence.d.ts +24 -0
- package/lib/types/wire.d.ts +38 -0
- package/package.json +168 -0
- package/src/agent-pty.ts +519 -0
- package/src/browser-probe.ts +26 -0
- package/src/bundle-route.ts +130 -0
- package/src/client/BrowserView.tsx +253 -0
- package/src/client/DiffTab.tsx +110 -0
- package/src/client/DiffView.tsx +266 -0
- package/src/client/EditorHost.tsx +101 -0
- package/src/client/ExplorerView.tsx +283 -0
- package/src/client/GitView.tsx +540 -0
- package/src/client/OrphanedTab.tsx +27 -0
- package/src/client/PdfView.tsx +110 -0
- package/src/client/PptxView.tsx +131 -0
- package/src/client/SandboxStatusBar.tsx +60 -0
- package/src/client/SideCardSection.module.css +271 -0
- package/src/client/SideCardSection.tsx +426 -0
- package/src/client/Sidebar.tsx +861 -0
- package/src/client/SubagentView.module.css +547 -0
- package/src/client/SubagentView.tsx +866 -0
- package/src/client/TabBar.tsx +188 -0
- package/src/client/TerminalView.tsx +233 -0
- package/src/client/TextEditor.tsx +382 -0
- package/src/client/api.ts +215 -0
- package/src/client/binary-download.tsx +23 -0
- package/src/client/breakpoints.ts +51 -0
- package/src/client/browser.ts +119 -0
- package/src/client/builtins/index.ts +33 -0
- package/src/client/builtins/tabs.tsx +211 -0
- package/src/client/builtins/viewers.tsx +151 -0
- package/src/client/chunk-loader.ts +196 -0
- package/src/client/chunks/docx.tsx +8 -0
- package/src/client/chunks/editor.tsx +9 -0
- package/src/client/chunks/pptx.tsx +8 -0
- package/src/client/chunks/terminal.tsx +9 -0
- package/src/client/chunks/xlsx.tsx +9 -0
- package/src/client/cm-themes.ts +129 -0
- package/src/client/conversation-draft.ts +29 -0
- package/src/client/css-modules.d.ts +5 -0
- package/src/client/docx-view.tsx +113 -0
- package/src/client/editor-load.ts +92 -0
- package/src/client/icons.tsx +137 -0
- package/src/client/image-types.ts +8 -0
- package/src/client/ime-guard.ts +47 -0
- package/src/client/index.tsx +238 -0
- package/src/client/intercept.tsx +94 -0
- package/src/client/lang.ts +95 -0
- package/src/client/layout.css +54 -0
- package/src/client/lazy-chunk.tsx +89 -0
- package/src/client/link-intercept.ts +66 -0
- package/src/client/locales.ts +476 -0
- package/src/client/office-shared.tsx +40 -0
- package/src/client/office-types.ts +48 -0
- package/src/client/office-view.tsx +12 -0
- package/src/client/openpath-intercept.ts +62 -0
- package/src/client/paths.ts +28 -0
- package/src/client/pdf-types.ts +4 -0
- package/src/client/prefs.ts +100 -0
- package/src/client/produced-files.ts +87 -0
- package/src/client/selection-payload.ts +86 -0
- package/src/client/service.ts +434 -0
- package/src/client/sidebar.module.css +1917 -0
- package/src/client/split-pane.tsx +292 -0
- package/src/client/state.ts +1048 -0
- package/src/client/subagent-activity.ts +67 -0
- package/src/client/subagent-detect.ts +125 -0
- package/src/client/subagent-jobs.ts +161 -0
- package/src/client/theme.ts +44 -0
- package/src/client/xlsx-to-univer.ts +260 -0
- package/src/client/xlsx-view.tsx +116 -0
- package/src/config.ts +95 -0
- package/src/context-types.ts +445 -0
- package/src/fs-tree.ts +115 -0
- package/src/git.ts +236 -0
- package/src/html-route.ts +70 -0
- package/src/index.ts +897 -0
- package/src/invariant.ts +32 -0
- package/src/jobs-routes.ts +257 -0
- package/src/prefs-shared.ts +127 -0
- package/src/pty-manager.ts +199 -0
- package/src/tools.ts +477 -0
- package/src/trust-fence.ts +77 -0
- package/src/wire.ts +94 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Syntax highlighting for the file editor: extension → CodeMirror language
|
|
3
|
+
* mapping. The key derivation is pure and unit-tested; the factories pull in
|
|
4
|
+
* the CodeMirror language packages (bundled into the client).
|
|
5
|
+
*/
|
|
6
|
+
import { Language, LanguageSupport } from '@codemirror/language';
|
|
7
|
+
/** The lowercased file extension of a path ('' when none). */
|
|
8
|
+
export declare function extOf(path: string): string;
|
|
9
|
+
/** Language key for an extension, or null for plain text. Pure (tested). */
|
|
10
|
+
export declare function languageKeyForExt(ext: string): string | null;
|
|
11
|
+
/** The CodeMirror language support for a path, or null for plain text. */
|
|
12
|
+
export declare function languageForPath(path: string): Language | LanguageSupport | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy chunk view wrapper: mounts a component that lives in a lazy chunk,
|
|
3
|
+
* showing a loading placeholder while the chunk script loads and an error +
|
|
4
|
+
* retry affordance on failure. Used by the built-in tab/viewer descriptors.
|
|
5
|
+
*
|
|
6
|
+
* Contract note: {@link lazyChunkComponent} returns a plain render-prop
|
|
7
|
+
* function — the descriptor contract is `component: (props) => ReactNode`,
|
|
8
|
+
* and the repo renders descriptors BOTH ways: Sidebar calls
|
|
9
|
+
* `descriptor.component(props)` directly, EditorHost renders it via
|
|
10
|
+
* `createElement`. The wrapper function body therefore contains no hooks;
|
|
11
|
+
* all state lives in the inner {@link LazyChunkView} component.
|
|
12
|
+
*/
|
|
13
|
+
import { type ComponentType, type ReactNode } from 'react';
|
|
14
|
+
import { type ChunkExports, type ChunkName } from './chunk-loader.ts';
|
|
15
|
+
/**
|
|
16
|
+
* Build a descriptor-compatible lazy wrapper for a chunk-resident component.
|
|
17
|
+
* The returned function is the descriptor `component` itself: it returns an
|
|
18
|
+
* element and never calls hooks, so both invocation styles (plain function
|
|
19
|
+
* call and createElement/JSX render) work. `pick` must be a module-level
|
|
20
|
+
* function (stable identity) — an inline lambda would re-trigger the load
|
|
21
|
+
* effect on every render.
|
|
22
|
+
* @param chunk - the chunk name (see chunk-loader.ts).
|
|
23
|
+
* @param pick - select the component from the chunk's exports.
|
|
24
|
+
*/
|
|
25
|
+
export declare function lazyChunkComponent<P extends object>(chunk: ChunkName, pick: (mod: ChunkExports) => ComponentType<P> | undefined): (props: P) => ReactNode;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat/GUI external-link interception: clicking an http(s) link that points
|
|
3
|
+
* OUTSIDE the GUI (chat messages, tool rows, prose mentions) opens the
|
|
4
|
+
* sidebar browser instead of a new browser tab. Gated by BOTH the
|
|
5
|
+
* `browserInterceptLinks` pref and the browser tab's enable switch; a
|
|
6
|
+
* Ctrl/Cmd/Shift/Alt-modified click always bypasses the takeover so the
|
|
7
|
+
* user can still force a real browser tab.
|
|
8
|
+
*
|
|
9
|
+
* Only the GUI's OWN document is watched — links inside the browser tab's
|
|
10
|
+
* sandboxed iframe live in another document and never bubble here (and
|
|
11
|
+
* their clicks must keep working inside the sidebar).
|
|
12
|
+
*/
|
|
13
|
+
/** The pure decision: the URL to open in the sidebar, or null to let the
|
|
14
|
+
* click fall through. Extracted so the policy is unit-testable without a
|
|
15
|
+
* DOM. `anchorHref` must be the ABSOLUTE href (`<a>.href` already is). */
|
|
16
|
+
export declare function shouldInterceptLink(anchorHref: string, selfOrigin: string): string | null;
|
|
17
|
+
/** Whether a left-click may be taken over (unmodified left click only). */
|
|
18
|
+
export declare function isPlainLeftClick(event: {
|
|
19
|
+
button: number;
|
|
20
|
+
metaKey: boolean;
|
|
21
|
+
ctrlKey: boolean;
|
|
22
|
+
shiftKey: boolean;
|
|
23
|
+
altKey: boolean;
|
|
24
|
+
}): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Register the document-level click capture that funnels external links
|
|
27
|
+
* into the sidebar browser. Returns the disposer (HMR-safe).
|
|
28
|
+
*/
|
|
29
|
+
export declare function registerLinkInterception(opts: {
|
|
30
|
+
takeoverEnabled: () => boolean;
|
|
31
|
+
/** Open the sidebar browser tab at `url` (the caller resolves the session). */
|
|
32
|
+
openInSidebar: (url: string) => void;
|
|
33
|
+
/** The GUI's own origin (window.location.origin at registration). */
|
|
34
|
+
selfOrigin: string;
|
|
35
|
+
}): () => void;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal zh/en copy for the sidebar. The copy follows the DSH i18n system:
|
|
3
|
+
* the client apply attaches the locale service (`ctx.locale`, provided by
|
|
4
|
+
* `@deepseek-ai/dsh-client-locale`) through {@link attachLocale}, and
|
|
5
|
+
* `t()`/`isZh()` resolve the active locale from it — the Host-backed
|
|
6
|
+
* `locale.preference` wins over the raw browser language and switches live.
|
|
7
|
+
* Without an attached service (standalone/test compositions) the browser
|
|
8
|
+
* language is used, matching the previous behavior. The dictionaries are
|
|
9
|
+
* also registered into the DSH locale registry under {@link LOCALE_NS}.
|
|
10
|
+
*/
|
|
11
|
+
/** The zh dictionary (also registered into the DSH locale registry under {@link LOCALE_NS}). */
|
|
12
|
+
export declare const zh: {
|
|
13
|
+
explorer: string;
|
|
14
|
+
git: string;
|
|
15
|
+
terminal: string;
|
|
16
|
+
editor: string;
|
|
17
|
+
newTab: string;
|
|
18
|
+
openExplorer: string;
|
|
19
|
+
openGit: string;
|
|
20
|
+
newTerminal: string;
|
|
21
|
+
terminalLimit: string;
|
|
22
|
+
close: string;
|
|
23
|
+
collapse: string;
|
|
24
|
+
expand: string;
|
|
25
|
+
collapseBottomPanel: string;
|
|
26
|
+
expandBottomPanel: string;
|
|
27
|
+
terminalError: string;
|
|
28
|
+
terminalConnectFailed: string;
|
|
29
|
+
terminalRetry: string;
|
|
30
|
+
preview: string;
|
|
31
|
+
edit: string;
|
|
32
|
+
refresh: string;
|
|
33
|
+
save: string;
|
|
34
|
+
saved: string;
|
|
35
|
+
unsaved: string;
|
|
36
|
+
saveFailed: string;
|
|
37
|
+
truncation: string;
|
|
38
|
+
binary: string;
|
|
39
|
+
loading: string;
|
|
40
|
+
error: string;
|
|
41
|
+
retry: string;
|
|
42
|
+
splitLeft: string;
|
|
43
|
+
splitRight: string;
|
|
44
|
+
splitUp: string;
|
|
45
|
+
splitDown: string;
|
|
46
|
+
notRepo: string;
|
|
47
|
+
noChanges: string;
|
|
48
|
+
stage: string;
|
|
49
|
+
unstage: string;
|
|
50
|
+
stageAll: string;
|
|
51
|
+
unstageAll: string;
|
|
52
|
+
commitPlaceholder: string;
|
|
53
|
+
commit: string;
|
|
54
|
+
commitError: string;
|
|
55
|
+
branch: string;
|
|
56
|
+
checkoutError: string;
|
|
57
|
+
history: string;
|
|
58
|
+
changes: string;
|
|
59
|
+
staged: string;
|
|
60
|
+
unstaged: string;
|
|
61
|
+
cancel: string;
|
|
62
|
+
diffEmpty: string;
|
|
63
|
+
diffLoadError: string;
|
|
64
|
+
diffBinary: string;
|
|
65
|
+
diffAdded: string;
|
|
66
|
+
diffDeleted: string;
|
|
67
|
+
diffRenamed: string;
|
|
68
|
+
diffExpand: string;
|
|
69
|
+
diffCollapse: string;
|
|
70
|
+
discard: string;
|
|
71
|
+
discardTitle: string;
|
|
72
|
+
discardDesc: string;
|
|
73
|
+
viewCommitDiff: string;
|
|
74
|
+
copyShortHash: string;
|
|
75
|
+
copyFullHash: string;
|
|
76
|
+
copySubject: string;
|
|
77
|
+
revertCommit: string;
|
|
78
|
+
revertTitle: string;
|
|
79
|
+
revertDesc: string;
|
|
80
|
+
cherryPickCommit: string;
|
|
81
|
+
cherryPickTitle: string;
|
|
82
|
+
cherryPickDesc: string;
|
|
83
|
+
timeJustNow: string;
|
|
84
|
+
timeMinutesAgo: string;
|
|
85
|
+
timeHoursAgo: string;
|
|
86
|
+
timeYesterday: string;
|
|
87
|
+
loadMore: string;
|
|
88
|
+
historyLoadError: string;
|
|
89
|
+
produced: string;
|
|
90
|
+
producedOpen: string;
|
|
91
|
+
disconnected: string;
|
|
92
|
+
exited: string;
|
|
93
|
+
noSession: string;
|
|
94
|
+
pluginNotLoaded: string;
|
|
95
|
+
hiddenFiles: string;
|
|
96
|
+
parent: string;
|
|
97
|
+
copied: string;
|
|
98
|
+
copy: string;
|
|
99
|
+
newFile: string;
|
|
100
|
+
openEditor: string;
|
|
101
|
+
gitDetail: string;
|
|
102
|
+
referenceFile: string;
|
|
103
|
+
addToConversation: string;
|
|
104
|
+
copyRelative: string;
|
|
105
|
+
copyAbsolute: string;
|
|
106
|
+
download: string;
|
|
107
|
+
settingsNav: string;
|
|
108
|
+
settingsOpenTitle: string;
|
|
109
|
+
settingsOpenDesc: string;
|
|
110
|
+
settingsWidthTitle: string;
|
|
111
|
+
settingsWidthDesc: string;
|
|
112
|
+
settingsWidthSuffix: string;
|
|
113
|
+
settingsOpenPathTitle: string;
|
|
114
|
+
settingsOpenPathDesc: string;
|
|
115
|
+
settingsSaveFailed: string;
|
|
116
|
+
settingsConflict: string;
|
|
117
|
+
binaryNoPreview: string;
|
|
118
|
+
downloadToView: string;
|
|
119
|
+
officeTooLarge: string;
|
|
120
|
+
officeCorrupt: string;
|
|
121
|
+
officeEncrypted: string;
|
|
122
|
+
officeLoadFailed: string;
|
|
123
|
+
previousSlide: string;
|
|
124
|
+
nextSlide: string;
|
|
125
|
+
zoom: string;
|
|
126
|
+
zoomHint: string;
|
|
127
|
+
settingsSubagentTitle: string;
|
|
128
|
+
settingsSubagentDesc: string;
|
|
129
|
+
settingsJobsTitle: string;
|
|
130
|
+
settingsJobsDesc: string;
|
|
131
|
+
settingsToolsTitle: string;
|
|
132
|
+
settingsToolsDesc: string;
|
|
133
|
+
settingsBottomTerminalTitle: string;
|
|
134
|
+
settingsBottomTerminalDesc: string;
|
|
135
|
+
settingsTabsTitle: string;
|
|
136
|
+
settingsViewersTitle: string;
|
|
137
|
+
settingsGeneralTitle: string;
|
|
138
|
+
settingsPopup: string;
|
|
139
|
+
settingsViewerCatchAll: string;
|
|
140
|
+
viewerImage: string;
|
|
141
|
+
viewerPdf: string;
|
|
142
|
+
viewerDocx: string;
|
|
143
|
+
viewerXlsx: string;
|
|
144
|
+
viewerPptx: string;
|
|
145
|
+
viewerMarkdown: string;
|
|
146
|
+
viewerCode: string;
|
|
147
|
+
viewerBinary: string;
|
|
148
|
+
viewerHtml: string;
|
|
149
|
+
browser: string;
|
|
150
|
+
browserPlaceholder: string;
|
|
151
|
+
browserGo: string;
|
|
152
|
+
browserBack: string;
|
|
153
|
+
browserForward: string;
|
|
154
|
+
browserStart: string;
|
|
155
|
+
browserBlockedScheme: string;
|
|
156
|
+
browserBlockedLoopback: string;
|
|
157
|
+
browserInvalid: string;
|
|
158
|
+
browserNoSandboxWarning: string;
|
|
159
|
+
htmlNoSandboxWarning: string;
|
|
160
|
+
sandboxStatusOn: string;
|
|
161
|
+
sandboxUnlock: string;
|
|
162
|
+
sandboxRestore: string;
|
|
163
|
+
settingsHtmlDefaultUnsafeTitle: string;
|
|
164
|
+
settingsHtmlDefaultUnsafeDesc: string;
|
|
165
|
+
settingsHtmlSandboxTitle: string;
|
|
166
|
+
settingsHtmlSandboxDesc: string;
|
|
167
|
+
settingsBrowserSandboxTitle: string;
|
|
168
|
+
settingsBrowserSandboxDesc: string;
|
|
169
|
+
settingsBrowserLinksTitle: string;
|
|
170
|
+
settingsBrowserLinksDesc: string;
|
|
171
|
+
browserOpenExternal: string;
|
|
172
|
+
browserEmbedBlocked: string;
|
|
173
|
+
browserEmbedBlockedDesc: string;
|
|
174
|
+
browserEmbedAnyway: string;
|
|
175
|
+
subagent: string;
|
|
176
|
+
openSubagent: string;
|
|
177
|
+
subagentMainAgent: string;
|
|
178
|
+
subagentEmpty: string;
|
|
179
|
+
subagentEmptyDesc: string;
|
|
180
|
+
subagentRunning: string;
|
|
181
|
+
subagentInactive: string;
|
|
182
|
+
subagentModeOneShot: string;
|
|
183
|
+
subagentModeContinuable: string;
|
|
184
|
+
subagentCount: string;
|
|
185
|
+
subagentCountRunning: string;
|
|
186
|
+
subagentDiagCorrupt: string;
|
|
187
|
+
subagentDiagUnsupported: string;
|
|
188
|
+
subagentDiagUnavailable: string;
|
|
189
|
+
subagentThinking: string;
|
|
190
|
+
jobs: string;
|
|
191
|
+
jobsCount: string;
|
|
192
|
+
jobsCountRunning: string;
|
|
193
|
+
jobStatusRunning: string;
|
|
194
|
+
jobStatusStopping: string;
|
|
195
|
+
jobStatusCompleted: string;
|
|
196
|
+
jobStatusKilled: string;
|
|
197
|
+
jobStatusFailed: string;
|
|
198
|
+
jobDurationSeconds: string;
|
|
199
|
+
jobDurationMinutes: string;
|
|
200
|
+
jobDurationHours: string;
|
|
201
|
+
jobViewOutput: string;
|
|
202
|
+
jobHideOutput: string;
|
|
203
|
+
jobNoOutput: string;
|
|
204
|
+
jobNotReadYet: string;
|
|
205
|
+
jobOutputTruncated: string;
|
|
206
|
+
jobOutputError: string;
|
|
207
|
+
jobKill: string;
|
|
208
|
+
jobKillConfirm: string;
|
|
209
|
+
jobKillError: string;
|
|
210
|
+
};
|
|
211
|
+
/** The en dictionary (key-set-equal to zh, enforced by the type annotation). */
|
|
212
|
+
export declare const en: Record<keyof typeof zh, string>;
|
|
213
|
+
/**
|
|
214
|
+
* The dictionary namespace this plugin owns in the DSH locale registry
|
|
215
|
+
* (`'sidebar'` is taken by DSH's own ui-sidebar, hence this distinct name).
|
|
216
|
+
*/
|
|
217
|
+
export declare const LOCALE_NS = "betterSidebar";
|
|
218
|
+
/**
|
|
219
|
+
* Attach (or detach, with undefined) the DSH locale service. The sidebar
|
|
220
|
+
* mounts its own React root outside the slot system's locale seat, so the
|
|
221
|
+
* service rides this module-level holder: components keep calling the plain
|
|
222
|
+
* `t()` function, and the Sidebar root's locale subscription re-renders the
|
|
223
|
+
* whole tree on switches.
|
|
224
|
+
*/
|
|
225
|
+
export declare function attachLocale(service: {
|
|
226
|
+
getSnapshot(): {
|
|
227
|
+
active: string;
|
|
228
|
+
};
|
|
229
|
+
} | undefined): void;
|
|
230
|
+
/** Translate a copy key in the active locale (zh → zh, else en). */
|
|
231
|
+
export type CopyKey = keyof typeof zh;
|
|
232
|
+
/** Translate a copy key; `{name}` placeholders interpolate from `params`. */
|
|
233
|
+
export declare function t(key: CopyKey, params?: Record<string, string | number>): string;
|
|
234
|
+
/** Whether the active locale is Chinese (used for selectors). */
|
|
235
|
+
export declare function isZh(): boolean;
|
|
236
|
+
/** Format an ISO 8601 author date relative to now (刚刚 / N 分钟前 / N 小时前 / 昨天 / date). */
|
|
237
|
+
export declare function relativeTime(iso: string): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared pieces of the Office preview views (docx / xlsx): the load-state
|
|
3
|
+
* union, the shared props, and the download fallback. The two views live in
|
|
4
|
+
* their own modules (docx-view.tsx / xlsx-view.tsx) so the bundler can emit
|
|
5
|
+
* them as separate lazy chunks — docx-preview and the Univer family (several
|
|
6
|
+
* MB) must never share a script (see docs/plans/2026-08-12-lazy-chunks-design.md).
|
|
7
|
+
*/
|
|
8
|
+
import { type SessionScope } from './api.ts';
|
|
9
|
+
/** Loading / ready / error state shared by both views. */
|
|
10
|
+
export type LoadState = {
|
|
11
|
+
status: 'loading';
|
|
12
|
+
} | {
|
|
13
|
+
status: 'ready';
|
|
14
|
+
} | {
|
|
15
|
+
status: 'error';
|
|
16
|
+
message: string;
|
|
17
|
+
};
|
|
18
|
+
/** Shared props. */
|
|
19
|
+
export interface OfficeViewProps {
|
|
20
|
+
scope: SessionScope;
|
|
21
|
+
path: string;
|
|
22
|
+
title: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The shared error / fallback affordance: the failure reason plus a download
|
|
26
|
+
* link, so the user always has a path to the file. Used by both DocxView and
|
|
27
|
+
* XlsxView, and matches the binary placeholder download link.
|
|
28
|
+
*/
|
|
29
|
+
export declare function BinaryFallback(props: {
|
|
30
|
+
scope: SessionScope;
|
|
31
|
+
path: string;
|
|
32
|
+
message: string;
|
|
33
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Office file type dispatch — pure functions mapping file extensions to
|
|
3
|
+
* preview kinds. Kept separate from the editor host so the mapping is
|
|
4
|
+
* unit-testable without mounting React or pulling in docx-preview / Univer.
|
|
5
|
+
*
|
|
6
|
+
* The host side never inspects Office extensions: the binary NUL probe in
|
|
7
|
+
* {@link ../index.ts} (readText) tags every Office file as binary, and the
|
|
8
|
+
* /sidebar/file media route serves raw bytes for any extension. This module
|
|
9
|
+
* is the client's sole source of truth for "is this previewable here".
|
|
10
|
+
*/
|
|
11
|
+
/** Extensions rendered with docx-preview (preserved styles/images/tables). */
|
|
12
|
+
export declare const OFFICE_DOCX_EXT: ".docx";
|
|
13
|
+
/** Extensions rendered with Univer (sheets: data + formulas + formatting). */
|
|
14
|
+
export declare const OFFICE_XLSX_EXT: ".xlsx";
|
|
15
|
+
/** Extensions rendered with the browser-native PPTX viewer. */
|
|
16
|
+
export declare const OFFICE_PPTX_EXT: ".pptx";
|
|
17
|
+
/** Extensions that get a download-only affordance (no client-side renderer). */
|
|
18
|
+
export declare const OFFICE_DOWNLOAD_ONLY_EXT: readonly string[];
|
|
19
|
+
/**
|
|
20
|
+
* The preview strategy for one path's extension.
|
|
21
|
+
* - `'docx'` — render via docx-preview.
|
|
22
|
+
* - `'xlsx'` — render via Univer.
|
|
23
|
+
* - `'pptx'` — render via pptx-renderer.
|
|
24
|
+
* - `'download-only'` — show the binary download button (no preview renderer
|
|
25
|
+
* covers legacy OLE .doc/.xls/.ppt on the client).
|
|
26
|
+
* - `null` — not an Office file; the caller's existing image / md / text / binary
|
|
27
|
+
* pipeline handles it.
|
|
28
|
+
*/
|
|
29
|
+
export type OfficeKind = 'docx' | 'xlsx' | 'pptx' | 'download-only' | null;
|
|
30
|
+
/**
|
|
31
|
+
* Map a lowercased extension (with leading dot) to its preview kind.
|
|
32
|
+
*
|
|
33
|
+
* @param ext - the path extension (with leading dot) (`.docx`,
|
|
34
|
+
* `.xlsx`, `.pptx`, `.doc`, `.xls`, `.ppt`, …); `''` when the path has none.
|
|
35
|
+
*/
|
|
36
|
+
export declare function officeKindForExt(ext: string): OfficeKind;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compat re-export shim for the historical `src/client/office-view.tsx`
|
|
3
|
+
* path. The office preview views were split into docx-view.tsx /
|
|
4
|
+
* xlsx-view.tsx (+ office-shared.tsx) so the bundler can emit each library
|
|
5
|
+
* as its own lazy chunk (see docs/plans/2026-08-12-lazy-chunks-design.md).
|
|
6
|
+
* This module keeps deep imports of this path resolvable through the
|
|
7
|
+
* `./src/*` exports subpath — it deliberately re-exports BOTH views, so it
|
|
8
|
+
* must never be imported from the core bundle or a chunk entry (it would
|
|
9
|
+
* drag both libraries into that bundle).
|
|
10
|
+
*/
|
|
11
|
+
export { DocxView } from './docx-view.tsx';
|
|
12
|
+
export { XlsxView } from './xlsx-view.tsx';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interception of the chat's file-open funnel. The client runtime's
|
|
3
|
+
* `ctx.workspaces.openPath` is the SINGLE door every chat-side file open goes
|
|
4
|
+
* through — ui-conversation's apply.ts resolves the path against the session
|
|
5
|
+
* cwd and calls it for tool-row path links, the produced-files row, and
|
|
6
|
+
* prose file mentions alike (verified against the DSH source:
|
|
7
|
+
* `packages/client/ui-conversation/src/client/apply.ts` is the only
|
|
8
|
+
* production caller). Wrapping that one method reroutes those opens into the
|
|
9
|
+
* sidebar editor instead of the Host OS — no DSH modification needed.
|
|
10
|
+
*
|
|
11
|
+
* The wrapper is dependency-free by design (no React / ui-primitives), so
|
|
12
|
+
* the takeover logic is unit-testable and the file stays importable from the
|
|
13
|
+
* test runtime.
|
|
14
|
+
*/
|
|
15
|
+
/** The one service method the wrapper replaces (mirror of the runtime IWorkspaces). */
|
|
16
|
+
export interface OpenPathService {
|
|
17
|
+
openPath(path: string): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
/** Per-call decisions the wrapper needs (wired to the store + ctx in the client half). */
|
|
20
|
+
export interface OpenPathInterceptDeps {
|
|
21
|
+
/**
|
|
22
|
+
* Whether to take over this call: the `interceptOpenPath` pref AND the
|
|
23
|
+
* editor tab's own enable switch must both be on (an editor that cannot
|
|
24
|
+
* open must not swallow opens — they fall through to the Host).
|
|
25
|
+
*/
|
|
26
|
+
takeoverEnabled(): boolean;
|
|
27
|
+
/** The session whose scope the sidebar editor loads the file in (current session). */
|
|
28
|
+
currentSessionId(): string | undefined;
|
|
29
|
+
/** Route the open into the sidebar editor (the established openSidebarFile). */
|
|
30
|
+
openInSidebar(path: string, sessionId: string): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Wrap `workspaces.openPath`: intercepted calls open the file in the sidebar
|
|
34
|
+
* editor instead of the Host OS and resolve as success (the original's
|
|
35
|
+
* callers ignore the result); anything that declines falls through to the
|
|
36
|
+
* original method untouched.
|
|
37
|
+
* @param workspaces - the client workspaces service to wrap.
|
|
38
|
+
* @param deps - per-call takeover decisions.
|
|
39
|
+
* @returns the disposer restoring the original method (HMR-safe).
|
|
40
|
+
*/
|
|
41
|
+
export declare function wrapOpenPath(workspaces: OpenPathService, deps: OpenPathInterceptDeps): () => void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path projection helpers shared by the explorer rows: a path relative to
|
|
3
|
+
* the session cwd (for the @-reference button and "copy relative path").
|
|
4
|
+
* The fs-tree joins with '/' even on Windows, so both separators normalize
|
|
5
|
+
* to '/' before comparison.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* The path relative to the session's working directory.
|
|
9
|
+
* @param cwd - the explorer root (absolute).
|
|
10
|
+
* @param path - an absolute entry path from the fs-tree.
|
|
11
|
+
* @returns the relative path with '/' separators ('.' for the cwd itself),
|
|
12
|
+
* or `path` unchanged when it lies outside the cwd.
|
|
13
|
+
*
|
|
14
|
+
* The prefix test is case-insensitive: Windows paths (and macOS's
|
|
15
|
+
* case-insensitive volumes) may arrive with different casing than the cwd
|
|
16
|
+
* row, and the containment decision must not depend on it. The returned
|
|
17
|
+
* relative text keeps the caller's own casing.
|
|
18
|
+
*/
|
|
19
|
+
export declare function relativeTo(cwd: string, path: string): string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side read of the user-facing "Side card" preferences. The host owns
|
|
3
|
+
* the namespace through the settings seam (in-process); the DSH settings RPC
|
|
4
|
+
* domain only serves allowlisted namespaces to configuration clients, so the
|
|
5
|
+
* client reads and writes THIS namespace through the plugin's own fenced
|
|
6
|
+
* /sidebar routes instead (api.settingsGet/settingsUpdate). Any failure
|
|
7
|
+
* (route rejected, namespace absent, a field of the wrong type, a value out
|
|
8
|
+
* of the contract range) falls back to the schema defaults — the side card
|
|
9
|
+
* must keep working exactly as composed when the settings surface is missing.
|
|
10
|
+
*/
|
|
11
|
+
import type { api } from './api.ts';
|
|
12
|
+
import { clampWidthPercent, SIDEBAR_PREFS_DEFAULTS, type SidebarPrefs } from '../prefs-shared.ts';
|
|
13
|
+
export { SIDEBAR_PREFS_DEFAULTS, clampWidthPercent };
|
|
14
|
+
export type { SidebarPrefs };
|
|
15
|
+
/** The settings wire face the preferences need (a subset of the plugin api). */
|
|
16
|
+
export type SidebarSettingsClient = Pick<typeof api, 'settingsGet' | 'settingsUpdate'>;
|
|
17
|
+
/** Validate one raw resolved value into {@link SidebarPrefs}. Used for the
|
|
18
|
+
* settings.get payload AND the settings.update response (both carry the
|
|
19
|
+
* layered resolved value); any malformed field falls back to its default.
|
|
20
|
+
* @param value - the raw resolved section from the settings wire.
|
|
21
|
+
* @returns validated prefs (always well-formed).
|
|
22
|
+
*/
|
|
23
|
+
export declare function parsePrefs(value: unknown): SidebarPrefs;
|
|
24
|
+
/**
|
|
25
|
+
* Read the resolved side card preferences through the plugin's settings route.
|
|
26
|
+
* @param settings - the settings wire face (the plugin api by default).
|
|
27
|
+
* @returns validated prefs, or the schema defaults when the route rejects,
|
|
28
|
+
* the namespace is absent, or a stored value violates the contract.
|
|
29
|
+
*/
|
|
30
|
+
export declare function loadPrefs(settings: SidebarSettingsClient): Promise<SidebarPrefs>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure derivation of one turn's produced files from finalized conversation
|
|
3
|
+
* nodes — a structural replica of ui-deliverables' `producedForClosing`
|
|
4
|
+
* (the mutation tools' follow-along `locations`, by render intent: a diff
|
|
5
|
+
* card or a generic edit card; reads/deletes/failures produce nothing).
|
|
6
|
+
* Kept dependency-free so the takeover logic is unit-testable and the
|
|
7
|
+
* replica is easy to diff against upstream when it drifts.
|
|
8
|
+
*/
|
|
9
|
+
/** Paths a tool-result view reports as produced, by render intent. */
|
|
10
|
+
export declare function producedPaths(view: unknown): readonly string[];
|
|
11
|
+
/**
|
|
12
|
+
* Files produced by the turn the assistant at `seq` closes. Accumulation
|
|
13
|
+
* resets on turn boundaries (a user message, or a node reporting a different
|
|
14
|
+
* turn number); paths keep first-seen order and appear once.
|
|
15
|
+
* @param nodes - snapshot nodes in surface order (structural, unknown-safe).
|
|
16
|
+
* @param seq - the closing assistant's seq (the render site's anchor).
|
|
17
|
+
* @returns produced paths; empty when the turn wrote nothing.
|
|
18
|
+
*/
|
|
19
|
+
export declare function producedForClosing(nodes: readonly unknown[], seq: number): readonly string[];
|
|
20
|
+
/**
|
|
21
|
+
* Claim the turn-tail chain only when the closing turn produced files.
|
|
22
|
+
* @param owner - the turn-tail owner currency ({nodes, seq}).
|
|
23
|
+
* @returns produced paths as the matched value, or null to decline.
|
|
24
|
+
*/
|
|
25
|
+
export declare function selectProducedFiles(owner: unknown): readonly string[] | null;
|
|
26
|
+
/** Resolve a (possibly relative) path against the session cwd for the sidebar. */
|
|
27
|
+
export declare function resolveSidebarPath(cwd: string | undefined, path: string): string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Max inserted selection length (UTF-16 code units, i.e. JS `.length`). */
|
|
2
|
+
export declare const SELECTION_LIMIT = 500;
|
|
3
|
+
/** The source line span a selection maps to (1-based, inclusive). */
|
|
4
|
+
export interface SelectionLines {
|
|
5
|
+
start: number;
|
|
6
|
+
end: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The fence info line: `rel[:start[-end]]` — lines are omitted entirely
|
|
10
|
+
* when unknown (the preview reverse-search missed).
|
|
11
|
+
*/
|
|
12
|
+
export declare function headerOf(path: string, cwd: string | undefined, lines?: SelectionLines): string;
|
|
13
|
+
/**
|
|
14
|
+
* The full text appended to the composer draft for one selection.
|
|
15
|
+
* Over the limit the content is dropped: the plain path line is the whole
|
|
16
|
+
* payload (an empty fenced block would just occupy the draft).
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildSelectionInsert(path: string, cwd: string | undefined, lines: SelectionLines | undefined, selected: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Reverse-map a rendered-DOM selection back to source line numbers. The
|
|
21
|
+
* preview selection is plain text (block boundaries come out as `\n`), so
|
|
22
|
+
* this is a best-effort substring search: a single trailing newline is
|
|
23
|
+
* stripped first (DOM block selections tend to carry one), and only an
|
|
24
|
+
* EXACTLY-ONE occurrence yields lines — an ambiguous or missing match
|
|
25
|
+
* returns null (the header then carries the path without line numbers).
|
|
26
|
+
*/
|
|
27
|
+
export declare function linesOfSelection(source: string, selected: string): SelectionLines | null;
|