@lincyaw/workbench 0.2.0-rc.12 → 0.2.0-rc.14
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/package.json +4 -4
- package/src/messages.ts +4 -2
- package/src/panels/DocumentView.tsx +9 -7
- package/src/styles.css +14 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lincyaw/workbench",
|
|
3
|
-
"version": "0.2.0-rc.
|
|
3
|
+
"version": "0.2.0-rc.14",
|
|
4
4
|
"description": "Presmium's workbench panels in React (the documents, a document edited on its rendered page with comments and version history) with the workspace service's client and the preview protocol's workbench side; @lincyaw/dsh places them in presmium studio (experimental)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"@tiptap/pm": "3.32.0",
|
|
55
55
|
"katex": "0.18.10",
|
|
56
56
|
"react-resizable-panels": "4.14.5",
|
|
57
|
-
"@lincyaw/
|
|
58
|
-
"@lincyaw/
|
|
57
|
+
"@lincyaw/design": "1.0.0-rc.15",
|
|
58
|
+
"@lincyaw/kernel": "1.0.0-rc.15"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"react": "^18.3.1",
|
|
@@ -66,6 +66,6 @@
|
|
|
66
66
|
"@types/react-dom": "18.3.7",
|
|
67
67
|
"react": "^18.3.1",
|
|
68
68
|
"react-dom": "^18.3.1",
|
|
69
|
-
"@lincyaw/compiler": "1.0.0-rc.
|
|
69
|
+
"@lincyaw/compiler": "1.0.0-rc.15"
|
|
70
70
|
}
|
|
71
71
|
}
|
package/src/messages.ts
CHANGED
|
@@ -329,7 +329,8 @@ const zh = {
|
|
|
329
329
|
agentWaiting: (n: number) => `AI 修改了 ${n} 处内容,要接受这些修改吗?`,
|
|
330
330
|
accept: '接受',
|
|
331
331
|
reject: '拒绝',
|
|
332
|
-
problems: (n: number) =>
|
|
332
|
+
problems: (n: number) => `文稿有 ${n} 个问题需要处理。`,
|
|
333
|
+
problemsTitle: '文稿中的问题',
|
|
333
334
|
fixWithAi: '用 AI 修复',
|
|
334
335
|
fixing: '正在发送给 AI…',
|
|
335
336
|
fixFailed: (reason: string) => `无法发送给 AI。${reason}`,
|
|
@@ -693,7 +694,8 @@ const en: WorkbenchMessages = {
|
|
|
693
694
|
agentWaiting: (n: number) => `The AI changed ${n} file${n === 1 ? '' : 's'}. Accept the changes?`,
|
|
694
695
|
accept: 'Accept',
|
|
695
696
|
reject: 'Reject',
|
|
696
|
-
problems: (n: number) =>
|
|
697
|
+
problems: (n: number) => `The document has ${n} problem${n === 1 ? '' : 's'} to fix.`,
|
|
698
|
+
problemsTitle: 'Problems in the Document',
|
|
697
699
|
fixWithAi: 'Fix with AI',
|
|
698
700
|
fixing: 'Sending to the AI…',
|
|
699
701
|
fixFailed: (reason: string) => `Couldn’t send to the AI. ${reason}`,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react'
|
|
2
2
|
import type { ReactNode, RefObject } from 'react'
|
|
3
|
-
import { PmButton, PmIconButton, PmMascot, PmMenu, PmNotice, PmSkeleton, PmSortableList, PmToolbar, PmToolbarButton } from '../components.tsx'
|
|
3
|
+
import { PmButton, PmDialog, PmIconButton, PmMascot, PmMenu, PmNotice, PmSkeleton, PmSortableList, PmToolbar, PmToolbarButton } from '../components.tsx'
|
|
4
4
|
import { useMessages, useWorkbench, useWorkbenchState } from '../context.tsx'
|
|
5
5
|
import { failureReason, timeAgo } from '../messages.ts'
|
|
6
6
|
import { SHORTCUTS } from '../shortcuts.ts'
|
|
@@ -431,7 +431,7 @@ function DocumentNotices() {
|
|
|
431
431
|
)
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
-
/**
|
|
434
|
+
/** The document's problems in one line above the page, with the AI to fix them; the list itself opens in a dialog. */
|
|
435
435
|
function ProblemsNotice() {
|
|
436
436
|
const t = useMessages()
|
|
437
437
|
const workbench = useWorkbench()
|
|
@@ -440,23 +440,25 @@ function ProblemsNotice() {
|
|
|
440
440
|
const canRepair = useWorkbenchState(state => state.canRepairDiagnostics)
|
|
441
441
|
const repairing = useWorkbenchState(state => state.isRepairingDiagnostics)
|
|
442
442
|
const repairFailure = useWorkbenchState(state => state.diagnosticsRepairFailure)
|
|
443
|
+
const [open, setOpen] = useState(false)
|
|
443
444
|
if (workbench.client.capabilities?.diagnostics === 'none') return null
|
|
444
445
|
const problems = (snapshot?.diagnostics ?? []).filter(diagnostic => diagnostic.severity === 'error' && !diagnostic.checkId.startsWith('presmium.workbench.'))
|
|
445
446
|
if (unavailable) return <PmNotice tone="warn"><span>{t.diagnosticsUnavailable}</span><PmButton small onClick={() => workbench.retryDiagnostics()}>{t.retry}</PmButton></PmNotice>
|
|
446
447
|
if (problems.length === 0) return repairFailure ? <PmNotice tone="danger">{t.fixFailed(failureReason(t, repairFailure))}</PmNotice> : null
|
|
448
|
+
const repair = canRepair && <PmButton small variant="accent" icon="sparkle" disabled={repairing} onClick={() => void workbench.requestRepairDiagnostics()}>{repairing ? t.fixing : t.fixWithAi}</PmButton>
|
|
447
449
|
return (
|
|
448
450
|
<PmNotice tone="warn">
|
|
449
451
|
<div className="pmw-problems">
|
|
450
452
|
<div className="pmw-problems__summary">
|
|
451
453
|
<span>{t.problems(problems.length)}</span>
|
|
452
|
-
|
|
454
|
+
<PmButton small variant="ghost" onClick={() => setOpen(true)}>{t.details}</PmButton>
|
|
455
|
+
{repair}
|
|
453
456
|
</div>
|
|
454
457
|
{repairFailure && <p className="pmw-problems__failure">{t.fixFailed(failureReason(t, repairFailure))}</p>}
|
|
455
|
-
<details className="pmw-problems__details">
|
|
456
|
-
<summary>{t.details}</summary>
|
|
457
|
-
<ul>{problems.map(problem => <li key={problem.id}>{problem.message}</li>)}</ul>
|
|
458
|
-
</details>
|
|
459
458
|
</div>
|
|
459
|
+
<PmDialog open={open} label={t.problemsTitle} closeLabel={t.close} actions={repair || undefined} onClose={() => setOpen(false)}>
|
|
460
|
+
<ul className="pmw-problems__list">{problems.map(problem => <li key={problem.id}><p>{problem.message}</p>{problem.hint && <p className="pmw-problems__hint">{problem.hint}</p>}</li>)}</ul>
|
|
461
|
+
</PmDialog>
|
|
460
462
|
</PmNotice>
|
|
461
463
|
)
|
|
462
464
|
}
|
package/src/styles.css
CHANGED
|
@@ -265,20 +265,24 @@
|
|
|
265
265
|
color: var(--pm-color-danger);
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
-
.pmw-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
.pmw-problems__details ul {
|
|
275
|
-
margin: var(--pm-space-1) 0 0;
|
|
268
|
+
.pmw-problems__list {
|
|
269
|
+
display: flex;
|
|
270
|
+
flex-direction: column;
|
|
271
|
+
gap: var(--pm-space-3);
|
|
272
|
+
margin: 0;
|
|
276
273
|
padding-left: var(--pm-space-4);
|
|
277
|
-
font-family: var(--pm-font-mono);
|
|
278
|
-
font-size: var(--pm-text-xs);
|
|
279
274
|
overflow-wrap: anywhere;
|
|
280
275
|
}
|
|
281
276
|
|
|
277
|
+
.pmw-problems__list p {
|
|
278
|
+
margin: 0;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.pmw-problems__hint {
|
|
282
|
+
color: var(--pm-color-muted);
|
|
283
|
+
font-size: var(--pm-text-sm);
|
|
284
|
+
}
|
|
285
|
+
|
|
282
286
|
.pmw-document__body {
|
|
283
287
|
display: flex;
|
|
284
288
|
flex: 1;
|