@infinity_cheng/dsh-prompt-editor 0.3.2 → 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 +52 -12
- package/client.js +482 -69
- package/index.js +320 -21
- package/locale/en.json +28 -3
- package/locale/zh.json +28 -3
- package/package.json +1 -1
- package/rules.mjs +85 -2
package/client.js
CHANGED
|
@@ -19,7 +19,7 @@ window.__ModuleLoader__.load({
|
|
|
19
19
|
})()
|
|
20
20
|
|
|
21
21
|
const NS = 'prompt-editor'
|
|
22
|
-
const
|
|
22
|
+
const MODES = ['intent-first', 'strict']
|
|
23
23
|
const OPEN_TAG = '<enhanced_prompt>'
|
|
24
24
|
const CLOSE_TAG = '</enhanced_prompt>'
|
|
25
25
|
const IS_MAC = typeof navigator !== 'undefined' && /Mac|iPhone|iPad/.test(navigator.platform || '')
|
|
@@ -59,15 +59,37 @@ window.__ModuleLoader__.load({
|
|
|
59
59
|
'dialog.stale': '草稿已变化,请重新打开。',
|
|
60
60
|
'dialog.warnings': '校验提示',
|
|
61
61
|
'dialog.close': '关闭',
|
|
62
|
+
'dialog.view': '显示方式',
|
|
63
|
+
'dialog.viewDiff': '差异',
|
|
64
|
+
'dialog.viewSide': '对照',
|
|
65
|
+
'dialog.diffTitle': '原文 → 改写',
|
|
66
|
+
'dialog.diffLegend': '删除 / 新增',
|
|
67
|
+
'dialog.copy': '复制',
|
|
68
|
+
'dialog.copied': '已复制',
|
|
69
|
+
'dialog.stop': '停止',
|
|
70
|
+
'dialog.stopped': '已停止生成',
|
|
71
|
+
'undo.done': '已替换',
|
|
72
|
+
'undo.action': '撤销',
|
|
73
|
+
'undo.close': '关闭撤销提示',
|
|
62
74
|
'mode.intent-first': '意图优先',
|
|
63
75
|
'mode.strict': '最小改动',
|
|
64
76
|
'settings.nav': '提示词增强',
|
|
65
77
|
'settings.title': '提示词增强',
|
|
66
|
-
'settings.intro': '
|
|
78
|
+
'settings.intro': '默认规则保存到当前 DSH profile,输入框按钮和 Agent 工具共用。',
|
|
67
79
|
'settings.mode': '默认规则',
|
|
68
80
|
'settings.modeHint': '意图优先会补全成任务说明;最小改动只消除歧义。',
|
|
69
|
-
'settings.profileDefault': 'Profile
|
|
70
|
-
'settings.
|
|
81
|
+
'settings.profileDefault': 'Profile 配置:{mode}',
|
|
82
|
+
'settings.persisted': '保存后写入当前 profile 的插件配置,换浏览器或清缓存都不会丢。',
|
|
83
|
+
'settings.saving': '保存中…',
|
|
84
|
+
'settings.saveError': '保存失败:{message}',
|
|
85
|
+
'settings.modelTitle': '增强模型',
|
|
86
|
+
'settings.modelHint': '关闭时跟随当前会话模型;开启后固定使用下面的模型。',
|
|
87
|
+
'settings.useCustomModel': '使用增强专用模型',
|
|
88
|
+
'settings.modelLoading': '正在读取模型…',
|
|
89
|
+
'settings.modelLoadError': '模型目录读取失败',
|
|
90
|
+
'settings.modelPlaceholder': '跟随当前会话模型',
|
|
91
|
+
'settings.modelChoose': '请选择模型',
|
|
92
|
+
'settings.savedModel': '已保存:{model}(当前未启用)',
|
|
71
93
|
}
|
|
72
94
|
|
|
73
95
|
function makeText(t) {
|
|
@@ -88,22 +110,6 @@ window.__ModuleLoader__.load({
|
|
|
88
110
|
}
|
|
89
111
|
}
|
|
90
112
|
|
|
91
|
-
function readMode() {
|
|
92
|
-
try {
|
|
93
|
-
return localStorage.getItem(MODE_KEY) === 'strict' ? 'strict' : 'intent-first'
|
|
94
|
-
} catch {
|
|
95
|
-
return 'intent-first'
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function writeMode(mode) {
|
|
100
|
-
try {
|
|
101
|
-
localStorage.setItem(MODE_KEY, mode === 'strict' ? 'strict' : 'intent-first')
|
|
102
|
-
} catch {
|
|
103
|
-
// Storage may be disabled; the component still keeps its local state.
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
113
|
/** Show only the prompt body while the model is still emitting its tagged answer. */
|
|
108
114
|
/**
|
|
109
115
|
* Map clipboard-text coordinates (the draft string) to the editor's
|
|
@@ -222,7 +228,8 @@ window.__ModuleLoader__.load({
|
|
|
222
228
|
.dsh-prompt-editor-trigger:disabled{opacity:.45;cursor:default}
|
|
223
229
|
.dsh-prompt-editor-trigger svg{display:block;flex:0 0 auto}
|
|
224
230
|
.dsh-prompt-editor-overlay{position:fixed;inset:0;z-index:10000;display:flex;align-items:center;justify-content:center;padding:24px;background:rgba(0,0,0,.38)}
|
|
225
|
-
.dsh-prompt-editor-dialog{display:flex;flex-direction:column;width:min(920px,100%);max-height:min(760px,88vh);overflow:hidden;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l1);border-radius:14px;box-shadow:0 18px 60px rgba(0,0,0,.28)}
|
|
231
|
+
.dsh-prompt-editor-dialog{display:flex;flex-direction:column;width:min(920px,100%);max-height:min(760px,88vh);overflow:hidden;background-color:var(--dsw-static-neutral-bluish-00,#fff);background-image:linear-gradient(var(--dsw-alias-bg-base),var(--dsw-alias-bg-base));color:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l1);border-radius:14px;box-shadow:0 18px 60px rgba(0,0,0,.28)}
|
|
232
|
+
body[data-ds-dark-theme] .dsh-prompt-editor-dialog{background-color:var(--dsw-static-neutral-bluish-950,#16171b)}
|
|
226
233
|
.dsh-prompt-editor-head{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:14px 16px;border-bottom:1px solid var(--dsw-alias-border-l1)}
|
|
227
234
|
.dsh-prompt-editor-titleWrap{display:flex;align-items:center;gap:10px;min-width:0}
|
|
228
235
|
.dsh-prompt-editor-title{font-size:14px;line-height:20px;font-weight:600;color:var(--dsw-alias-label-primary)}
|
|
@@ -252,9 +259,27 @@ window.__ModuleLoader__.load({
|
|
|
252
259
|
.dsh-prompt-editor-btn:disabled{opacity:.45;cursor:default}
|
|
253
260
|
.dsh-prompt-editor-btnPrimary{border-color:transparent;background:var(--dsw-alias-button-primary-fill,var(--dsw-alias-brand-primary-new-colorprimary-new-color,#2f6fed));color:var(--dsw-alias-label-on-color,#fff)}
|
|
254
261
|
.dsh-prompt-editor-btnPrimary:hover:not(:disabled){background:var(--dsw-alias-button-primary-fill,var(--dsw-alias-brand-primary-new-colorprimary-new-color,#2f6fed));filter:brightness(1.05)}
|
|
262
|
+
.dsh-prompt-editor-viewToggle{display:inline-flex;padding:2px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-layer-1)}
|
|
263
|
+
.dsh-prompt-editor-viewToggle button{height:24px;padding:0 8px;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:11px;cursor:pointer}
|
|
264
|
+
.dsh-prompt-editor-viewToggle button[aria-pressed="true"]{background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);box-shadow:0 1px 2px rgba(0,0,0,.12)}
|
|
265
|
+
.dsh-prompt-editor-diffPane{grid-column:1/-1}
|
|
266
|
+
.dsh-prompt-editor-diffHead{display:flex;align-items:center;justify-content:space-between;gap:8px}
|
|
267
|
+
.dsh-prompt-editor-diffLegend{color:var(--dsw-alias-label-secondary);font-size:11px}
|
|
268
|
+
.dsh-prompt-editor-diffPre ins{padding:0 2px;border-radius:3px;background:rgba(46,160,67,.18);color:inherit;text-decoration:none}
|
|
269
|
+
.dsh-prompt-editor-diffPre del{padding:0 2px;border-radius:3px;background:rgba(248,81,73,.16);color:var(--dsw-alias-label-secondary);text-decoration:line-through}
|
|
270
|
+
.dsh-prompt-editor-undoToast{position:fixed;right:24px;bottom:96px;z-index:1000;display:flex;align-items:center;gap:10px;padding:8px 10px 8px 12px;border:1px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);box-shadow:0 8px 30px rgba(0,0,0,.2);font-size:12px}
|
|
271
|
+
.dsh-prompt-editor-undoToast button{height:26px;padding:0 8px;border:1px solid var(--dsw-alias-border-l1);border-radius:7px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:inherit;font-size:12px;cursor:pointer}
|
|
272
|
+
.dsh-prompt-editor-undoToast button:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
273
|
+
.dsh-prompt-editor-undoToast .dsh-prompt-editor-iconBtn{width:24px;height:24px;border-color:transparent}
|
|
255
274
|
.dsh-prompt-editor-settings{display:flex;flex-direction:column;gap:10px;max-width:760px}
|
|
256
275
|
.dsh-prompt-editor-settings h2{margin:0;font-size:14px;line-height:22px;font-weight:600;color:var(--dsw-alias-label-primary)}
|
|
257
276
|
.dsh-prompt-editor-settings p{margin:0;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px}
|
|
277
|
+
.dsh-prompt-editor-settings .dsh-prompt-editor-error{margin:0}
|
|
278
|
+
.dsh-prompt-editor-settingsControl{display:flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:flex-end}
|
|
279
|
+
.dsh-prompt-editor-settingsModel{max-width:300px}
|
|
280
|
+
.dsh-prompt-editor-checkbox{width:16px;height:16px;margin:0;accent-color:var(--dsw-alias-brand-primary-new-colorprimary-new-color,#2f6fed);cursor:pointer}
|
|
281
|
+
.dsh-prompt-editor-toggle{display:inline-flex;align-items:center;gap:7px;color:var(--dsw-alias-label-primary);font-size:12px;cursor:pointer;user-select:none}
|
|
282
|
+
.dsh-prompt-editor-savedModel{margin:0!important;color:var(--dsw-alias-label-secondary)!important;font-size:11px!important}
|
|
258
283
|
.dsh-prompt-editor-settingsRow{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 14px;border:1px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-1)}
|
|
259
284
|
.dsh-prompt-editor-settingsCopy{display:flex;flex-direction:column;gap:2px;min-width:0}
|
|
260
285
|
.dsh-prompt-editor-settingsTitle{color:var(--dsw-alias-label-primary);font-size:13px;line-height:20px;font-weight:500}
|
|
@@ -276,14 +301,109 @@ window.__ModuleLoader__.load({
|
|
|
276
301
|
h('path', { d: 'M4 20l4.2-1.1L20 7.1 16.9 4 5.1 15.8 4 20z' }),
|
|
277
302
|
h('path', { d: 'M14.5 6.5l3 3' }))
|
|
278
303
|
|
|
279
|
-
function
|
|
304
|
+
function diffTokens(before, after) {
|
|
305
|
+
const tokenize = (value) => value.match(/[\p{Script=Han}]|[A-Za-z0-9_]+|[ \t]+|\n|[^\s]/gu) ?? []
|
|
306
|
+
const a = tokenize(before)
|
|
307
|
+
const b = tokenize(after)
|
|
308
|
+
if (a.length * b.length > 2_500_000) {
|
|
309
|
+
return [
|
|
310
|
+
...(before === '' ? [] : [{ type: 'del', text: before }]),
|
|
311
|
+
...(after === '' ? [] : [{ type: 'ins', text: after }]),
|
|
312
|
+
]
|
|
313
|
+
}
|
|
314
|
+
const width = b.length + 1
|
|
315
|
+
const dp = new Uint32Array((a.length + 1) * width)
|
|
316
|
+
for (let i = a.length - 1; i >= 0; i -= 1) {
|
|
317
|
+
for (let j = b.length - 1; j >= 0; j -= 1) {
|
|
318
|
+
dp[i * width + j] = a[i] === b[j]
|
|
319
|
+
? dp[(i + 1) * width + j + 1] + 1
|
|
320
|
+
: Math.max(dp[(i + 1) * width + j], dp[i * width + j + 1])
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
const ops = []
|
|
324
|
+
let i = 0
|
|
325
|
+
let j = 0
|
|
326
|
+
while (i < a.length && j < b.length) {
|
|
327
|
+
if (a[i] === b[j]) {
|
|
328
|
+
ops.push({ type: 'equal', text: a[i] })
|
|
329
|
+
i += 1
|
|
330
|
+
j += 1
|
|
331
|
+
} else if (dp[(i + 1) * width + j] >= dp[i * width + j + 1]) {
|
|
332
|
+
ops.push({ type: 'del', text: a[i] })
|
|
333
|
+
i += 1
|
|
334
|
+
} else {
|
|
335
|
+
ops.push({ type: 'ins', text: b[j] })
|
|
336
|
+
j += 1
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
while (i < a.length) {
|
|
340
|
+
ops.push({ type: 'del', text: a[i] })
|
|
341
|
+
i += 1
|
|
342
|
+
}
|
|
343
|
+
while (j < b.length) {
|
|
344
|
+
ops.push({ type: 'ins', text: b[j] })
|
|
345
|
+
j += 1
|
|
346
|
+
}
|
|
347
|
+
const merged = []
|
|
348
|
+
for (const op of ops) {
|
|
349
|
+
const last = merged[merged.length - 1]
|
|
350
|
+
if (last !== undefined && last.type === op.type) last.text += op.text
|
|
351
|
+
else merged.push({ ...op })
|
|
352
|
+
}
|
|
353
|
+
return merged
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function InlineDiff({ before, after }) {
|
|
357
|
+
const ops = useMemo(() => diffTokens(before, after), [before, after])
|
|
358
|
+
return h('pre', { className: 'dsh-prompt-editor-pre dsh-prompt-editor-diffPre', tabIndex: 0 },
|
|
359
|
+
ops.map((op, index) => op.type === 'equal'
|
|
360
|
+
? h('span', { key: index }, op.text)
|
|
361
|
+
: h(op.type === 'del' ? 'del' : 'ins', { key: index }, op.text)))
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
async function copyToClipboard(value) {
|
|
365
|
+
try {
|
|
366
|
+
if (typeof navigator !== 'undefined' && navigator.clipboard?.writeText !== undefined) {
|
|
367
|
+
await navigator.clipboard.writeText(value)
|
|
368
|
+
return true
|
|
369
|
+
}
|
|
370
|
+
} catch {
|
|
371
|
+
// Fall through to the DOM copy path.
|
|
372
|
+
}
|
|
373
|
+
try {
|
|
374
|
+
const area = document.createElement('textarea')
|
|
375
|
+
area.value = value
|
|
376
|
+
area.setAttribute('readonly', '')
|
|
377
|
+
area.style.position = 'fixed'
|
|
378
|
+
area.style.opacity = '0'
|
|
379
|
+
document.body.appendChild(area)
|
|
380
|
+
area.select()
|
|
381
|
+
const ok = document.execCommand('copy')
|
|
382
|
+
area.remove()
|
|
383
|
+
return ok
|
|
384
|
+
} catch {
|
|
385
|
+
return false
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function PreviewDialog({ state, text, onClose, onAccept, onRetry, onMode, onStop }) {
|
|
280
390
|
const acceptRef = useRef(null)
|
|
281
391
|
const cancelRef = useRef(null)
|
|
392
|
+
const stopRef = useRef(null)
|
|
282
393
|
const dialogRef = useRef(null)
|
|
394
|
+
const copiedTimerRef = useRef(null)
|
|
395
|
+
const [view, setView] = useState('side')
|
|
396
|
+
const [copied, setCopied] = useState(false)
|
|
397
|
+
|
|
398
|
+
useEffect(() => () => clearTimeout(copiedTimerRef.current), [])
|
|
283
399
|
|
|
284
400
|
useEffect(() => {
|
|
285
401
|
const timer = setTimeout(() => {
|
|
286
402
|
if (state.loading) {
|
|
403
|
+
if (stopRef.current !== null && stopRef.current.disabled === false) {
|
|
404
|
+
stopRef.current.focus?.()
|
|
405
|
+
return
|
|
406
|
+
}
|
|
287
407
|
cancelRef.current?.focus?.()
|
|
288
408
|
return
|
|
289
409
|
}
|
|
@@ -293,25 +413,33 @@ window.__ModuleLoader__.load({
|
|
|
293
413
|
target?.focus?.()
|
|
294
414
|
}, 30)
|
|
295
415
|
return () => clearTimeout(timer)
|
|
296
|
-
}, [state.loading, state.result])
|
|
416
|
+
}, [state.loading, state.result, state.stopped])
|
|
417
|
+
|
|
418
|
+
useEffect(() => {
|
|
419
|
+
setCopied(false)
|
|
420
|
+
}, [state.result])
|
|
297
421
|
|
|
298
422
|
const result = state.result
|
|
299
423
|
const enhanced = result?.prompt ?? visibleText(state.raw)
|
|
300
424
|
const fallback = result?.status === 'fallback'
|
|
301
425
|
const unchanged = result !== null && result.changed === false && !fallback
|
|
426
|
+
const stopped = state.stopped === true
|
|
302
427
|
const canAccept = result !== null && result.changed === true && !fallback && state.loading !== true
|
|
428
|
+
const canCopy = result !== null && state.loading !== true
|
|
303
429
|
const warningCount = result?.warnings?.length ?? 0
|
|
304
430
|
const statusText = state.loading
|
|
305
431
|
? text('dialog.loading')
|
|
306
|
-
:
|
|
307
|
-
? text('dialog.
|
|
308
|
-
:
|
|
309
|
-
? text('dialog.
|
|
310
|
-
:
|
|
311
|
-
? text('dialog.
|
|
312
|
-
:
|
|
313
|
-
? text('dialog.
|
|
314
|
-
:
|
|
432
|
+
: stopped
|
|
433
|
+
? text('dialog.stopped')
|
|
434
|
+
: state.error !== null
|
|
435
|
+
? text('dialog.failed')
|
|
436
|
+
: fallback
|
|
437
|
+
? text('dialog.fallback')
|
|
438
|
+
: unchanged
|
|
439
|
+
? text('dialog.unchanged')
|
|
440
|
+
: result !== null
|
|
441
|
+
? text('dialog.done', { count: warningCount })
|
|
442
|
+
: ''
|
|
315
443
|
const acceptLabel = fallback
|
|
316
444
|
? text('dialog.fallbackShort')
|
|
317
445
|
: unchanged
|
|
@@ -320,6 +448,64 @@ window.__ModuleLoader__.load({
|
|
|
320
448
|
? text('dialog.replaceSelection')
|
|
321
449
|
: text('dialog.replaceWhole')
|
|
322
450
|
|
|
451
|
+
const copy = async () => {
|
|
452
|
+
if (!canCopy || result === null) return
|
|
453
|
+
const ok = await copyToClipboard(result.prompt)
|
|
454
|
+
if (!ok) return
|
|
455
|
+
setCopied(true)
|
|
456
|
+
clearTimeout(copiedTimerRef.current)
|
|
457
|
+
copiedTimerRef.current = setTimeout(() => setCopied(false), 1500)
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
const viewToggle = h('div', {
|
|
461
|
+
className: 'dsh-prompt-editor-viewToggle',
|
|
462
|
+
role: 'group',
|
|
463
|
+
'aria-label': text('dialog.view'),
|
|
464
|
+
},
|
|
465
|
+
h('button', {
|
|
466
|
+
type: 'button',
|
|
467
|
+
'aria-pressed': view === 'side' ? 'true' : 'false',
|
|
468
|
+
onClick: () => setView('side'),
|
|
469
|
+
}, text('dialog.viewSide')),
|
|
470
|
+
h('button', {
|
|
471
|
+
type: 'button',
|
|
472
|
+
'aria-pressed': view === 'diff' ? 'true' : 'false',
|
|
473
|
+
onClick: () => setView('diff'),
|
|
474
|
+
}, text('dialog.viewDiff')))
|
|
475
|
+
|
|
476
|
+
const loadingPane = h('div', { className: 'dsh-prompt-editor-loading' },
|
|
477
|
+
h('span', { className: 'dsh-prompt-editor-dots' }, text('dialog.loading')))
|
|
478
|
+
|
|
479
|
+
const diffPane = h('section', { className: 'dsh-prompt-editor-pane dsh-prompt-editor-diffPane' },
|
|
480
|
+
h('div', { className: 'dsh-prompt-editor-diffHead' },
|
|
481
|
+
h('h3', { className: 'dsh-prompt-editor-paneTitle' }, text('dialog.diffTitle')),
|
|
482
|
+
h('span', { className: 'dsh-prompt-editor-diffLegend' }, text('dialog.diffLegend'))),
|
|
483
|
+
state.loading && enhanced === ''
|
|
484
|
+
? loadingPane
|
|
485
|
+
: state.error !== null && result === null && enhanced === ''
|
|
486
|
+
? h('pre', { className: 'dsh-prompt-editor-pre', tabIndex: 0 }, text('dialog.failed'))
|
|
487
|
+
: enhanced === '' && stopped
|
|
488
|
+
? h('pre', { className: 'dsh-prompt-editor-pre', tabIndex: 0 }, text('dialog.failed'))
|
|
489
|
+
: h(InlineDiff, { before: state.source, after: enhanced }))
|
|
490
|
+
|
|
491
|
+
const sidePanes = [
|
|
492
|
+
h('section', { key: 'original', className: 'dsh-prompt-editor-pane' },
|
|
493
|
+
h('h3', { className: 'dsh-prompt-editor-paneTitle' }, text('dialog.original')),
|
|
494
|
+
h('pre', { className: 'dsh-prompt-editor-pre', tabIndex: 0 }, state.source)),
|
|
495
|
+
h('section', { key: 'enhanced', className: 'dsh-prompt-editor-pane' },
|
|
496
|
+
h('h3', { className: 'dsh-prompt-editor-paneTitle' }, text('dialog.enhanced')),
|
|
497
|
+
state.loading && enhanced === ''
|
|
498
|
+
? loadingPane
|
|
499
|
+
: h('pre', { className: 'dsh-prompt-editor-pre', tabIndex: 0 },
|
|
500
|
+
enhanced !== ''
|
|
501
|
+
? enhanced
|
|
502
|
+
: state.error !== null
|
|
503
|
+
? text('dialog.failed')
|
|
504
|
+
: stopped
|
|
505
|
+
? text('dialog.failed')
|
|
506
|
+
: (unchanged ? text('dialog.unchanged') : text('dialog.loading')))),
|
|
507
|
+
]
|
|
508
|
+
|
|
323
509
|
const dialog = h('div', {
|
|
324
510
|
className: 'dsh-prompt-editor-overlay',
|
|
325
511
|
role: 'presentation',
|
|
@@ -359,6 +545,7 @@ window.__ModuleLoader__.load({
|
|
|
359
545
|
? text('dialog.selection', { count: state.source.length })
|
|
360
546
|
: text('dialog.whole'))),
|
|
361
547
|
h('div', { className: 'dsh-prompt-editor-headActions' },
|
|
548
|
+
viewToggle,
|
|
362
549
|
h('label', { className: 'dsh-prompt-editor-modeLabel' },
|
|
363
550
|
text('dialog.mode'),
|
|
364
551
|
h('select', {
|
|
@@ -378,20 +565,7 @@ window.__ModuleLoader__.load({
|
|
|
378
565
|
onClick: onClose,
|
|
379
566
|
}, '×'))),
|
|
380
567
|
h('div', { className: 'dsh-prompt-editor-body' },
|
|
381
|
-
|
|
382
|
-
h('h3', { className: 'dsh-prompt-editor-paneTitle' }, text('dialog.original')),
|
|
383
|
-
h('pre', { className: 'dsh-prompt-editor-pre', tabIndex: 0 }, state.source)),
|
|
384
|
-
h('section', { className: 'dsh-prompt-editor-pane' },
|
|
385
|
-
h('h3', { className: 'dsh-prompt-editor-paneTitle' }, text('dialog.enhanced')),
|
|
386
|
-
state.loading && enhanced === ''
|
|
387
|
-
? h('div', { className: 'dsh-prompt-editor-loading' },
|
|
388
|
-
h('span', { className: 'dsh-prompt-editor-dots' }, text('dialog.loading')))
|
|
389
|
-
: h('pre', { className: 'dsh-prompt-editor-pre', tabIndex: 0 },
|
|
390
|
-
enhanced !== ''
|
|
391
|
-
? enhanced
|
|
392
|
-
: state.error !== null
|
|
393
|
-
? text('dialog.failed')
|
|
394
|
-
: (unchanged ? text('dialog.unchanged') : text('dialog.loading'))))),
|
|
568
|
+
view === 'diff' ? diffPane : sidePanes),
|
|
395
569
|
result?.warnings?.length > 0
|
|
396
570
|
? h('div', { className: 'dsh-prompt-editor-warnings' },
|
|
397
571
|
h('p', { className: 'dsh-prompt-editor-warningsTitle' }, text('dialog.warnings')),
|
|
@@ -414,9 +588,22 @@ window.__ModuleLoader__.load({
|
|
|
414
588
|
h('button', {
|
|
415
589
|
type: 'button',
|
|
416
590
|
className: 'dsh-prompt-editor-btn',
|
|
417
|
-
disabled:
|
|
418
|
-
onClick:
|
|
419
|
-
}, text('dialog.
|
|
591
|
+
disabled: !canCopy,
|
|
592
|
+
onClick: () => { void copy() },
|
|
593
|
+
}, copied ? text('dialog.copied') : text('dialog.copy')),
|
|
594
|
+
state.loading
|
|
595
|
+
? h('button', {
|
|
596
|
+
ref: stopRef,
|
|
597
|
+
type: 'button',
|
|
598
|
+
className: 'dsh-prompt-editor-btn',
|
|
599
|
+
onClick: onStop,
|
|
600
|
+
}, text('dialog.stop'))
|
|
601
|
+
: h('button', {
|
|
602
|
+
type: 'button',
|
|
603
|
+
className: 'dsh-prompt-editor-btn',
|
|
604
|
+
disabled: state.retryable === false,
|
|
605
|
+
onClick: onRetry,
|
|
606
|
+
}, text('dialog.retry')),
|
|
420
607
|
h('button', {
|
|
421
608
|
ref: acceptRef,
|
|
422
609
|
type: 'button',
|
|
@@ -438,7 +625,10 @@ window.__ModuleLoader__.load({
|
|
|
438
625
|
|
|
439
626
|
const [open, setOpen] = useState(false)
|
|
440
627
|
const [state, setState] = useState(null)
|
|
628
|
+
const [defaultMode, setDefaultMode] = useState('intent-first')
|
|
629
|
+
const [undo, setUndo] = useState(null)
|
|
441
630
|
const abortRef = useRef(null)
|
|
631
|
+
const undoTimerRef = useRef(null)
|
|
442
632
|
const mountedRef = useRef(true)
|
|
443
633
|
const triggerRef = useRef(null)
|
|
444
634
|
const selectionCacheRef = useRef(null)
|
|
@@ -446,6 +636,26 @@ window.__ModuleLoader__.load({
|
|
|
446
636
|
useEffect(() => () => {
|
|
447
637
|
mountedRef.current = false
|
|
448
638
|
abortRef.current?.abort()
|
|
639
|
+
clearTimeout(undoTimerRef.current)
|
|
640
|
+
}, [])
|
|
641
|
+
|
|
642
|
+
useEffect(() => {
|
|
643
|
+
let cancelled = false
|
|
644
|
+
fetch('/api/prompt-editor/settings', { credentials: 'same-origin' })
|
|
645
|
+
.then((response) => response.ok ? response.json() : null)
|
|
646
|
+
.then((body) => {
|
|
647
|
+
if (cancelled || body?.ok !== true) return
|
|
648
|
+
if (MODES.includes(body.values?.defaultMode)) setDefaultMode(body.values.defaultMode)
|
|
649
|
+
})
|
|
650
|
+
.catch(() => {})
|
|
651
|
+
const onMode = (event) => {
|
|
652
|
+
if (MODES.includes(event?.detail)) setDefaultMode(event.detail)
|
|
653
|
+
}
|
|
654
|
+
window.addEventListener('dsh-prompt-editor:mode', onMode)
|
|
655
|
+
return () => {
|
|
656
|
+
cancelled = true
|
|
657
|
+
window.removeEventListener('dsh-prompt-editor:mode', onMode)
|
|
658
|
+
}
|
|
449
659
|
}, [])
|
|
450
660
|
|
|
451
661
|
const close = useCallback(() => {
|
|
@@ -472,7 +682,7 @@ window.__ModuleLoader__.load({
|
|
|
472
682
|
abortRef.current?.abort()
|
|
473
683
|
const controller = new AbortController()
|
|
474
684
|
abortRef.current = controller
|
|
475
|
-
setState({ source, span, selected, mode, context, raw: '', result: null, error: null, loading: true, retryable: true })
|
|
685
|
+
setState({ source, span, selected, mode, context, raw: '', result: null, error: null, loading: true, retryable: true, stopped: false })
|
|
476
686
|
let sawDone = false
|
|
477
687
|
|
|
478
688
|
try {
|
|
@@ -506,10 +716,10 @@ window.__ModuleLoader__.load({
|
|
|
506
716
|
}
|
|
507
717
|
if (event.type === 'reset') return { ...previous, raw: '' }
|
|
508
718
|
if (event.type === 'done') {
|
|
509
|
-
return { ...previous, result: event, raw: event.prompt ?? previous.raw, error: null, loading: false }
|
|
719
|
+
return { ...previous, result: event, raw: event.prompt ?? previous.raw, error: null, loading: false, stopped: false }
|
|
510
720
|
}
|
|
511
721
|
if (event.type === 'error') {
|
|
512
|
-
return { ...previous, error: typeof event.message === 'string' ? event.message : 'unknown error', loading: false }
|
|
722
|
+
return { ...previous, error: typeof event.message === 'string' ? event.message : 'unknown error', loading: false, stopped: false }
|
|
513
723
|
}
|
|
514
724
|
return previous
|
|
515
725
|
})
|
|
@@ -545,7 +755,7 @@ window.__ModuleLoader__.load({
|
|
|
545
755
|
const selected = span.end > span.start
|
|
546
756
|
const segments = draftSegments(draft, occurrences)
|
|
547
757
|
const hasChips = segments.some((segment) => segment.kind === 'chip')
|
|
548
|
-
const mode =
|
|
758
|
+
const mode = defaultMode
|
|
549
759
|
if (hasChips && !selected) {
|
|
550
760
|
setOpen(true)
|
|
551
761
|
setState({
|
|
@@ -575,7 +785,7 @@ window.__ModuleLoader__.load({
|
|
|
575
785
|
if (source.trim() === '') return
|
|
576
786
|
setOpen(true)
|
|
577
787
|
run(source, span, selected, mode, hasChips ? draft : undefined)
|
|
578
|
-
}, [draft, draftRev, inputActions, occurrences, run, text])
|
|
788
|
+
}, [draft, draftRev, defaultMode, inputActions, occurrences, run, text])
|
|
579
789
|
|
|
580
790
|
useEffect(() => {
|
|
581
791
|
if (inputActions === undefined || typeof inputActions.captureInsertion !== 'function') return undefined
|
|
@@ -640,10 +850,66 @@ window.__ModuleLoader__.load({
|
|
|
640
850
|
} catch {
|
|
641
851
|
accepted = false
|
|
642
852
|
}
|
|
643
|
-
if (accepted)
|
|
644
|
-
|
|
853
|
+
if (accepted) {
|
|
854
|
+
let rev
|
|
855
|
+
try {
|
|
856
|
+
rev = inputActions.captureInsertion()?.draftRev
|
|
857
|
+
} catch {
|
|
858
|
+
rev = undefined
|
|
859
|
+
}
|
|
860
|
+
if (Number.isFinite(rev)) {
|
|
861
|
+
clearTimeout(undoTimerRef.current)
|
|
862
|
+
setUndo({
|
|
863
|
+
source: state.source,
|
|
864
|
+
start: span.start,
|
|
865
|
+
length: state.result.prompt.length,
|
|
866
|
+
draftRev: rev,
|
|
867
|
+
})
|
|
868
|
+
undoTimerRef.current = setTimeout(() => setUndo(null), 8000)
|
|
869
|
+
}
|
|
870
|
+
close()
|
|
871
|
+
} else {
|
|
872
|
+
setState((previous) => previous === null ? previous : { ...previous, error: text('dialog.stale') })
|
|
873
|
+
}
|
|
645
874
|
}, [close, inputActions, state, text])
|
|
646
875
|
|
|
876
|
+
const stop = useCallback(() => {
|
|
877
|
+
abortRef.current?.abort()
|
|
878
|
+
abortRef.current = null
|
|
879
|
+
setState((previous) => previous === null ? previous : {
|
|
880
|
+
...previous,
|
|
881
|
+
loading: false,
|
|
882
|
+
stopped: true,
|
|
883
|
+
error: null,
|
|
884
|
+
retryable: true,
|
|
885
|
+
})
|
|
886
|
+
}, [])
|
|
887
|
+
|
|
888
|
+
const undoReplace = useCallback(() => {
|
|
889
|
+
if (undo === null || inputActions === undefined) return
|
|
890
|
+
let current
|
|
891
|
+
try {
|
|
892
|
+
current = inputActions.captureInsertion()
|
|
893
|
+
} catch {
|
|
894
|
+
return
|
|
895
|
+
}
|
|
896
|
+
clearTimeout(undoTimerRef.current)
|
|
897
|
+
if (current === null || current === undefined || current.draftRev !== undo.draftRev) {
|
|
898
|
+
setUndo(null)
|
|
899
|
+
return
|
|
900
|
+
}
|
|
901
|
+
try {
|
|
902
|
+
inputActions.insertText(undo.source, {
|
|
903
|
+
start: undo.start,
|
|
904
|
+
end: undo.start + undo.length,
|
|
905
|
+
draftRev: current.draftRev,
|
|
906
|
+
})
|
|
907
|
+
} catch {
|
|
908
|
+
// Keep the composer unchanged when the undo span cannot be replaced.
|
|
909
|
+
}
|
|
910
|
+
setUndo(null)
|
|
911
|
+
}, [inputActions, undo])
|
|
912
|
+
|
|
647
913
|
const retry = useCallback(() => {
|
|
648
914
|
if (state === null || state.retryable === false) return
|
|
649
915
|
run(state.source, state.span, state.selected, state.mode, state.context)
|
|
@@ -677,12 +943,28 @@ window.__ModuleLoader__.load({
|
|
|
677
943
|
onMouseDown: (event) => event.preventDefault(),
|
|
678
944
|
onClick: () => openDialog(),
|
|
679
945
|
}, ICON, h('span', null, text('button.label'))),
|
|
946
|
+
undo !== null
|
|
947
|
+
? h('div', { className: 'dsh-prompt-editor-undoToast', role: 'status' },
|
|
948
|
+
h('span', null, text('undo.done')),
|
|
949
|
+
h('button', { type: 'button', onClick: undoReplace }, text('undo.action')),
|
|
950
|
+
h('button', {
|
|
951
|
+
type: 'button',
|
|
952
|
+
className: 'dsh-prompt-editor-iconBtn',
|
|
953
|
+
'aria-label': text('undo.close'),
|
|
954
|
+
title: text('undo.close'),
|
|
955
|
+
onClick: () => {
|
|
956
|
+
clearTimeout(undoTimerRef.current)
|
|
957
|
+
setUndo(null)
|
|
958
|
+
},
|
|
959
|
+
}, '×'))
|
|
960
|
+
: null,
|
|
680
961
|
open && state !== null
|
|
681
962
|
? h(PreviewDialog, {
|
|
682
963
|
state,
|
|
683
964
|
text,
|
|
684
965
|
onClose: close,
|
|
685
966
|
onAccept: accept,
|
|
967
|
+
onStop: stop,
|
|
686
968
|
onRetry: retry,
|
|
687
969
|
onMode: changeMode,
|
|
688
970
|
})
|
|
@@ -691,8 +973,17 @@ window.__ModuleLoader__.load({
|
|
|
691
973
|
|
|
692
974
|
function SettingsPage(props) {
|
|
693
975
|
const text = useMemo(() => makeText(props.t), [props.t])
|
|
694
|
-
const [
|
|
695
|
-
const [
|
|
976
|
+
const [values, setValues] = useState(null)
|
|
977
|
+
const [catalog, setCatalog] = useState({ status: 'loading', groups: [] })
|
|
978
|
+
const [error, setError] = useState(null)
|
|
979
|
+
const [saving, setSaving] = useState(false)
|
|
980
|
+
|
|
981
|
+
const normalize = (raw) => ({
|
|
982
|
+
defaultMode: MODES.includes(raw?.defaultMode) ? raw.defaultMode : 'intent-first',
|
|
983
|
+
useCustomModel: raw?.useCustomModel === true,
|
|
984
|
+
enhanceProvider: typeof raw?.enhanceProvider === 'string' ? raw.enhanceProvider : '',
|
|
985
|
+
enhanceModel: typeof raw?.enhanceModel === 'string' ? raw.enhanceModel : '',
|
|
986
|
+
})
|
|
696
987
|
|
|
697
988
|
useEffect(() => {
|
|
698
989
|
let cancelled = false
|
|
@@ -700,7 +991,7 @@ window.__ModuleLoader__.load({
|
|
|
700
991
|
.then((response) => response.ok ? response.json() : null)
|
|
701
992
|
.then((body) => {
|
|
702
993
|
if (cancelled || body?.ok !== true) return
|
|
703
|
-
|
|
994
|
+
setValues(normalize(body.values))
|
|
704
995
|
})
|
|
705
996
|
.catch(() => {})
|
|
706
997
|
return () => {
|
|
@@ -708,12 +999,94 @@ window.__ModuleLoader__.load({
|
|
|
708
999
|
}
|
|
709
1000
|
}, [])
|
|
710
1001
|
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
1002
|
+
useEffect(() => {
|
|
1003
|
+
let cancelled = false
|
|
1004
|
+
const getRemote = props.getRemote
|
|
1005
|
+
const remote = typeof getRemote === 'function' ? getRemote() : undefined
|
|
1006
|
+
if (remote === undefined || remote === null || typeof remote.modelCatalog !== 'function') {
|
|
1007
|
+
setCatalog({ status: 'error', groups: [] })
|
|
1008
|
+
return undefined
|
|
1009
|
+
}
|
|
1010
|
+
Promise.resolve(remote.modelCatalog())
|
|
1011
|
+
.then((response) => {
|
|
1012
|
+
if (cancelled) return
|
|
1013
|
+
if (response?.ok !== true) throw new Error(response?.error?.message ?? 'catalog unavailable')
|
|
1014
|
+
const groups = (response.value?.groups ?? []).map((group) => ({
|
|
1015
|
+
id: group.id,
|
|
1016
|
+
label: group.name ?? group.label ?? group.id,
|
|
1017
|
+
models: (group.models ?? []).map((model) => ({ id: model.id, name: model.name ?? model.id })),
|
|
1018
|
+
}))
|
|
1019
|
+
setCatalog({ status: 'ready', groups })
|
|
1020
|
+
})
|
|
1021
|
+
.catch(() => {
|
|
1022
|
+
if (!cancelled) setCatalog({ status: 'error', groups: [] })
|
|
1023
|
+
})
|
|
1024
|
+
return () => {
|
|
1025
|
+
cancelled = true
|
|
1026
|
+
}
|
|
1027
|
+
}, [props.getRemote])
|
|
1028
|
+
|
|
1029
|
+
const save = async (patch) => {
|
|
1030
|
+
if (saving) return
|
|
1031
|
+
setSaving(true)
|
|
1032
|
+
setError(null)
|
|
1033
|
+
try {
|
|
1034
|
+
const response = await fetch('/api/prompt-editor/settings', {
|
|
1035
|
+
method: 'POST',
|
|
1036
|
+
credentials: 'same-origin',
|
|
1037
|
+
headers: { 'content-type': 'application/json' },
|
|
1038
|
+
body: JSON.stringify(patch),
|
|
1039
|
+
})
|
|
1040
|
+
let body = null
|
|
1041
|
+
try {
|
|
1042
|
+
body = await response.json()
|
|
1043
|
+
} catch {
|
|
1044
|
+
body = null
|
|
1045
|
+
}
|
|
1046
|
+
if (!response.ok || body?.ok !== true) {
|
|
1047
|
+
throw new Error(body?.error || `HTTP ${response.status}`)
|
|
1048
|
+
}
|
|
1049
|
+
const next = normalize(body.values)
|
|
1050
|
+
setValues(next)
|
|
1051
|
+
if (patch.defaultMode !== undefined) {
|
|
1052
|
+
window.dispatchEvent(new CustomEvent('dsh-prompt-editor:mode', { detail: next.defaultMode }))
|
|
1053
|
+
}
|
|
1054
|
+
} catch (failure) {
|
|
1055
|
+
setError(failure instanceof Error ? failure.message : String(failure))
|
|
1056
|
+
} finally {
|
|
1057
|
+
setSaving(false)
|
|
1058
|
+
}
|
|
715
1059
|
}
|
|
716
1060
|
|
|
1061
|
+
const mode = values?.defaultMode ?? 'intent-first'
|
|
1062
|
+
const useCustomModel = values?.useCustomModel === true
|
|
1063
|
+
const storedModelValue = values?.enhanceProvider && values?.enhanceModel
|
|
1064
|
+
? `${values.enhanceProvider}\u0000${values.enhanceModel}`
|
|
1065
|
+
: ''
|
|
1066
|
+
const modelValue = useCustomModel ? storedModelValue : ''
|
|
1067
|
+
const savedModelName = (() => {
|
|
1068
|
+
if (!values?.enhanceProvider || !values?.enhanceModel) return ''
|
|
1069
|
+
const group = catalog.groups.find((item) => item.id === values.enhanceProvider)
|
|
1070
|
+
const found = group?.models.find((item) => item.id === values.enhanceModel)
|
|
1071
|
+
return found !== undefined
|
|
1072
|
+
? `${group.label} / ${found.name}`
|
|
1073
|
+
: `${values.enhanceProvider} / ${values.enhanceModel}`
|
|
1074
|
+
})()
|
|
1075
|
+
const modelOptions = [
|
|
1076
|
+
h('option', { key: '', value: '' }, catalog.status === 'loading'
|
|
1077
|
+
? text('settings.modelLoading')
|
|
1078
|
+
: catalog.status === 'error'
|
|
1079
|
+
? text('settings.modelLoadError')
|
|
1080
|
+
: useCustomModel ? text('settings.modelChoose') : text('settings.modelPlaceholder')),
|
|
1081
|
+
...catalog.groups.flatMap((group) => group.models.length === 0
|
|
1082
|
+
? []
|
|
1083
|
+
: [h('optgroup', { key: group.id, label: group.label },
|
|
1084
|
+
...group.models.map((model) => h('option', {
|
|
1085
|
+
key: `${group.id}/${model.id}`,
|
|
1086
|
+
value: `${group.id}\u0000${model.id}`,
|
|
1087
|
+
}, model.name)))]),
|
|
1088
|
+
]
|
|
1089
|
+
|
|
717
1090
|
return h('div', { className: 'dsh-prompt-editor-settings' },
|
|
718
1091
|
h('style', {}, CSS),
|
|
719
1092
|
h('h2', null, text('settings.title')),
|
|
@@ -725,22 +1098,62 @@ window.__ModuleLoader__.load({
|
|
|
725
1098
|
h('select', {
|
|
726
1099
|
className: 'dsh-prompt-editor-select',
|
|
727
1100
|
value: mode,
|
|
1101
|
+
disabled: saving || values === null,
|
|
728
1102
|
'aria-label': text('settings.mode'),
|
|
729
|
-
onChange: (event) =>
|
|
1103
|
+
onChange: (event) => save({ defaultMode: event.target.value }),
|
|
730
1104
|
},
|
|
731
1105
|
h('option', { value: 'intent-first' }, text('mode.intent-first')),
|
|
732
1106
|
h('option', { value: 'strict' }, text('mode.strict')))),
|
|
733
|
-
|
|
1107
|
+
h('div', { className: 'dsh-prompt-editor-settingsRow' },
|
|
1108
|
+
h('div', { className: 'dsh-prompt-editor-settingsCopy' },
|
|
1109
|
+
h('span', { className: 'dsh-prompt-editor-settingsTitle' }, text('settings.modelTitle')),
|
|
1110
|
+
h('p', { className: 'dsh-prompt-editor-settingsHint' }, text('settings.modelHint')),
|
|
1111
|
+
h('label', { className: 'dsh-prompt-editor-toggle' },
|
|
1112
|
+
h('input', {
|
|
1113
|
+
type: 'checkbox',
|
|
1114
|
+
className: 'dsh-prompt-editor-checkbox',
|
|
1115
|
+
checked: useCustomModel,
|
|
1116
|
+
disabled: saving || values === null,
|
|
1117
|
+
onChange: (event) => save({ useCustomModel: event.target.checked }),
|
|
1118
|
+
}),
|
|
1119
|
+
text('settings.useCustomModel')),
|
|
1120
|
+
!useCustomModel && savedModelName !== ''
|
|
1121
|
+
? h('p', { className: 'dsh-prompt-editor-savedModel' }, text('settings.savedModel', { model: savedModelName }))
|
|
1122
|
+
: null),
|
|
1123
|
+
h('div', { className: 'dsh-prompt-editor-settingsControl' },
|
|
1124
|
+
h('select', {
|
|
1125
|
+
className: 'dsh-prompt-editor-select dsh-prompt-editor-settingsModel',
|
|
1126
|
+
value: modelValue,
|
|
1127
|
+
disabled: saving || values === null || !useCustomModel || catalog.status !== 'ready',
|
|
1128
|
+
'aria-label': text('settings.modelTitle'),
|
|
1129
|
+
onChange: (event) => {
|
|
1130
|
+
const raw = event.target.value
|
|
1131
|
+
if (raw === '') {
|
|
1132
|
+
save({ enhanceProvider: '', enhanceModel: '' })
|
|
1133
|
+
return
|
|
1134
|
+
}
|
|
1135
|
+
const [provider, model] = raw.split('\u0000')
|
|
1136
|
+
save({ enhanceProvider: provider, enhanceModel: model })
|
|
1137
|
+
},
|
|
1138
|
+
}, modelOptions))),
|
|
1139
|
+
values !== null
|
|
734
1140
|
? h('p', null, text('settings.profileDefault', {
|
|
735
|
-
mode:
|
|
1141
|
+
mode: values.defaultMode === 'strict' ? text('mode.strict') : text('mode.intent-first'),
|
|
736
1142
|
}))
|
|
737
1143
|
: null,
|
|
738
|
-
h('p', null, text('settings.
|
|
1144
|
+
h('p', null, text('settings.persisted')),
|
|
1145
|
+
saving ? h('p', { role: 'status' }, text('settings.saving')) : null,
|
|
1146
|
+
error !== null
|
|
1147
|
+
? h('p', { role: 'alert', className: 'dsh-prompt-editor-error' }, text('settings.saveError', { message: error }))
|
|
1148
|
+
: null)
|
|
739
1149
|
}
|
|
740
1150
|
|
|
741
1151
|
return {
|
|
742
|
-
inject: ['slots'],
|
|
1152
|
+
inject: ['slots', 'remote', 'remote.session'],
|
|
743
1153
|
apply(ctx) {
|
|
1154
|
+
const getSessionRemote = () => ctx.remote.session
|
|
1155
|
+
const Settings = (props) => h(SettingsPage, { ...props, getRemote: getSessionRemote })
|
|
1156
|
+
|
|
744
1157
|
ctx.slots.inject('conversation.input.right', () => ctx.slots.register({
|
|
745
1158
|
name: 'conversation.input.right',
|
|
746
1159
|
id: 'prompt-editor',
|
|
@@ -754,7 +1167,7 @@ window.__ModuleLoader__.load({
|
|
|
754
1167
|
order: 60,
|
|
755
1168
|
locale: NS,
|
|
756
1169
|
label: () => FALLBACK['settings.nav'],
|
|
757
|
-
},
|
|
1170
|
+
}, Settings))
|
|
758
1171
|
},
|
|
759
1172
|
}
|
|
760
1173
|
},
|