dsh-pinwhy 0.3.0 → 0.5.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/README.md +60 -132
- package/assets/pinwhy-icon.svg +16 -4
- package/client/index.js +646 -47
- package/package.json +31 -11
- package/src/bridge.js +20 -12
- package/src/config.js +2 -1
- package/src/plugin.js +2 -0
- package/src/presentation.js +5 -2
- package/src/schema.js +1 -0
- package/src/scope.js +43 -13
- package/src/tools.js +173 -30
- package/src/viewer.js +270 -0
package/client/index.js
CHANGED
|
@@ -3,64 +3,243 @@ window.__ModuleLoader__.load({ id: 'dsh-pinwhy', factory(require) {
|
|
|
3
3
|
const React = require('react');
|
|
4
4
|
const h = React.createElement;
|
|
5
5
|
const NS = 'pinwhy';
|
|
6
|
-
const actions = ['status', 'context', 'node_get', 'node_add', 'node_patch', 'link', 'cursor', 'checkpoint', 'diagnose'];
|
|
6
|
+
const actions = ['status', 'context', 'node_get', 'node_add', 'node_patch', 'link', 'cursor', 'checkpoint', 'diagnose', 'batch', 'search'];
|
|
7
|
+
/* ---- 1. Dictionaries & Settings Model ---- */
|
|
7
8
|
const dictionaries = {
|
|
8
|
-
zh: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
zh: {
|
|
10
|
+
status: '黑板状态', context: '恢复研究现场', node_get: '查看节点', node_add: '记录判断', node_patch: '更新节点',
|
|
11
|
+
link: '关联证据', cursor: '切换关注位置', checkpoint: '保存交接', diagnose: '接入诊断', batch: '批量记录', search: '搜索记忆',
|
|
12
|
+
boardTitle: 'Pinwhy 画板',
|
|
13
|
+
viewNode: '在画板中查看', openCommand: '打开 Pinwhy 画板',
|
|
14
|
+
pin: '固定画板入口', unpin: '取消固定画板入口',
|
|
15
|
+
autoDiscover: '自动发现已有黑板(可选)', workspacePick: '从 DSH 工作区添加',
|
|
16
|
+
referenceAdded: '已插入所属会话草稿,尚未发送。', referenceFailed: '未能完成引用操作,请检查所属会话草稿。',
|
|
17
|
+
viewerLoading: '正在连接 Pinwhy 画板…', viewerReload: '重新加载', viewerReconnect: '重新连接',
|
|
18
|
+
readOnlyBadge: '只读', noSession: '选择一个项目会话,查看它留下的判断、证据与现场。',
|
|
19
|
+
viewerFailed: '画板未能打开。', viewerInvalid: '画板返回的地址无法安全打开。',
|
|
20
|
+
viewerErrorDetails: '错误详情', ungrouped: '未分组项目', blankSession: '新会话',
|
|
21
|
+
boardSubtitle: '在项目中留下判断、证据与现场', chooseSession: '选择会话',
|
|
22
|
+
viewerLoadingHint: '正在读取项目黑板,已有记录会在此恢复。',
|
|
23
|
+
upgradeHint: '请升级独立 Pinwhy 运行时,以启用内置画板。',
|
|
24
|
+
runtimeHint: '请在插件设置中选择已安装的 Pinwhy CLI。',
|
|
25
|
+
setupHint: '请在插件设置中启用此项目,并显式初始化黑板。',
|
|
26
|
+
retryHint: '请检查项目接入状态后重新连接。',
|
|
27
|
+
settings: '项目与运行时配置', summary: '显式选择接入项目;保存不会初始化黑板。', project: '项目工作区', board: '黑板根目录(可选)',
|
|
28
|
+
add: '添加项目', remove: '移除项目', runtime: 'pinwhy CLI(留空使用 current)', node: 'Node(留空使用宿主运行时)',
|
|
29
|
+
timeout: '超时(毫秒)', output: '输出上限(字节)', save: '保存配置', reload: '重新读取配置',
|
|
30
|
+
saved: '配置已保存,新调用即时生效。', conflict: '保存未被接受;草稿已保留,请重新读取配置后重试。',
|
|
31
|
+
readonly: '当前配置不可编辑。', loading: '正在加载配置…',
|
|
32
|
+
guide: '在项目会话中输入“检查 pinwhy 接入状态”可运行只读诊断;不会创建黑板或修改权限。',
|
|
33
|
+
projectsSection: '项目与工作区', projectsSectionDesc: '配置接入 Pinwhy 的工作区;保存配置不会初始化新黑板。',
|
|
34
|
+
autoDiscoverDesc: '在工作区父级目录中自动查找已存在的 .pinwhy 黑板。',
|
|
35
|
+
emptyProjects: '尚未配置接入项目。可从下方工作区快速选择,或手动添加路径。',
|
|
36
|
+
runtimeSection: '运行时与 CLI', runtimeSectionDesc: '指定独立安装的 Pinwhy CLI 与 Node.js 解释器路径。',
|
|
37
|
+
runtimePlaceholder: '留空使用内置/全局 current', nodePlaceholder: '留空使用宿主运行时',
|
|
38
|
+
limitsSection: '执行与限制', limitsSectionDesc: '限制工具调用的单次执行时长与输出字节大小,防止长时间阻塞。',
|
|
39
|
+
timeoutHint: '范围 50 ~ 120,000 ms', outputHint: '范围 1,024 ~ 16,777,216 bytes',
|
|
40
|
+
addManual: '手动添加路径', boardPlaceholder: '留空同工作区路径',
|
|
41
|
+
rowHint: '点击下方组件的配置按钮,添加项目或调整 CLI。', running: '执行中', preparing: '准备中', done: '完成', failed: '执行失败',
|
|
42
|
+
detail: '查看原始调用与结果', inspect: '查看轨迹', read: '可读取', write: '可写入', yes: '是', no: '否',
|
|
43
|
+
failureDetail: '操作未成功,原始结果如下。', unknown: '缺少可识别的卡片信息,原始记录如下。'
|
|
44
|
+
},
|
|
45
|
+
en: {
|
|
46
|
+
status: 'Board status', context: 'Restore context', node_get: 'Read node', node_add: 'Record judgment', node_patch: 'Update node',
|
|
47
|
+
link: 'Link evidence', cursor: 'Change focus', checkpoint: 'Save handoff', diagnose: 'Setup diagnosis', batch: 'Batch record', search: 'Search memory',
|
|
48
|
+
boardTitle: 'Pinwhy Board',
|
|
49
|
+
viewNode: 'View in board', openCommand: 'Open Pinwhy board',
|
|
50
|
+
pin: 'Pin board entry', unpin: 'Unpin board entry',
|
|
51
|
+
autoDiscover: 'Discover existing boards automatically (optional)', workspacePick: 'Add from DSH workspaces',
|
|
52
|
+
referenceAdded: 'Inserted into the owning conversation draft; not sent.', referenceFailed: 'The reference could not be completed. Check the owning conversation draft.',
|
|
53
|
+
viewerLoading: 'Connecting to the Pinwhy board…', viewerReload: 'Reload', viewerReconnect: 'Reconnect',
|
|
54
|
+
readOnlyBadge: 'Read-only', noSession: 'Choose a project session to read its judgments, evidence and context.',
|
|
55
|
+
viewerFailed: 'The board could not open.', viewerInvalid: 'The board returned an address that cannot be embedded.',
|
|
56
|
+
viewerErrorDetails: 'Error details', ungrouped: 'Ungrouped projects', blankSession: 'New session',
|
|
57
|
+
boardSubtitle: 'Judgments, evidence and context for your project', chooseSession: 'Choose a session',
|
|
58
|
+
viewerLoadingHint: 'Reading the project board and restoring its recorded memory.',
|
|
59
|
+
upgradeHint: 'Update the independent Pinwhy runtime to enable the embedded board.',
|
|
60
|
+
runtimeHint: 'Select the installed Pinwhy CLI in plugin settings.',
|
|
61
|
+
setupHint: 'Enable this project in plugin settings and initialize its board explicitly.',
|
|
62
|
+
retryHint: 'Check the project connection, then reconnect.',
|
|
63
|
+
settings: 'Projects and runtime', summary: 'Enable projects explicitly; saving never initializes a board.', project: 'Workspace', board: 'Board root (optional)',
|
|
64
|
+
add: 'Add project', remove: 'Remove project', runtime: 'pinwhy CLI (blank uses current)', node: 'Node (blank uses host runtime)',
|
|
65
|
+
timeout: 'Timeout (ms)', output: 'Output limit (bytes)', save: 'Save configuration', reload: 'Reload configuration',
|
|
66
|
+
saved: 'Saved. New calls use this configuration immediately.', conflict: 'Save was not accepted. Draft retained; reload before retrying.',
|
|
67
|
+
readonly: 'Configuration is not editable.', loading: 'Loading configuration…',
|
|
68
|
+
guide: 'Ask “check pinwhy setup” in a project session for a read-only diagnosis. It never initializes a board or changes permissions.',
|
|
69
|
+
projectsSection: 'Projects & Workspaces', projectsSectionDesc: 'Configure workspaces connected to Pinwhy; saving never initializes a board.',
|
|
70
|
+
autoDiscoverDesc: 'Automatically search parent directories for existing .pinwhy boards.',
|
|
71
|
+
emptyProjects: 'No projects configured yet. Pick an open workspace below or add a path manually.',
|
|
72
|
+
runtimeSection: 'Runtime & CLI', runtimeSectionDesc: 'Specify paths to an independently installed Pinwhy CLI and Node executable.',
|
|
73
|
+
runtimePlaceholder: 'Blank uses current', nodePlaceholder: 'Blank uses host runtime',
|
|
74
|
+
limitsSection: 'Execution Limits', limitsSectionDesc: 'Bound tool call execution duration and output buffer size.',
|
|
75
|
+
timeoutHint: 'Range: 50 ~ 120,000 ms', outputHint: 'Range: 1,024 ~ 16,777,216 bytes',
|
|
76
|
+
addManual: 'Add path manually', boardPlaceholder: 'Blank defaults to workspace path',
|
|
77
|
+
rowHint: 'Use the component configuration button below to add projects or change the CLI.', running: 'Running', preparing: 'Preparing', done: 'Completed', failed: 'Failed',
|
|
78
|
+
detail: 'Raw call and result', inspect: 'Inspect trace', read: 'Readable', write: 'Writable', yes: 'Yes', no: 'No',
|
|
79
|
+
failureDetail: 'Operation failed; original result follows.', unknown: 'No recognized card metadata; original record follows.'
|
|
80
|
+
},
|
|
12
81
|
};
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const initial = value => ({
|
|
17
|
-
|
|
82
|
+
|
|
83
|
+
const box = { border: '1px solid var(--dsw-alias-border-l1, #e5e7eb)', borderRadius: 8, padding: 16, margin: '12px 0' };
|
|
84
|
+
|
|
85
|
+
const initial = value => ({
|
|
86
|
+
autoDiscover: value?.autoDiscover ?? false,
|
|
87
|
+
projects: (value?.projects ?? []).map(row => ({ workspace: row.workspace, boardRoot: row.boardRoot ?? '' })),
|
|
88
|
+
runtimeCli: value?.runtimeCli ?? '',
|
|
89
|
+
nodeExecutable: value?.nodeExecutable ?? '',
|
|
90
|
+
timeoutMs: value?.timeoutMs ?? 10000,
|
|
91
|
+
maxOutputBytes: value?.maxOutputBytes ?? 1048576,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const wire = draft => ({
|
|
95
|
+
...draft,
|
|
96
|
+
projects: draft.projects.map(row => ({ workspace: row.workspace, ...(row.boardRoot ? { boardRoot: row.boardRoot } : {}) })),
|
|
97
|
+
});
|
|
98
|
+
|
|
18
99
|
function edits(draft, base) {
|
|
19
100
|
const next = wire(draft), previous = wire(base);
|
|
20
101
|
return Object.keys(next).filter(key => JSON.stringify(next[key]) !== JSON.stringify(previous[key])).map(key =>
|
|
21
102
|
['runtimeCli', 'nodeExecutable'].includes(key) && next[key] === '' ? { op: 'unset', path: [key] } : { op: 'set', path: [key], value: next[key] });
|
|
22
103
|
}
|
|
23
|
-
|
|
104
|
+
|
|
105
|
+
const childrenOf = (children, rest) => rest.length ? rest : (Array.isArray(children) ? children : children != null ? [children] : []);
|
|
106
|
+
|
|
107
|
+
/* ---- 2. Settings Form Components ---- */
|
|
108
|
+
function SvgIcon({ size = 16, viewBox = '0 0 24 24', stroke = 'currentColor', strokeWidth = 2, children, ...props }, ...rest) {
|
|
109
|
+
const strokeProps = stroke ? { stroke, strokeWidth, strokeLinecap: 'round', strokeLinejoin: 'round' } : {};
|
|
110
|
+
return h('svg', { width: size, height: size, viewBox, fill: 'none', 'aria-hidden': true, ...strokeProps, ...props }, ...childrenOf(children, rest));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function SettingsCard({ title, description, children }, ...rest) {
|
|
114
|
+
return h('section', { className: 'pinwhy-settings-card' },
|
|
115
|
+
h('div', { className: 'pinwhy-settings-header' },
|
|
116
|
+
h('h4', { className: 'pinwhy-settings-title' }, title),
|
|
117
|
+
h('p', { className: 'pinwhy-settings-desc' }, description)),
|
|
118
|
+
...childrenOf(children, rest));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function Field({ label, hint, children }, ...rest) {
|
|
122
|
+
return h('div', { className: 'pinwhy-field' },
|
|
123
|
+
h('label', { className: 'pinwhy-field-label' },
|
|
124
|
+
h('span', null, label),
|
|
125
|
+
hint ? h('span', { className: 'pinwhy-field-hint' }, hint) : null),
|
|
126
|
+
...childrenOf(children, rest));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function ProjectRow({ row, index, onUpdate, onRemove, t }) {
|
|
130
|
+
return h('div', { key: index, className: 'pinwhy-project-card' },
|
|
131
|
+
h('div', { className: 'pinwhy-project-card-header' },
|
|
132
|
+
h('div', { className: 'pinwhy-project-badge' },
|
|
133
|
+
SvgIcon({ size: 14, strokeWidth: 1.8 }, h('path', { d: 'M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z' })),
|
|
134
|
+
h('span', null, `${t('project')} #${index + 1}`)),
|
|
135
|
+
h('button', { type: 'button', className: 'pinwhy-btn pinwhy-btn-danger', onClick: () => onRemove(index) },
|
|
136
|
+
SvgIcon({ size: 12 }, h('polyline', { points: '3 6 5 6 21 6' }), h('path', { d: 'M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2' })),
|
|
137
|
+
h('span', null, t('remove')))),
|
|
138
|
+
h('div', { className: 'pinwhy-project-fields' },
|
|
139
|
+
Field({ label: t('project') },
|
|
140
|
+
h('input', { required: true, className: 'pinwhy-input', value: row.workspace, placeholder: '/absolute/path/to/project',
|
|
141
|
+
onChange: event => onUpdate(index, { workspace: event.target.value }) })),
|
|
142
|
+
Field({ label: t('board') },
|
|
143
|
+
h('input', { className: 'pinwhy-input', value: row.boardRoot, placeholder: t('boardPlaceholder'),
|
|
144
|
+
onChange: event => onUpdate(index, { boardRoot: event.target.value }) }))));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function SettingsProjectsSection({ draft, workspaces, t, onChange, onUpdateProject, onRemoveProject, onAddWorkspace }) {
|
|
148
|
+
return SettingsCard({ title: t('projectsSection'), description: t('projectsSectionDesc') },
|
|
149
|
+
h('label', { className: 'pinwhy-toggle-row' },
|
|
150
|
+
h('div', { className: 'pinwhy-toggle-info' },
|
|
151
|
+
h('span', { className: 'pinwhy-toggle-title' }, t('autoDiscover')),
|
|
152
|
+
h('span', { className: 'pinwhy-toggle-desc' }, t('autoDiscoverDesc'))),
|
|
153
|
+
h('input', { type: 'checkbox', className: 'pinwhy-toggle-checkbox', checked: draft.autoDiscover,
|
|
154
|
+
onChange: event => onChange('autoDiscover', event.target.checked) })),
|
|
155
|
+
draft.projects.length === 0
|
|
156
|
+
? h('div', { className: 'pinwhy-projects-empty' }, t('emptyProjects'))
|
|
157
|
+
: h('div', { className: 'pinwhy-projects-list' }, ...draft.projects.map((row, index) => ProjectRow({ row, index, onUpdate: onUpdateProject, onRemove: onRemoveProject, t }))),
|
|
158
|
+
h('div', { className: 'pinwhy-project-add-bar' },
|
|
159
|
+
h('select', { className: 'pinwhy-input', style: { flex: 1 }, value: '', 'aria-label': t('workspacePick'),
|
|
160
|
+
onChange: event => onAddWorkspace(workspaces.find(w => w.path === event.target.value)?.path) },
|
|
161
|
+
h('option', { value: '' }, t('workspacePick')),
|
|
162
|
+
...workspaces.map(w => h('option', { key: w.id, value: w.path, disabled: draft.projects.some(p => p.workspace === w.path) }, w.path))),
|
|
163
|
+
h('button', { type: 'button', className: 'pinwhy-btn pinwhy-btn-outline',
|
|
164
|
+
onClick: () => onChange('projects', [...draft.projects, { workspace: '', boardRoot: '' }]) }, `+ ${t('addManual')}`)));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function SettingsRuntimeSection({ draft, t, onChange }) {
|
|
168
|
+
return SettingsCard({ title: t('runtimeSection'), description: t('runtimeSectionDesc') },
|
|
169
|
+
h('div', { className: 'pinwhy-grid-2' },
|
|
170
|
+
Field({ label: t('runtime') }, h('input', { className: 'pinwhy-input', value: draft.runtimeCli, placeholder: t('runtimePlaceholder'),
|
|
171
|
+
onChange: event => onChange('runtimeCli', event.target.value) })),
|
|
172
|
+
Field({ label: t('node') }, h('input', { className: 'pinwhy-input', value: draft.nodeExecutable, placeholder: t('nodePlaceholder'),
|
|
173
|
+
onChange: event => onChange('nodeExecutable', event.target.value) }))));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function SettingsLimitsSection({ draft, t, onChange }) {
|
|
177
|
+
return SettingsCard({ title: t('limitsSection'), description: t('limitsSectionDesc') },
|
|
178
|
+
h('div', { className: 'pinwhy-grid-2' },
|
|
179
|
+
Field({ label: t('timeout'), hint: t('timeoutHint') },
|
|
180
|
+
h('input', { type: 'number', required: true, min: 50, max: 120000, step: 1, className: 'pinwhy-input', value: draft.timeoutMs,
|
|
181
|
+
onChange: event => onChange('timeoutMs', Number(event.target.value)) })),
|
|
182
|
+
Field({ label: t('output'), hint: t('outputHint') },
|
|
183
|
+
h('input', { type: 'number', required: true, min: 1024, max: 16777216, step: 1, className: 'pinwhy-input', value: draft.maxOutputBytes,
|
|
184
|
+
onChange: event => onChange('maxOutputBytes', Number(event.target.value)) }))));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function Editor({ form, t, useWorkspaces }) {
|
|
188
|
+
const workspaces = (typeof useWorkspaces === 'function' ? useWorkspaces(state => state.items) : null) || [];
|
|
24
189
|
const state = form?.state;
|
|
25
190
|
const [draft, setDraft] = React.useState(() => initial(state?.value));
|
|
26
191
|
const [base, setBase] = React.useState(() => initial(state?.value));
|
|
27
192
|
const [revision, setRevision] = React.useState(state?.revision);
|
|
28
|
-
const [dirty, setDirty] = React.useState(false), [busy, setBusy] = React.useState(false), [notice, setNotice] = React.useState(
|
|
29
|
-
const reset = () => { const next = initial(state?.value); setDraft(next); setBase(next); setRevision(state?.revision); setDirty(false); setNotice(
|
|
193
|
+
const [dirty, setDirty] = React.useState(false), [busy, setBusy] = React.useState(false), [notice, setNotice] = React.useState(null);
|
|
194
|
+
const reset = () => { const next = initial(state?.value); setDraft(next); setBase(next); setRevision(state?.revision); setDirty(false); setNotice(null); };
|
|
30
195
|
React.useEffect(() => {
|
|
31
196
|
if (!dirty && state?.revision !== revision) {
|
|
32
197
|
const next = initial(state?.value); setDraft(next); setBase(next); setRevision(state?.revision);
|
|
33
198
|
}
|
|
34
199
|
}, [state?.revision, state?.status, dirty, revision]);
|
|
35
|
-
const change = (key, value) => { setDraft(old => ({ ...old, [key]: value })); setDirty(true); setNotice(
|
|
36
|
-
const
|
|
200
|
+
const change = (key, value) => { setDraft(old => ({ ...old, [key]: value })); setDirty(true); setNotice(null); };
|
|
201
|
+
const updateProject = (index, patch) => change('projects', draft.projects.map((item, i) => i === index ? { ...item, ...patch } : item));
|
|
202
|
+
const removeProject = index => change('projects', draft.projects.filter((_, i) => i !== index));
|
|
203
|
+
const addWorkspace = path => {
|
|
204
|
+
if (path && !draft.projects.some(p => p.workspace === path)) change('projects', [...draft.projects, { workspace: path, boardRoot: '' }]);
|
|
205
|
+
};
|
|
37
206
|
const ready = state?.status === 'ready' && state.writable && typeof revision === 'number';
|
|
38
207
|
async function save(event) {
|
|
39
208
|
event.preventDefault(); if (!ready || busy) return;
|
|
40
|
-
setBusy(true); setNotice(
|
|
209
|
+
setBusy(true); setNotice(null);
|
|
41
210
|
try {
|
|
42
211
|
const accepted = await form.mutate(edits(draft, base), revision);
|
|
43
|
-
if (accepted) { setDirty(false); setBase(draft); setNotice(t('saved')); }
|
|
44
|
-
else setNotice(t('conflict'));
|
|
45
|
-
} catch (error) { setNotice(`${t('conflict')} ${String(error.message ?? error)}`); }
|
|
212
|
+
if (accepted) { setDirty(false); setBase(draft); setNotice({ ok: true, text: t('saved') }); }
|
|
213
|
+
else setNotice({ ok: false, text: t('conflict') });
|
|
214
|
+
} catch (error) { setNotice({ ok: false, text: `${t('conflict')} ${String(error.message ?? error)}` }); }
|
|
46
215
|
finally { setBusy(false); }
|
|
47
216
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
h('
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
217
|
+
let statusText = null;
|
|
218
|
+
if (notice) statusText = h('span', { className: notice.ok ? 'pinwhy-notice-success' : 'pinwhy-notice-error' }, `${notice.ok ? '✓' : '⚠'} ${notice.text}`);
|
|
219
|
+
else if (!state || state.status === 'loading') statusText = h('span', null, t('loading'));
|
|
220
|
+
else if (!ready) statusText = h('span', null, t('readonly'));
|
|
221
|
+
|
|
222
|
+
return h('form', { onSubmit: save, 'data-pinwhy-settings': true, className: 'pinwhy-settings-wrap' },
|
|
223
|
+
h('fieldset', { disabled: !ready || busy, style: { border: 0, padding: 0, margin: 0, minWidth: 0, display: 'flex', flexDirection: 'column', gap: 18 } },
|
|
224
|
+
h('header', { className: 'pinwhy-settings-header' },
|
|
225
|
+
h('div', { className: 'pinwhy-settings-title' }, h(PinwhyIcon, { size: 18 }), h('h3', null, t('settings'))),
|
|
226
|
+
h('p', { className: 'pinwhy-settings-desc' }, t('summary'))),
|
|
227
|
+
SettingsProjectsSection({ draft, workspaces, t, onChange: change, onUpdateProject: updateProject, onRemoveProject: removeProject, onAddWorkspace: addWorkspace }),
|
|
228
|
+
SettingsRuntimeSection({ draft, t, onChange: change }),
|
|
229
|
+
SettingsLimitsSection({ draft, t, onChange: change }),
|
|
230
|
+
h('div', { className: 'pinwhy-guide-callout' },
|
|
231
|
+
SvgIcon({ size: 16 }, h('circle', { cx: 12, cy: 12, r: 10 }), h('line', { x1: 12, y1: 16, x2: 12, y2: 12 }), h('line', { x1: 12, y1: 8, x2: 12.01, y2: 8 })),
|
|
232
|
+
h('span', null, t('guide'))),
|
|
233
|
+
h('footer', { className: 'pinwhy-settings-footer' },
|
|
234
|
+
h('div', { role: 'status', className: 'pinwhy-notice' }, statusText),
|
|
235
|
+
h('div', { className: 'pinwhy-actions-group' },
|
|
236
|
+
h('button', { type: 'button', className: 'pinwhy-btn pinwhy-btn-outline', disabled: busy || state?.status !== 'ready', onClick: reset }, t('reload')),
|
|
237
|
+
h('button', { type: 'submit', className: 'pinwhy-btn pinwhy-btn-primary', disabled: !dirty }, t('save'))))));
|
|
62
238
|
}
|
|
239
|
+
|
|
240
|
+
/* ---- 3. Tool Card Components ---- */
|
|
63
241
|
const bounded = value => typeof value === 'string' ? value.slice(0, 1000) : '';
|
|
242
|
+
|
|
64
243
|
function cardMeta(block, name) {
|
|
65
244
|
const value = block?.meta?.pinwhy;
|
|
66
245
|
if (!value || value.schema !== 'pinwhy.card.v1' || value.action !== name) return null;
|
|
@@ -68,33 +247,453 @@ window.__ModuleLoader__.load({ id: 'dsh-pinwhy', factory(require) {
|
|
|
68
247
|
if (name === 'pinwhy_diagnose' && (typeof value.readyToRead !== 'boolean' || typeof value.readyToWrite !== 'boolean' || !Array.isArray(value.checks) || value.checks.length > 8 || value.checks.some(check => !check || !['id', 'status', 'code', 'message', 'remedy'].every(key => typeof check[key] === 'string')))) return null;
|
|
69
248
|
return value;
|
|
70
249
|
}
|
|
71
|
-
|
|
250
|
+
|
|
251
|
+
function ToolCardMeta({ meta, action, t }) {
|
|
252
|
+
return h(React.Fragment, null,
|
|
253
|
+
meta.summary ? h('p', null, bounded(meta.summary)) : null,
|
|
254
|
+
h('small', { style: { display: 'block', opacity: .7 } }, [meta.nodeId, meta.agentId, meta.boardRoot].filter(Boolean).map(bounded).join(' · ')),
|
|
255
|
+
action === 'diagnose' ? h(React.Fragment, null,
|
|
256
|
+
h('p', null, `${t('read')}: ${t(meta.readyToRead ? 'yes' : 'no')} · ${t('write')}: ${t(meta.readyToWrite ? 'yes' : 'no')}`),
|
|
257
|
+
h('ul', null, ...meta.checks.map((check, i) => h('li', { key: i }, `${check.status === 'ok' ? '✓' : '•'} ${bounded(check.code)} — ${bounded(check.message)}`, check.remedy ? h('p', null, bounded(check.remedy)) : null)))) : null,
|
|
258
|
+
meta.diagnostics ? h('p', null, bounded(meta.diagnostics)) : null);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function ToolCard({ toolName, phase, block, t, inspect, sessionId, onOpenNode }) {
|
|
72
262
|
const action = toolName.replace(/^pinwhy_/, '');
|
|
73
263
|
const meta = phase === 'result' && block?.isError === false ? cardMeta(block, toolName) : null;
|
|
74
264
|
const failed = phase === 'result' && block?.isError === true;
|
|
75
265
|
const state = phase === 'preparing' ? 'preparing' : phase === 'result' ? (failed ? 'failed' : 'done') : 'running';
|
|
266
|
+
const accent = failed ? 'var(--dsw-alias-state-error-primary, #db5050)' : phase === 'result' ? '#10b981' : null;
|
|
76
267
|
const raw = (() => { try { return JSON.stringify({ call: block?.call, args: block?.argsRaw, content: block?.content, error: block?.error, meta: block?.meta }, null, 2); } catch { return 'Invalid recorded result'; } })();
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
h('
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
h('ul', null, ...meta.checks.map((check, i) => h('li', { key: i }, `${check.status === 'ok' ? '✓' : '•'} ${bounded(check.code)} — ${bounded(check.message)}`, check.remedy ? h('p', null, bounded(check.remedy)) : null)))) : null,
|
|
85
|
-
meta.diagnostics ? h('p', null, bounded(meta.diagnostics)) : null) : phase === 'result' ? h('p', null, t(failed ? 'failureDetail' : 'unknown')) : null,
|
|
268
|
+
|
|
269
|
+
return h('article', { 'data-pinwhy-tool': toolName, style: { ...box, borderRadius: 12, background: 'var(--dsw-alias-card-fill, transparent)', borderLeft: `3px solid ${accent ?? 'var(--dsw-alias-border-l2, #d4d4d8)'}` } },
|
|
270
|
+
h('header', { style: { display: 'flex', alignItems: 'center', gap: 6, fontWeight: 600, fontSize: 13 } },
|
|
271
|
+
h('span', null, t(action)),
|
|
272
|
+
h('span', { style: { opacity: .4 } }, '·'),
|
|
273
|
+
h('span', { style: { fontSize: 12, fontWeight: 500, color: accent ?? 'var(--dsw-alias-label-tertiary, #71717a)' } }, t(state))),
|
|
274
|
+
meta ? ToolCardMeta({ meta, action, t }) : phase === 'result' ? h('p', null, t(failed ? 'failureDetail' : 'unknown')) : null,
|
|
86
275
|
h('details', { open: failed || (phase === 'result' && !meta) }, h('summary', null, t('detail')), h('pre', { style: { whiteSpace: 'pre-wrap', overflowWrap: 'anywhere', maxHeight: 360, overflow: 'auto', fontSize: 12 } }, raw)),
|
|
87
|
-
typeof
|
|
276
|
+
meta?.nodeId && sessionId && typeof onOpenNode === 'function' ? h('button', { type: 'button', className: 'pinwhy-btn pinwhy-btn-outline', style: { height: 28, fontSize: 12, marginRight: 8, marginTop: 8 }, 'data-pinwhy-node-link': meta.nodeId,
|
|
277
|
+
onClick: () => onOpenNode(sessionId, meta.nodeId, meta.boardRoot) }, t('viewNode')) : null,
|
|
278
|
+
typeof inspect === 'function' ? h('button', { type: 'button', className: 'pinwhy-btn pinwhy-btn-outline', style: { height: 28, fontSize: 12, marginTop: 8 }, onClick: inspect }, t('inspect')) : null);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function PinwhyIcon({ size = 16, ...props }) {
|
|
282
|
+
return SvgIcon({ size, viewBox: '0 0 128 128', stroke: null, ...props },
|
|
283
|
+
h('path', { d: 'M73 20H38C28.059 20 20 28.059 20 38V90C20 99.941 28.059 108 38 108H90C99.941 108 108 99.941 108 90V65', stroke: 'currentColor', strokeWidth: 12, strokeLinecap: 'round', strokeLinejoin: 'round' }),
|
|
284
|
+
h('path', { d: 'M46 80L76 50', stroke: 'currentColor', strokeWidth: 12, strokeLinecap: 'round' }),
|
|
285
|
+
h('circle', { cx: 98, cy: 28, r: 10, fill: 'currentColor' }));
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/* ---- 4. Viewer & Global Panel Components ---- */
|
|
289
|
+
function MenuEntry({ t, onDismiss, open, kind, entries = [], onPinnedChange }) {
|
|
290
|
+
const entry = entries.find(row => row.id === 'pinwhy');
|
|
291
|
+
// The shipped global More menu owns unpinned entries, including their pin action.
|
|
292
|
+
if (kind === 'global' && entry?.pinned === false) return null;
|
|
293
|
+
const pinned = entry?.pinned !== false;
|
|
294
|
+
return h('div', { className: 'pinwhy-menu-row' },
|
|
295
|
+
!entry || kind === 'global' ? h('button', { type: 'button', role: 'menuitem', className: 'pinwhy-menu-entry',
|
|
296
|
+
[`data-pinwhy-${kind}-entry`]: true,
|
|
297
|
+
onClick: () => { open(); onDismiss(); } }, h(PinwhyIcon, {}), h('span', null, t('boardTitle'))) : null,
|
|
298
|
+
typeof onPinnedChange === 'function' ? h('button', { type: 'button', role: 'menuitem', className: 'pinwhy-menu-entry',
|
|
299
|
+
'data-pinwhy-pin': kind, 'aria-label': t(pinned ? 'unpin' : 'pin'),
|
|
300
|
+
onClick: () => { onPinnedChange('pinwhy', !pinned); onDismiss(); } },
|
|
301
|
+
h('span', { 'aria-hidden': true }, pinned ? '−' : '+'), h('span', null, t(pinned ? 'unpin' : 'pin'))) : null);
|
|
88
302
|
}
|
|
303
|
+
|
|
304
|
+
// Reader selection only. Board data stays in the CLI snapshot and event stream.
|
|
305
|
+
function createPanelSelection() {
|
|
306
|
+
let value, focus = { nodeId: null, boardRoot: null, revision: 0 };
|
|
307
|
+
const listeners = new Set();
|
|
308
|
+
return {
|
|
309
|
+
getSnapshot: () => value,
|
|
310
|
+
getFocusSnapshot: () => focus,
|
|
311
|
+
subscribe: listener => { listeners.add(listener); return () => listeners.delete(listener); },
|
|
312
|
+
select: (id, nodeId = null, boardRoot = null) => {
|
|
313
|
+
if (value === id && !nodeId && !focus.nodeId) return;
|
|
314
|
+
value = id; focus = { nodeId, boardRoot, revision: focus.revision + 1 };
|
|
315
|
+
for (const notify of listeners) notify();
|
|
316
|
+
},
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function GlobalPanel({ useSessions, t, selection, openViewer, retainSession, hostPresentation, referenceNode }) {
|
|
321
|
+
const catalog = useSessions(value => value);
|
|
322
|
+
const selected = React.useSyncExternalStore(selection.subscribe, selection.getSnapshot);
|
|
323
|
+
const focus = React.useSyncExternalStore(selection.subscribe, selection.getFocusSnapshot);
|
|
324
|
+
const rows = catalog.ids.map(id => catalog.byId[id]).filter(Boolean);
|
|
325
|
+
if (selected && !catalog.ids.includes(selected) && catalog.byId[selected]) rows.push(catalog.byId[selected]);
|
|
326
|
+
const groups = new Map();
|
|
327
|
+
for (const row of rows) {
|
|
328
|
+
const project = row.cwd || '';
|
|
329
|
+
if (!groups.has(project)) groups.set(project, []);
|
|
330
|
+
groups.get(project).push(row);
|
|
331
|
+
}
|
|
332
|
+
const selectedRow = catalog.byId[selected];
|
|
333
|
+
return h('section', { className: 'pinwhy-global', 'data-pinwhy-global-panel': true },
|
|
334
|
+
h('header', { className: 'pinwhy-global-header' },
|
|
335
|
+
h('div', { className: 'pinwhy-global-heading' }, h(PinwhyIcon, { size: 20 }),
|
|
336
|
+
h('div', null, h('h1', null, t('boardTitle')), h('p', null, t('boardSubtitle')))),
|
|
337
|
+
h('label', { className: 'pinwhy-session-picker' }, h('span', null, t('chooseSession')),
|
|
338
|
+
h('select', { value: selected ?? '', title: selectedRow?.cwd, 'aria-label': t('chooseSession'), 'data-pinwhy-session-picker': true,
|
|
339
|
+
onChange: event => selection.select(event.target.value || undefined) },
|
|
340
|
+
h('option', { value: '' }, t('chooseSession')),
|
|
341
|
+
...Array.from(groups, ([project, sessions]) => h('optgroup', { key: project, label: project ? boardName(project) : t('ungrouped') },
|
|
342
|
+
...sessions.map(row => h('option', { key: row.id, value: row.id, title: [row.cwd, row.id].filter(Boolean).join('\n') },
|
|
343
|
+
`${row.displayTitle || row.id}${row.blank ? ` · ${t('blankSession')}` : ''}`))))))),
|
|
344
|
+
h(ViewerPanel, { sessionId: selected, t, openViewer, retainSession, hostPresentation, referenceNode, focus }));
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function embeddedUrl(url, presentation, canReference = false) {
|
|
348
|
+
const parsed = new URL(url, 'http://host.invalid');
|
|
349
|
+
parsed.searchParams.set('embed', '1');
|
|
350
|
+
for (const key of ['theme', 'fontFamily', 'codeFontFamily', 'fontSize', 'codeFontSize']) {
|
|
351
|
+
if (presentation[key] !== undefined) parsed.searchParams.set(key, String(presentation[key]));
|
|
352
|
+
}
|
|
353
|
+
if (presentation.locale) parsed.searchParams.set('lang', presentation.locale);
|
|
354
|
+
if (canReference) parsed.searchParams.set('reference', '1');
|
|
355
|
+
return url.startsWith('/') ? parsed.pathname + parsed.search + parsed.hash : parsed.href;
|
|
356
|
+
}
|
|
357
|
+
const boardName = root => root.replace(/\\/g, '/').split('/').filter(Boolean).pop() || root;
|
|
358
|
+
|
|
359
|
+
/* ---- 5. Stylesheet ---- */
|
|
360
|
+
const clientCss = `
|
|
361
|
+
.pinwhy-menu-entry{display:flex;align-items:center;gap:10px;width:100%;padding:8px 12px;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-primary,inherit);font:var(--dsw-font-sm-14,inherit);font-size:14px;text-align:left;cursor:pointer}
|
|
362
|
+
.pinwhy-menu-entry:hover,.pinwhy-menu-entry:focus-visible{background:var(--dsw-alias-interactive-bg-hover,#f4f4f5);outline:none}
|
|
363
|
+
.pinwhy-menu-entry svg{flex:none}
|
|
364
|
+
.pinwhy-global,.pinwhy-viewer{display:flex;flex-direction:column;height:100%;min-height:0;min-width:0;overflow:hidden;background:var(--dsw-alias-bg-base,transparent);color:var(--dsw-alias-label-primary,inherit)}
|
|
365
|
+
.pinwhy-global{padding-top:var(--dsh-frame-top-clearance,0px);container:pinwhy-panel / inline-size}
|
|
366
|
+
.pinwhy-global-header{display:flex;align-items:center;justify-content:space-between;gap:20px;padding:20px 28px 16px;border-bottom:1px solid var(--dsw-alias-border-l1,#e5e7eb)}
|
|
367
|
+
.pinwhy-global-heading{display:flex;align-items:center;gap:12px;min-width:0}
|
|
368
|
+
.pinwhy-global-heading h1{margin:0;font-size:18px;font-weight:600;letter-spacing:-.02em}
|
|
369
|
+
.pinwhy-global-heading p{margin:4px 0 0;font-size:12px;color:var(--dsw-alias-label-tertiary,#71717a)}
|
|
370
|
+
.pinwhy-session-picker{display:flex;align-items:center;gap:10px;min-width:0;font-size:12px;color:var(--dsw-alias-label-tertiary,#71717a)}
|
|
371
|
+
.pinwhy-session-picker select{box-sizing:border-box;max-width:280px;min-width:0;padding:7px 10px;border:1px solid var(--dsw-alias-border-l2,#d4d4d8);border-radius:7px;background:var(--dsw-alias-bg-base,transparent);color:var(--dsw-alias-label-primary,inherit);font:inherit;text-overflow:ellipsis}
|
|
372
|
+
.pinwhy-session-picker select:focus-visible,.pinwhy-viewer-retry:focus-visible{outline:2px solid var(--dsw-alias-label-primary,currentColor);outline-offset:2px}
|
|
373
|
+
.pinwhy-viewer{flex:1}
|
|
374
|
+
.pinwhy-viewer-bar{display:flex;align-items:center;gap:8px;flex:none;height:36px;padding:0 16px;border-bottom:1px solid var(--dsw-alias-border-l1,#e5e7eb);font-size:12px;color:var(--dsw-alias-label-tertiary,#71717a)}
|
|
375
|
+
.pinwhy-board-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-primary,inherit);font-weight:600}
|
|
376
|
+
[data-pinwhy-read-only]{display:inline-flex;align-items:center;padding:1px 7px;border-radius:9999px;font-size:11px;font-weight:500;background:var(--dsw-alias-interactive-bg-hover,rgba(0,0,0,.05));color:var(--dsw-alias-label-secondary,#52525b)}
|
|
377
|
+
.pinwhy-viewer-refresh{display:grid;place-items:center;width:26px;height:26px;margin-left:auto;padding:0;border:0;border-radius:5px;background:transparent;color:inherit;cursor:pointer}
|
|
378
|
+
.pinwhy-viewer-refresh svg{transition:transform .25s ease}
|
|
379
|
+
.pinwhy-viewer-refresh:hover svg{transform:rotate(90deg)}
|
|
380
|
+
.pinwhy-viewer-refresh:hover,.pinwhy-viewer-refresh:focus-visible{background:var(--dsw-alias-interactive-bg-hover,#f4f4f5);outline:2px solid var(--dsw-alias-border-l2,#d4d4d8)}
|
|
381
|
+
.pinwhy-viewer-state{display:flex;flex:1;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:32px;text-align:center}
|
|
382
|
+
.pinwhy-viewer-state svg{color:var(--dsw-alias-label-tertiary,#71717a)}
|
|
383
|
+
.pinwhy-viewer-state h2{margin:0;font-size:16px;font-weight:500}
|
|
384
|
+
.pinwhy-viewer-state p{max-width:440px;margin:0;font-size:13px;line-height:1.6;color:var(--dsw-alias-label-tertiary,#71717a);overflow-wrap:anywhere}
|
|
385
|
+
.pinwhy-viewer-state details{max-width:520px;font-size:12px;text-align:left;color:var(--dsw-alias-label-tertiary,#71717a)}
|
|
386
|
+
.pinwhy-viewer-content{position:relative;display:flex;flex:1;min-height:0;min-width:0}
|
|
387
|
+
.pinwhy-frame-loading{position:absolute;inset:0;z-index:1;background:var(--dsw-alias-bg-base,Canvas)}
|
|
388
|
+
.pinwhy-spinner{box-sizing:border-box;width:24px;height:24px;border:2px solid var(--dsw-alias-border-l2,#d4d4d8);border-top-color:#10b981;border-radius:50%;animation:pinwhy-spin .8s linear infinite}
|
|
389
|
+
.pinwhy-viewer-retry{padding:8px 16px;border:1px solid var(--dsw-alias-border-l2,#d4d4d8);border-radius:7px;background:transparent;color:inherit;font:inherit;cursor:pointer}
|
|
390
|
+
.pinwhy-viewer-retry:hover{background:var(--dsw-alias-interactive-bg-hover,#f4f4f5)}
|
|
391
|
+
@keyframes pinwhy-spin{to{transform:rotate(360deg)}}
|
|
392
|
+
@media(prefers-reduced-motion:reduce){.pinwhy-spinner{animation:none}}
|
|
393
|
+
@container pinwhy-panel (max-width:620px){.pinwhy-global-header{padding:14px 16px;flex-wrap:wrap;gap:12px}.pinwhy-global-heading p{display:none}.pinwhy-session-picker{width:100%}.pinwhy-session-picker>span{flex:none}.pinwhy-session-picker select{flex:1;max-width:100%}}
|
|
394
|
+
@media(max-width:760px){.pinwhy-viewer-bar{padding:0 12px}}
|
|
395
|
+
.pinwhy-settings-wrap{box-sizing:border-box;max-width:860px;margin:12px auto 28px;display:flex;flex-direction:column;gap:18px;font-family:inherit;color:var(--dsw-alias-label-primary,inherit)}
|
|
396
|
+
.pinwhy-settings-card{box-sizing:border-box;background:var(--dsw-alias-card-fill,var(--dsw-alias-bg-base,#fff));border:1px solid var(--dsw-alias-border-l1,#e5e7eb);border-radius:12px;padding:18px 22px;display:flex;flex-direction:column;gap:14px;box-shadow:0 1px 3px rgba(0,0,0,.03)}
|
|
397
|
+
.pinwhy-settings-header{display:flex;flex-direction:column;gap:3px;border-bottom:1px solid var(--dsw-alias-border-l1,#e5e7eb);padding-bottom:12px}
|
|
398
|
+
.pinwhy-settings-title{display:flex;align-items:center;gap:8px;margin:0;font-size:15px;font-weight:600;letter-spacing:-.01em;color:var(--dsw-alias-label-primary,inherit)}
|
|
399
|
+
.pinwhy-settings-title h3,.pinwhy-settings-title h4{margin:0;font-size:inherit;font-weight:inherit}
|
|
400
|
+
.pinwhy-settings-desc{margin:0;font-size:13px;line-height:1.5;color:var(--dsw-alias-label-tertiary,#71717a)}
|
|
401
|
+
.pinwhy-toggle-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 14px;border-radius:8px;background:var(--dsw-alias-interactive-bg-hover,rgba(0,0,0,.02));border:1px solid var(--dsw-alias-border-l1,#e5e7eb);cursor:pointer;user-select:none}
|
|
402
|
+
.pinwhy-toggle-row:hover{border-color:var(--dsw-alias-border-l2,#d4d4d8)}
|
|
403
|
+
.pinwhy-toggle-info{display:flex;flex-direction:column;gap:2px}
|
|
404
|
+
.pinwhy-toggle-title{font-size:13px;font-weight:500;color:var(--dsw-alias-label-primary,inherit)}
|
|
405
|
+
.pinwhy-toggle-desc{font-size:12px;color:var(--dsw-alias-label-tertiary,#71717a)}
|
|
406
|
+
.pinwhy-toggle-checkbox{width:18px;height:18px;cursor:pointer;accent-color:#10b981}
|
|
407
|
+
.pinwhy-projects-list{display:flex;flex-direction:column;gap:10px}
|
|
408
|
+
.pinwhy-projects-empty{padding:20px;text-align:center;font-size:13px;color:var(--dsw-alias-label-tertiary,#71717a);border:1px dashed var(--dsw-alias-border-l2,#d4d4d8);border-radius:8px}
|
|
409
|
+
.pinwhy-project-card{box-sizing:border-box;padding:14px 16px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2,#d4d4d8);background:var(--dsw-alias-bg-base,transparent);display:flex;flex-direction:column;gap:10px}
|
|
410
|
+
.pinwhy-project-card-header{display:flex;align-items:center;justify-content:space-between}
|
|
411
|
+
.pinwhy-project-badge{font-size:12px;font-weight:600;color:var(--dsw-alias-label-secondary,#52525b);display:flex;align-items:center;gap:6px}
|
|
412
|
+
.pinwhy-project-fields{display:grid;grid-template-columns:1fr 1fr;gap:12px}
|
|
413
|
+
.pinwhy-project-add-bar{display:flex;gap:10px;align-items:center}
|
|
414
|
+
.pinwhy-field{display:flex;flex-direction:column;gap:5px}
|
|
415
|
+
.pinwhy-field-label{font-size:12px;font-weight:500;color:var(--dsw-alias-label-primary,inherit);display:flex;justify-content:space-between;align-items:baseline}
|
|
416
|
+
.pinwhy-field-hint{font-size:11px;font-weight:400;color:var(--dsw-alias-label-tertiary,#71717a)}
|
|
417
|
+
.pinwhy-input{box-sizing:border-box;width:100%;height:36px;padding:7px 12px;border:1px solid var(--dsw-alias-border-l2,#d4d4d8);border-radius:6px;background:var(--dsw-alias-bg-base,transparent);color:var(--dsw-alias-label-primary,inherit);font:inherit;font-size:13px;outline:none;transition:border-color .15s ease,box-shadow .15s ease}
|
|
418
|
+
.pinwhy-input:focus{border-color:#10b981;box-shadow:0 0 0 2px rgba(16,185,129,.2)}
|
|
419
|
+
.pinwhy-input::placeholder{color:var(--dsw-alias-label-tertiary,#a1a1aa);opacity:.8}
|
|
420
|
+
.pinwhy-grid-2{display:grid;grid-template-columns:1fr 1fr;gap:16px}
|
|
421
|
+
.pinwhy-btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;height:34px;padding:0 14px;border-radius:6px;font:inherit;font-size:13px;font-weight:500;cursor:pointer;white-space:nowrap;transition:all .15s ease;user-select:none;border:1px solid transparent}
|
|
422
|
+
.pinwhy-btn-primary{background:#10b981;color:#fff;border-color:#059669}
|
|
423
|
+
.pinwhy-btn-primary:hover:not(:disabled){background:#059669}
|
|
424
|
+
.pinwhy-btn-primary:disabled{opacity:.45;cursor:not-allowed}
|
|
425
|
+
.pinwhy-btn-outline{background:transparent;color:var(--dsw-alias-label-primary,inherit);border-color:var(--dsw-alias-border-l2,#d4d4d8)}
|
|
426
|
+
.pinwhy-btn-outline:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,#f4f4f5);border-color:var(--dsw-alias-label-tertiary,#a1a1aa)}
|
|
427
|
+
.pinwhy-btn-outline:disabled{opacity:.4;cursor:not-allowed}
|
|
428
|
+
.pinwhy-btn-danger{background:transparent;color:var(--dsw-alias-state-error-primary,#dc2626);border-color:transparent;padding:4px 8px;height:28px;font-size:12px}
|
|
429
|
+
.pinwhy-btn-danger:hover{background:rgba(220,38,38,.08)}
|
|
430
|
+
.pinwhy-settings-footer{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:8px 0}
|
|
431
|
+
.pinwhy-notice{font-size:13px;color:var(--dsw-alias-label-secondary,#52525b);display:flex;align-items:center;gap:6px}
|
|
432
|
+
.pinwhy-notice-success{color:#10b981;font-weight:500}
|
|
433
|
+
.pinwhy-notice-error{color:var(--dsw-alias-state-error-primary,#dc2626)}
|
|
434
|
+
.pinwhy-actions-group{display:flex;align-items:center;gap:10px;margin-left:auto}
|
|
435
|
+
.pinwhy-guide-callout{display:flex;align-items:flex-start;gap:10px;padding:12px 16px;border-radius:8px;background:rgba(16,185,129,.06);border:1px solid rgba(16,185,129,.2);font-size:12px;line-height:1.6;color:var(--dsw-alias-label-secondary,inherit)}
|
|
436
|
+
.pinwhy-guide-callout svg{flex:none;margin-top:2px;color:#10b981}
|
|
437
|
+
@media(max-width:680px){.pinwhy-project-fields,.pinwhy-grid-2{grid-template-columns:1fr}.pinwhy-project-add-bar{flex-direction:column;align-items:stretch}.pinwhy-settings-footer{flex-direction:column;align-items:stretch;gap:12px}.pinwhy-actions-group{justify-content:flex-end}}
|
|
438
|
+
`;
|
|
439
|
+
|
|
440
|
+
const loopbackHosts = ['localhost', '127.0.0.1', '[::1]'];
|
|
441
|
+
const viewerPrefix = '/pinwhy-viewer/';
|
|
442
|
+
|
|
443
|
+
/** The Host viewer mount, or an absolute loopback origin of it; nothing else is embeddable. */
|
|
444
|
+
function viewerUrl(url) {
|
|
445
|
+
if (typeof url !== 'string' || url === '' || url.length > 4096 || /[\u0000-\u0020\\]/.test(url)) return null;
|
|
446
|
+
if (url.startsWith('/')) {
|
|
447
|
+
if (url.startsWith('//')) return null;
|
|
448
|
+
const path = url.split(/[?#]/, 1)[0];
|
|
449
|
+
if (/(^|\/)\.\.?(\/|$)/.test(path)) return null;
|
|
450
|
+
return path.startsWith(viewerPrefix) && path.length > viewerPrefix.length ? url : null;
|
|
451
|
+
}
|
|
452
|
+
let parsed;
|
|
453
|
+
try { parsed = new URL(url); } catch { return null; }
|
|
454
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return null;
|
|
455
|
+
if (!loopbackHosts.includes(parsed.hostname)) return null;
|
|
456
|
+
return parsed.pathname.startsWith(viewerPrefix) && parsed.pathname.length > viewerPrefix.length ? url : null;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/** The `viewer.open` value, or null when any field cannot be trusted for embedding. */
|
|
460
|
+
function viewerValue(value) {
|
|
461
|
+
if (!value || typeof value !== 'object') return null;
|
|
462
|
+
const url = viewerUrl(value.url);
|
|
463
|
+
if (!url || !['boardRoot', 'agentId', 'viewerId'].every(key => typeof value[key] === 'string' && value[key] !== '')) return null;
|
|
464
|
+
return { url, boardRoot: value.boardRoot, agentId: value.agentId, viewerId: value.viewerId };
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
function viewerFailure(error) {
|
|
468
|
+
const code = typeof error?.code === 'string' && error.code !== '' ? error.code.slice(0, 80) : 'VIEWER_UNAVAILABLE';
|
|
469
|
+
const message = typeof error?.message === 'string' ? error.message.slice(0, 500) : '';
|
|
470
|
+
return { code, message };
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
const REMEDY_BY_CODE = {
|
|
474
|
+
RUNTIME_INCOMPATIBLE: 'upgradeHint',
|
|
475
|
+
RUNTIME_MISSING: 'runtimeHint',
|
|
476
|
+
NOT_ENABLED: 'setupHint',
|
|
477
|
+
BOARD_NOT_INITIALIZED: 'setupHint',
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
const STATUS_VIEW = {
|
|
481
|
+
empty: { role: 'status', heading: 'chooseSession', message: () => 'noSession' },
|
|
482
|
+
loading: { role: 'status', heading: 'viewerLoading', message: () => 'viewerLoadingHint' },
|
|
483
|
+
error: { role: 'alert', heading: 'viewerFailed', message: code => REMEDY_BY_CODE[code] ?? 'retryHint' },
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
function frameOrigin(frame) {
|
|
487
|
+
if (!frame?.src) return null;
|
|
488
|
+
try { return new URL(frame.src, typeof window !== 'undefined' && window.location ? window.location.href : undefined).origin; }
|
|
489
|
+
catch { return null; }
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
function useViewerSession({ sessionId, attempt, boardRoot, openViewer, retainSession }) {
|
|
493
|
+
const [result, setResult] = React.useState({ status: 'loading', for: undefined, attempt: 0 });
|
|
494
|
+
const [loadedFrame, setLoadedFrame] = React.useState(null);
|
|
495
|
+
React.useEffect(() => {
|
|
496
|
+
if (typeof sessionId !== 'string' || sessionId === '') return undefined;
|
|
497
|
+
const controller = new AbortController();
|
|
498
|
+
let live = true, reference;
|
|
499
|
+
setLoadedFrame(null);
|
|
500
|
+
setResult({ status: 'loading', for: sessionId, attempt });
|
|
501
|
+
const fail = error => { if (live) setResult({ status: 'error', for: sessionId, attempt, error: viewerFailure(error) }); };
|
|
502
|
+
(async () => {
|
|
503
|
+
reference = retainSession?.(sessionId);
|
|
504
|
+
if (reference) await reference.ready;
|
|
505
|
+
if (!live) return;
|
|
506
|
+
const response = await openViewer(sessionId, controller.signal);
|
|
507
|
+
if (!live) return;
|
|
508
|
+
if (response?.ok !== true) { fail(response?.error); return; }
|
|
509
|
+
const value = viewerValue(response.value);
|
|
510
|
+
if (!value) { fail({ code: 'VIEWER_INVALID', message: '' }); return; }
|
|
511
|
+
if (boardRoot && boardRoot !== value.boardRoot) { fail({ code: 'NOT_ENABLED', message: 'The recorded node belongs to a different board.' }); return; }
|
|
512
|
+
setResult({ status: 'ready', for: sessionId, attempt, value });
|
|
513
|
+
})().catch(fail);
|
|
514
|
+
return () => { live = false; controller.abort(); reference?.release(); };
|
|
515
|
+
}, [sessionId, attempt, boardRoot]);
|
|
516
|
+
|
|
517
|
+
const settled = typeof sessionId !== 'string' || !sessionId
|
|
518
|
+
? { status: 'empty' } : result.for === sessionId && result.attempt === attempt ? result : { status: 'loading' };
|
|
519
|
+
const ready = settled.status === 'ready' ? settled.value : null;
|
|
520
|
+
const frameKey = ready ? `${ready.viewerId}:${attempt}` : null;
|
|
521
|
+
const frameLoading = Boolean(ready && loadedFrame !== frameKey);
|
|
522
|
+
return { settled, ready, frameKey, frameLoading, markFrameLoaded: () => setLoadedFrame(frameKey) };
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
const validRefId = (value, max) => typeof value === 'string' && value.length > 0 && value.length <= max;
|
|
526
|
+
|
|
527
|
+
function useReferenceBridge({ frameRef, ready, referenceNode, sessionId, t }) {
|
|
528
|
+
React.useEffect(() => {
|
|
529
|
+
if (!ready || !referenceNode || typeof window === 'undefined' || typeof window.addEventListener !== 'function') return undefined;
|
|
530
|
+
const controller = new AbortController();
|
|
531
|
+
let pending = false;
|
|
532
|
+
const receive = async event => {
|
|
533
|
+
const frame = frameRef.current, origin = frameOrigin(frame);
|
|
534
|
+
if (!frame || !origin || event.source !== frame.contentWindow || event.origin !== origin) return;
|
|
535
|
+
const message = event.data;
|
|
536
|
+
if (message?.type !== 'pinwhy:reference' || !validRefId(message.nodeId, 256) || !validRefId(message.requestId, 128)) return;
|
|
537
|
+
const reply = (ok, text) => frame.contentWindow.postMessage({ type: 'pinwhy:reference-result', requestId: message.requestId, ok, message: text }, event.origin);
|
|
538
|
+
if (pending) { reply(false, t('referenceFailed')); return; }
|
|
539
|
+
pending = true;
|
|
540
|
+
try {
|
|
541
|
+
await referenceNode(sessionId, message.nodeId, ready.boardRoot, controller.signal);
|
|
542
|
+
if (!controller.signal.aborted) reply(true, t('referenceAdded'));
|
|
543
|
+
} catch { if (!controller.signal.aborted) reply(false, t('referenceFailed')); }
|
|
544
|
+
finally { pending = false; }
|
|
545
|
+
};
|
|
546
|
+
window.addEventListener('message', receive);
|
|
547
|
+
return () => { controller.abort(); window.removeEventListener('message', receive); };
|
|
548
|
+
}, [ready?.viewerId, ready?.boardRoot, referenceNode, sessionId]);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
function ViewerStatusView({ status, error, onRetry, t }) {
|
|
552
|
+
const spec = STATUS_VIEW[status] ?? STATUS_VIEW.loading;
|
|
553
|
+
const code = error?.code;
|
|
554
|
+
return h('div', { className: 'pinwhy-viewer-state', role: spec.role, 'data-pinwhy-viewer-error': code },
|
|
555
|
+
status === 'loading' ? h('span', { className: 'pinwhy-spinner', 'aria-hidden': true }) : h(PinwhyIcon, { size: 32 }),
|
|
556
|
+
h('h2', null, t(spec.heading)),
|
|
557
|
+
h('p', null, t(spec.message(code))),
|
|
558
|
+
status === 'error' ? h('button', { type: 'button', className: 'pinwhy-viewer-retry', onClick: onRetry }, t('viewerReconnect')) : null,
|
|
559
|
+
status === 'error' ? h('details', null, h('summary', null, t('viewerErrorDetails')), `${code} — ${error.message}`) : null);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Read-only Pinwhy workspace embedded from the Host's viewer mount.
|
|
564
|
+
* The Host owns the runtime process and its lifetime: unmount only aborts the
|
|
565
|
+
* in-flight open request, and a stale response never replaces a newer session.
|
|
566
|
+
*/
|
|
567
|
+
function ViewerPanel({ sessionId, t, openViewer, retainSession, hostPresentation, referenceNode, focus }) {
|
|
568
|
+
const [attempt, setAttempt] = React.useState(0);
|
|
569
|
+
const [appearance] = React.useState(() => hostPresentation?.getSnapshot() ?? { theme: 'light' });
|
|
570
|
+
const frameRef = React.useRef(null);
|
|
571
|
+
const focused = React.useRef(null);
|
|
572
|
+
const { settled, ready, frameKey, frameLoading, markFrameLoaded } = useViewerSession({
|
|
573
|
+
sessionId, attempt, boardRoot: focus?.boardRoot, openViewer, retainSession,
|
|
574
|
+
});
|
|
575
|
+
const reload = () => setAttempt(value => value + 1);
|
|
576
|
+
const postToFrame = payload => {
|
|
577
|
+
const frame = frameRef.current, origin = frameOrigin(frame);
|
|
578
|
+
if (frame?.contentWindow && origin) { frame.contentWindow.postMessage(payload, origin); return true; }
|
|
579
|
+
return false;
|
|
580
|
+
};
|
|
581
|
+
const sendAppearance = () => postToFrame({ type: 'pinwhy:appearance', ...(hostPresentation?.getSnapshot() ?? appearance) });
|
|
582
|
+
const sendFocus = () => {
|
|
583
|
+
const key = focus?.nodeId && (!focus.boardRoot || focus.boardRoot === ready?.boardRoot) ? `${frameKey}:${focus.revision}` : null;
|
|
584
|
+
if (key && focused.current !== key && postToFrame({ type: 'pinwhy:navigate', nodeId: focus.nodeId, requestId: key })) {
|
|
585
|
+
focused.current = key;
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
React.useEffect(() => hostPresentation?.subscribe(sendAppearance), [hostPresentation, ready?.viewerId]);
|
|
589
|
+
React.useEffect(() => { if (!frameLoading) sendFocus(); }, [focus?.revision, frameLoading, frameKey]);
|
|
590
|
+
useReferenceBridge({ frameRef, ready, referenceNode, sessionId, t });
|
|
591
|
+
|
|
592
|
+
const reloadLabel = t(settled.status === 'error' ? 'viewerReconnect' : 'viewerReload');
|
|
593
|
+
const body = ready
|
|
594
|
+
? h('div', { className: 'pinwhy-viewer-content' },
|
|
595
|
+
h('iframe', {
|
|
596
|
+
key: frameKey, ref: frameRef, src: embeddedUrl(ready.url, appearance, Boolean(referenceNode)), title: t('boardTitle'), 'data-pinwhy-viewer': ready.viewerId,
|
|
597
|
+
onLoad: () => { sendAppearance(); focused.current = null; markFrameLoaded(); sendFocus(); }, style: { display: 'block', flex: 1, width: '100%', minHeight: 0, border: 0 },
|
|
598
|
+
}),
|
|
599
|
+
frameLoading ? h('div', { className: 'pinwhy-viewer-state pinwhy-frame-loading', role: 'status' },
|
|
600
|
+
h('span', { className: 'pinwhy-spinner', 'aria-hidden': true }), h('p', null, t('viewerLoading'))) : null)
|
|
601
|
+
: ViewerStatusView({ status: settled.status, error: settled.error, onRetry: reload, t });
|
|
602
|
+
|
|
603
|
+
return h('div', { className: 'pinwhy-viewer', 'aria-busy': settled.status === 'loading' || frameLoading, 'data-pinwhy-viewer-pane': true, 'data-pinwhy-viewer-status': settled.status },
|
|
604
|
+
h('div', { className: 'pinwhy-viewer-bar' },
|
|
605
|
+
ready ? h('span', { className: 'pinwhy-board-name', 'data-pinwhy-board-root': true, title: ready.boardRoot }, boardName(ready.boardRoot)) : h('span', null, 'Pinwhy'),
|
|
606
|
+
h('span', { 'aria-hidden': true }, '·'), h('span', { 'data-pinwhy-read-only': true }, t('readOnlyBadge')),
|
|
607
|
+
sessionId ? h('button', { type: 'button', className: 'pinwhy-viewer-refresh', 'data-pinwhy-reload': true,
|
|
608
|
+
title: reloadLabel, 'aria-label': reloadLabel, onClick: reload },
|
|
609
|
+
SvgIcon({ size: 14, strokeWidth: 1.5 }, h('path', { d: 'M20 7v5h-5M4 17v-5h5M6.1 6.1a8 8 0 0 1 13 2.9M4.9 15a8 8 0 0 0 13 2.9' }))) : null),
|
|
610
|
+
body);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
/* ---- 6. Host Plugin Lifecycle & Slots ---- */
|
|
614
|
+
function createHostPresentation(ctx) {
|
|
615
|
+
const getSnapshot = () => {
|
|
616
|
+
const theme = ctx.theme.getTheme(), language = ctx.locale.getSnapshot().active;
|
|
617
|
+
const locale = /^(zh-hk|zh-tw|zh-hant)$/i.test(language) ? 'zh-HK' : /^zh/i.test(language) ? 'zh-CN' : /^ja/i.test(language) ? 'ja' : 'en';
|
|
618
|
+
return { theme: theme.active.colorScheme, locale, fontFamily: theme.fontFamilies.text, codeFontFamily: theme.fontFamilies.code,
|
|
619
|
+
fontSize: theme.fontSizes.text, codeFontSize: theme.fontSizes.code };
|
|
620
|
+
};
|
|
621
|
+
const subscribe = listener => {
|
|
622
|
+
const theme = ctx.on('theme/change', listener), locale = ctx.locale.subscribe(listener);
|
|
623
|
+
return () => { theme(); locale(); };
|
|
624
|
+
};
|
|
625
|
+
return { getSnapshot, subscribe };
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
function createNodeReferencer(ctx, retainSession) {
|
|
629
|
+
return async (sessionId, nodeId, boardRoot, signal) => {
|
|
630
|
+
const reference = retainSession(sessionId);
|
|
631
|
+
try {
|
|
632
|
+
await reference.ready; signal.throwIfAborted();
|
|
633
|
+
const result = await ctx.connection.rpc.call('/api', 'pinwhy/node.read', { sessionId, nodeId }, signal);
|
|
634
|
+
signal.throwIfAborted();
|
|
635
|
+
if (!result?.ok || result.value?.boardRoot !== boardRoot || result.value.node?.id !== nodeId) throw new Error('Reference is unavailable.');
|
|
636
|
+
const scope = ctx.sessions.scope(sessionId);
|
|
637
|
+
if (!scope) throw new Error('The owning Session has closed.');
|
|
638
|
+
const input = ctx.conversation.input.for(scope);
|
|
639
|
+
const text = `Pinwhy · ${nodeId}\n${boardRoot}\n${JSON.stringify(result.value.node, null, 2)}`;
|
|
640
|
+
if (!input.insertQuote(text)) throw new Error('The draft cannot accept a reference right now.');
|
|
641
|
+
ctx.uiWorkspace.openSession(sessionId);
|
|
642
|
+
input.focus();
|
|
643
|
+
} finally { reference.release(); }
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
|
|
89
647
|
return {
|
|
90
|
-
name: 'pinwhy-client',
|
|
648
|
+
name: 'pinwhy-client',
|
|
649
|
+
inject: ['slots', 'locale', 'connection', 'layout', 'uiSession', 'sessions', 'theme', 'shortcuts', 'uiWorkspace', 'conversation'],
|
|
91
650
|
apply(ctx) {
|
|
651
|
+
const t = ctx.locale.bind(NS);
|
|
92
652
|
ctx.effect(() => ctx.locale.register(NS, dictionaries));
|
|
653
|
+
const selection = createPanelSelection();
|
|
654
|
+
const openViewer = (sessionId, signal) => ctx.connection.rpc.call('/api', 'pinwhy/viewer.open', { sessionId }, signal);
|
|
655
|
+
const retainSession = sessionId => ctx.sessions.retain(sessionId, { source: 'pinwhyView' });
|
|
656
|
+
const openBoard = (sessionId, nodeId = null, boardRoot = null) => {
|
|
657
|
+
selection.select(sessionId, nodeId, boardRoot);
|
|
658
|
+
ctx.layout.selectPanel('pinwhy');
|
|
659
|
+
};
|
|
660
|
+
const hostPresentation = createHostPresentation(ctx);
|
|
661
|
+
const referenceNode = createNodeReferencer(ctx, retainSession);
|
|
662
|
+
ctx.effect(() => ctx.shortcuts.register({
|
|
663
|
+
id: 'pinwhy.openBoard', label: () => t('openCommand'), aliases: ['pinwhy'], defaults: {}, regions: ['page', 'editable'], modals: [],
|
|
664
|
+
resolve: () => {
|
|
665
|
+
const id = ctx.uiSession.adapter.current.getSnapshot().key;
|
|
666
|
+
return { status: 'handled', run: () => openBoard(id) };
|
|
667
|
+
},
|
|
668
|
+
}));
|
|
669
|
+
ctx.effect(() => {
|
|
670
|
+
if (typeof document === 'undefined') return () => { /* no DOM in headless test */ };
|
|
671
|
+
const style = document.createElement('style'); style.textContent = clientCss; document.head.appendChild(style);
|
|
672
|
+
return () => style.remove();
|
|
673
|
+
});
|
|
674
|
+
// Settings forms
|
|
93
675
|
ctx.slots.inject('plugins.row.config', () => ctx.slots.register({ name: 'plugins.row.config', key: 'dsh-pinwhy#pinwhy', locale: NS }, props => props.view === 'summary' ? props.t('summary') : h(Editor, props)));
|
|
94
676
|
ctx.slots.inject('plugins.bundle.config', () => ctx.slots.register({ name: 'plugins.bundle.config', key: 'dsh-pinwhy', locale: NS }, ({ t }) => h('p', null, t('rowHint'))));
|
|
95
|
-
|
|
677
|
+
|
|
678
|
+
// Result-only tool cards; no live board events are synthesized from chat calls.
|
|
679
|
+
for (const action of actions) {
|
|
680
|
+
ctx.slots.inject('tool.call.toolview', () => ctx.slots.register({ name: 'tool.call.toolview', key: `pinwhy_${action}`, locale: NS }, props => h(ToolCard, { ...props, onOpenNode: openBoard })));
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
ctx.slots.inject('main', () => ctx.slots.register({ name: 'main', key: 'pinwhy', locale: NS },
|
|
684
|
+
props => h(GlobalPanel, { ...props, selection, openViewer, retainSession, hostPresentation, referenceNode })));
|
|
685
|
+
ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({ name: 'sidebar.panellist', id: 'pinwhy', order: 30, label: () => t('boardTitle'), locale: NS }, props => h(PinwhyIcon, { size: props.size })));
|
|
686
|
+
ctx.slots.inject('sidebar.panellist.actions', () => ctx.slots.register({
|
|
687
|
+
name: 'sidebar.panellist.actions', id: 'pinwhy', order: 20, locale: NS,
|
|
688
|
+
}, props => h(MenuEntry, { ...props, kind: 'global', open: () => openBoard(ctx.uiSession.adapter.current.getSnapshot().key) })));
|
|
689
|
+
ctx.slots.inject('conversation.view', () => ctx.slots.register({
|
|
690
|
+
name: 'conversation.view', id: 'pinwhy', order: 30, label: () => t('boardTitle'), locale: NS,
|
|
691
|
+
}, props => h(ViewerPanel, { ...props, openViewer, retainSession, hostPresentation, referenceNode })));
|
|
692
|
+
ctx.slots.inject('conversation.session.header.views.actions', () => ctx.slots.register({
|
|
693
|
+
name: 'conversation.session.header.views.actions', id: 'pinwhy', order: 20, locale: NS,
|
|
694
|
+
}, props => h(MenuEntry, { ...props, kind: 'conversation', open: () => props.onOpen('pinwhy') })));
|
|
96
695
|
},
|
|
97
696
|
// Pure seams used by package tests; no browser or Host state is accessed.
|
|
98
|
-
test: { initial, edits, cardMeta, ToolCard, Editor },
|
|
697
|
+
test: { initial, edits, cardMeta, ToolCard, Editor, MenuEntry, ViewerPanel, GlobalPanel, createPanelSelection, embeddedUrl, viewerUrl, viewerValue, viewerFailure },
|
|
99
698
|
};
|
|
100
699
|
} });
|