@lemonriver/core 1.3.0 → 1.4.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/dist/{build-CSkdswfd.js → build-Cv0nNc4G.js} +1 -1
- package/dist/cli/bin.js +5 -5
- package/dist/{config-C5-myPY6.js → config-Di9kipre.js} +2773 -714
- package/dist/{config-CYNOR93W.d.ts → config-f1SqAhtR.d.ts} +1 -1
- package/dist/{dev-DHtYH8sw.js → dev-Az1UzCQp.js} +11 -11
- package/dist/index.d.ts +2 -2
- package/dist/index.js +21 -2
- package/dist/locale/index.d.ts +1 -1
- package/dist/locale/index.js +1 -1
- package/dist/{mcp-B2UeO1un.js → mcp-CW7H6oUg.js} +1 -1
- package/dist/{preview-C1B6-umF.js → preview-DtSq5uN1.js} +1 -1
- package/dist/{types-tdaXSyah.d.ts → types-C4VfD89E.d.ts} +12 -0
- package/dist/{update-DzL8fpcI.js → update-DVe2kQA7.js} +86 -13
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +1 -1
- package/dist/{zh-tw-BhYyMx0-.js → zh-tw-BX3oQAc2.js} +110 -0
- package/package.json +5 -6
- package/release-notes.json +20 -0
- package/src/agent/types.ts +9 -2
- package/src/app/app.tsx +2 -0
- package/src/app/components/agent/agent-panel.tsx +12 -3
- package/src/app/components/agent/agent-presence.tsx +1 -1
- package/src/app/components/command/home-command-menu.tsx +4 -1
- package/src/app/components/command/slide-command-menu.tsx +4 -1
- package/src/app/components/export-progress-toast.tsx +3 -1
- package/src/app/components/inspector/asset-picker-dialog.tsx +1 -1
- package/src/app/components/inspector/comment-layer.tsx +3 -3
- package/src/app/components/inspector/inline-text-editor.tsx +1 -12
- package/src/app/components/inspector/inspect-overlay.tsx +9 -1
- package/src/app/components/inspector/inspector-panel.tsx +7 -23
- package/src/app/components/inspector/inspector-provider.tsx +177 -36
- package/src/app/components/inspector/page-panel.tsx +270 -0
- package/src/app/components/language-toggle.tsx +13 -11
- package/src/app/components/overview-grid.tsx +3 -3
- package/src/app/components/panel/editor-sidebar.tsx +43 -8
- package/src/app/components/panel/panel-shell.tsx +9 -5
- package/src/app/components/panel/save-card.tsx +1 -1
- package/src/app/components/sidebar/folder-item.tsx +4 -1
- package/src/app/components/sidebar/sidebar.tsx +11 -8
- package/src/app/components/slide-canvas.tsx +1 -1
- package/src/app/components/style-panel/design-provider.tsx +48 -11
- package/src/app/components/style-panel/use-design.ts +6 -1
- package/src/app/components/theme-toggle.tsx +16 -22
- package/src/app/components/thumbnail-rail.tsx +69 -50
- package/src/app/components/ui/context-menu.tsx +9 -10
- package/src/app/components/ui/dialog.tsx +2 -4
- package/src/app/components/ui/dropdown-menu.tsx +9 -10
- package/src/app/components/ui/popover.tsx +1 -1
- package/src/app/components/ui/select.tsx +2 -2
- package/src/app/components/ui/sonner.tsx +2 -2
- package/src/app/index.html +7 -0
- package/src/app/lemonriver/agent-cli/model.ts +22 -0
- package/src/app/lemonriver/agent-install/model.ts +46 -0
- package/src/app/lemonriver/agent-install/section.tsx +178 -0
- package/src/app/lemonriver/agent-install/use-install.ts +51 -0
- package/src/app/lemonriver/agent-providers/section.tsx +385 -44
- package/src/app/lemonriver/agent-providers/use-providers.ts +50 -3
- package/src/app/lemonriver/backup/places.ts +22 -12
- package/src/app/lemonriver/chrome/sidebar-extras.tsx +1 -1
- package/src/app/lemonriver/feedback/dialog.tsx +1 -2
- package/src/app/lemonriver/feedback/model.ts +0 -5
- package/src/app/lemonriver/guide/clipboard.ts +19 -0
- package/src/app/lemonriver/guide/create-board.tsx +150 -0
- package/src/app/lemonriver/guide/install-board.tsx +208 -0
- package/src/app/lemonriver/guide/more-agents-page.tsx +89 -0
- package/src/app/lemonriver/guide/more-agents.ts +137 -0
- package/src/app/lemonriver/guide/quick-board.tsx +57 -0
- package/src/app/lemonriver/guide/start-board.tsx +38 -0
- package/src/app/lemonriver/guide/start-card.tsx +105 -0
- package/src/app/lemonriver/guide/start.ts +174 -0
- package/src/app/lemonriver/guide/state.ts +5 -21
- package/src/app/lemonriver/help/help-page.tsx +24 -6
- package/src/app/lemonriver/help/model.ts +1 -0
- package/src/app/lemonriver/home/home-page.tsx +12 -6
- package/src/app/lemonriver/home/sorting.ts +45 -0
- package/src/app/lemonriver/home/use-deck-times.ts +1 -2
- package/src/app/lemonriver/i18n/system-locale.ts +39 -0
- package/src/app/lemonriver/routes.tsx +2 -0
- package/src/app/lemonriver/settings/backup-section.tsx +3 -2
- package/src/app/lemonriver/settings/settings-page.tsx +5 -6
- package/src/app/lemonriver/settings/workspace-card.tsx +2 -1
- package/src/app/lemonriver/share/share-dialog.tsx +2 -1
- package/src/app/lemonriver/text/en.ts +592 -453
- package/src/app/lemonriver/text/es.ts +402 -271
- package/src/app/lemonriver/text/ja.ts +403 -274
- package/src/app/lemonriver/text/platform.ts +7 -0
- package/src/app/lemonriver/text/types.ts +118 -1
- package/src/app/lemonriver/text/zh-cn.ts +643 -508
- package/src/app/lemonriver/text/zh-tw.ts +679 -545
- package/src/app/lemonriver/theme/app.css +9 -0
- package/src/app/lemonriver/theme/controls.css +5 -2
- package/src/app/lemonriver/theme/index.css +9 -0
- package/src/app/lemonriver/theme/pages.ts +2 -0
- package/src/app/lemonriver/theme/theme-menu.tsx +10 -11
- package/src/app/lemonriver/update/restart-wait.ts +45 -0
- package/src/app/lemonriver/update/update-prompt.tsx +9 -0
- package/src/app/lib/agent/use-agent.ts +117 -30
- package/src/app/lib/desktop-host.ts +31 -0
- package/src/app/lib/desktop-routes.ts +22 -0
- package/src/app/lib/desktop.ts +106 -0
- package/src/app/lib/export-pdf.ts +15 -7
- package/src/app/lib/inspector/color.ts +51 -0
- package/src/app/lib/inspector/fiber.ts +6 -0
- package/src/app/lib/inspector/use-editor.ts +2 -1
- package/src/app/lib/inspector/use-notes.ts +331 -57
- package/src/app/lib/inspector/use-visual-editor.ts +9 -1
- package/src/app/lib/locale-store.ts +6 -1
- package/src/app/lib/transition.ts +43 -0
- package/src/app/lib/unsaved.ts +155 -0
- package/src/app/routes/home.tsx +1 -1
- package/src/app/routes/slide.tsx +116 -73
- package/src/app/styles.css +39 -1
- package/src/locale/en.ts +19 -0
- package/src/locale/es.ts +19 -0
- package/src/locale/ja.ts +19 -0
- package/src/locale/types.ts +12 -0
- package/src/locale/zh-cn.ts +19 -0
- package/src/locale/zh-tw.ts +19 -0
- package/src/app/lemonriver/guide/guide-prompt.tsx +0 -89
|
@@ -1,25 +1,55 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useState } from 'react';
|
|
2
2
|
import { toast } from 'sonner';
|
|
3
3
|
import { format } from '@/lib/use-locale';
|
|
4
4
|
import { cn } from '@/lib/utils';
|
|
5
5
|
import { ProviderLogo } from '../../components/agent/provider-logo';
|
|
6
|
+
import type { AgentCliId, CliStatus } from '../agent-cli/model';
|
|
6
7
|
import { useLrText } from '../text';
|
|
7
8
|
import { type AgentProviderRow, useAgentProviders } from './use-providers';
|
|
8
9
|
|
|
9
10
|
export function AgentProvidersSection() {
|
|
10
|
-
const
|
|
11
|
-
const { catalog, saving, setEnabled } = useAgentProviders();
|
|
11
|
+
const t = useLrText().agents;
|
|
12
|
+
const { catalog, saving, setEnabled, setCliPath, reload } = useAgentProviders();
|
|
13
|
+
const [rechecking, setRechecking] = useState(false);
|
|
14
|
+
const [draft, setDraft] = useState<Partial<Record<AgentCliId, string>>>({});
|
|
15
|
+
const [manualError, setManualError] = useState<Partial<Record<AgentCliId, boolean>>>({});
|
|
16
|
+
const [detailsOpen, setDetailsOpen] = useState<Partial<Record<AgentCliId, boolean>>>({});
|
|
12
17
|
if (!catalog) return null;
|
|
13
18
|
|
|
14
19
|
const on = new Set(catalog.enabled);
|
|
20
|
+
const otherAgents = catalog.agents.filter((row) => !row.connectable);
|
|
15
21
|
|
|
16
22
|
async function toggle(row: AgentProviderRow) {
|
|
17
23
|
const ok = await setEnabled(row.id, !on.has(row.id));
|
|
18
|
-
if (!ok) toast.error(
|
|
24
|
+
if (!ok) toast.error(t.saveFailed);
|
|
19
25
|
}
|
|
20
26
|
|
|
21
|
-
function
|
|
22
|
-
|
|
27
|
+
async function recheck() {
|
|
28
|
+
setRechecking(true);
|
|
29
|
+
await reload();
|
|
30
|
+
setRechecking(false);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function clearManualError(id: AgentCliId) {
|
|
34
|
+
setManualError((current) => ({ ...current, [id]: false }));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function savePath(id: AgentCliId) {
|
|
38
|
+
const value = (draft[id] ?? '').trim();
|
|
39
|
+
if (!value) return;
|
|
40
|
+
const result = await setCliPath(id, value);
|
|
41
|
+
if (!result.ok) {
|
|
42
|
+
setManualError((current) => ({ ...current, [id]: true }));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
clearManualError(id);
|
|
46
|
+
setDraft((current) => ({ ...current, [id]: '' }));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function clearPath(id: AgentCliId) {
|
|
50
|
+
const result = await setCliPath(id, null);
|
|
51
|
+
if (!result.ok) toast.error(t.saveFailed);
|
|
52
|
+
clearManualError(id);
|
|
23
53
|
}
|
|
24
54
|
|
|
25
55
|
return (
|
|
@@ -27,58 +57,369 @@ export function AgentProvidersSection() {
|
|
|
27
57
|
data-lr-agent-providers
|
|
28
58
|
className="mt-5 rounded-[16px] border border-border bg-card px-6 py-5 shadow-[var(--lr-shadow-1)]"
|
|
29
59
|
>
|
|
30
|
-
<
|
|
31
|
-
|
|
60
|
+
<div className="flex items-start gap-3">
|
|
61
|
+
<div className="min-w-0 flex-1">
|
|
62
|
+
<h2 className="text-[16px] font-semibold">{t.title}</h2>
|
|
63
|
+
<p className="mt-1 text-[14px] text-muted-foreground">{t.hint}</p>
|
|
64
|
+
</div>
|
|
65
|
+
<button
|
|
66
|
+
type="button"
|
|
67
|
+
data-lr-agent-recheck
|
|
68
|
+
disabled={rechecking}
|
|
69
|
+
onClick={() => void recheck()}
|
|
70
|
+
className="shrink-0 rounded-[10px] border border-border bg-card px-3 py-1.5 text-[13px] font-medium outline-none hover:border-[var(--lr-text-3)] focus-visible:ring-2 focus-visible:ring-ring/40"
|
|
71
|
+
>
|
|
72
|
+
{t.recheck}
|
|
73
|
+
</button>
|
|
74
|
+
</div>
|
|
32
75
|
|
|
33
|
-
<ul className="divide-y divide-border border-t border-border">
|
|
76
|
+
<ul className="mt-2 divide-y divide-border border-t border-border">
|
|
34
77
|
{catalog.providers.map((row) => {
|
|
35
78
|
const checked = row.builtin || on.has(row.id);
|
|
36
79
|
const locked = row.builtin || !row.detected || !row.connectable;
|
|
80
|
+
const id = row.cli?.id;
|
|
37
81
|
return (
|
|
38
|
-
<li key={row.id} data-lr-agent-row={row.id} className="
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
82
|
+
<li key={row.id} data-lr-agent-row={row.id} className="py-3">
|
|
83
|
+
<div className="flex items-center gap-3">
|
|
84
|
+
<ProviderLogo provider={row.id} className="size-6 shrink-0" />
|
|
85
|
+
<div className="min-w-0 flex-1">
|
|
86
|
+
<p className="text-[14px] font-semibold">
|
|
87
|
+
{row.name}
|
|
88
|
+
{row.builtin && (
|
|
89
|
+
<span className="ml-2 text-[12px] font-normal text-muted-foreground">
|
|
90
|
+
{t.alwaysOn}
|
|
91
|
+
</span>
|
|
92
|
+
)}
|
|
93
|
+
</p>
|
|
94
|
+
</div>
|
|
95
|
+
<button
|
|
96
|
+
type="button"
|
|
97
|
+
role="switch"
|
|
98
|
+
data-lr-agent-switch={row.id}
|
|
99
|
+
aria-checked={checked}
|
|
100
|
+
aria-label={format(t.unlock, { name: row.name })}
|
|
101
|
+
aria-disabled={locked}
|
|
102
|
+
disabled={locked || saving === row.id}
|
|
103
|
+
onClick={() => void toggle(row)}
|
|
104
|
+
className={cn(
|
|
105
|
+
'lr-switch shrink-0 outline-none focus-visible:ring-2 focus-visible:ring-ring/40',
|
|
106
|
+
locked && 'cursor-not-allowed opacity-45',
|
|
47
107
|
)}
|
|
48
|
-
|
|
49
|
-
<p data-lr-agent-state={row.id} className="text-[12px] text-muted-foreground">
|
|
50
|
-
{hint(row)}
|
|
51
|
-
</p>
|
|
108
|
+
/>
|
|
52
109
|
</div>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
/>
|
|
110
|
+
|
|
111
|
+
{row.cli && (
|
|
112
|
+
<CliDetails
|
|
113
|
+
cli={row.cli}
|
|
114
|
+
t={t}
|
|
115
|
+
draft={draft[id ?? 'claude'] ?? ''}
|
|
116
|
+
manualError={Boolean(id && manualError[id])}
|
|
117
|
+
working={saving === row.id}
|
|
118
|
+
onDraft={(value) => id && setDraft((current) => ({ ...current, [id]: value }))}
|
|
119
|
+
onSave={() => id && void savePath(id)}
|
|
120
|
+
onClear={() => id && void clearPath(id)}
|
|
121
|
+
/>
|
|
122
|
+
)}
|
|
67
123
|
</li>
|
|
68
124
|
);
|
|
69
125
|
})}
|
|
70
126
|
</ul>
|
|
71
127
|
|
|
128
|
+
{otherAgents.length > 0 && (
|
|
129
|
+
<div data-lr-agent-cli-agents className="mt-4 border-t border-border pt-3">
|
|
130
|
+
<h3 className="text-[13px] font-semibold">{t.cliTitle}</h3>
|
|
131
|
+
<p className="mt-0.5 text-[12px] text-muted-foreground">{t.cliHint}</p>
|
|
132
|
+
<ul className="mt-2 divide-y divide-border border-t border-border">
|
|
133
|
+
{otherAgents.map((row) => {
|
|
134
|
+
const cli = row.cli;
|
|
135
|
+
const id = cli.id;
|
|
136
|
+
const missing = cli.state === 'missing';
|
|
137
|
+
const open = missing && (Boolean(detailsOpen[id]) || Boolean(manualError[id]));
|
|
138
|
+
return (
|
|
139
|
+
<li key={row.id} data-lr-agent-cli-row={row.id} className="py-3">
|
|
140
|
+
{missing ? (
|
|
141
|
+
<>
|
|
142
|
+
<div className="flex flex-wrap items-baseline gap-x-2 gap-y-1">
|
|
143
|
+
<p className="text-[14px] font-semibold text-muted-foreground">
|
|
144
|
+
{row.name}
|
|
145
|
+
</p>
|
|
146
|
+
<p
|
|
147
|
+
data-lr-agent-cli-state={id}
|
|
148
|
+
className="text-[12px] font-medium text-muted-foreground"
|
|
149
|
+
>
|
|
150
|
+
{t.missing}
|
|
151
|
+
</p>
|
|
152
|
+
<span aria-hidden className="text-[12px] text-muted-foreground">
|
|
153
|
+
·
|
|
154
|
+
</span>
|
|
155
|
+
<a
|
|
156
|
+
href={cli.installUrl}
|
|
157
|
+
target="_blank"
|
|
158
|
+
rel="noreferrer"
|
|
159
|
+
data-lr-agent-cli-install={id}
|
|
160
|
+
className="text-[12px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
|
|
161
|
+
>
|
|
162
|
+
{t.installLink}
|
|
163
|
+
</a>
|
|
164
|
+
<span aria-hidden className="text-[12px] text-muted-foreground">
|
|
165
|
+
·
|
|
166
|
+
</span>
|
|
167
|
+
<button
|
|
168
|
+
type="button"
|
|
169
|
+
data-lr-agent-cli-details={id}
|
|
170
|
+
aria-expanded={open}
|
|
171
|
+
onClick={() =>
|
|
172
|
+
setDetailsOpen((current) => ({ ...current, [id]: !current[id] }))
|
|
173
|
+
}
|
|
174
|
+
className="text-[12px] font-medium text-muted-foreground underline-offset-2 outline-none hover:text-foreground hover:underline focus-visible:ring-2 focus-visible:ring-ring/40"
|
|
175
|
+
>
|
|
176
|
+
{t.details}
|
|
177
|
+
</button>
|
|
178
|
+
</div>
|
|
179
|
+
{open && (
|
|
180
|
+
<div className="mt-2 pl-9">
|
|
181
|
+
<AgentMissingDetails
|
|
182
|
+
cli={cli}
|
|
183
|
+
t={t}
|
|
184
|
+
draft={draft[id] ?? ''}
|
|
185
|
+
manualError={Boolean(manualError[id])}
|
|
186
|
+
working={saving === row.id}
|
|
187
|
+
onDraft={(value) =>
|
|
188
|
+
setDraft((current) => ({ ...current, [id]: value }))
|
|
189
|
+
}
|
|
190
|
+
onSave={() => void savePath(id)}
|
|
191
|
+
/>
|
|
192
|
+
</div>
|
|
193
|
+
)}
|
|
194
|
+
</>
|
|
195
|
+
) : (
|
|
196
|
+
<>
|
|
197
|
+
<div className="flex items-baseline justify-between gap-2">
|
|
198
|
+
<p className="text-[14px] font-semibold">{row.name}</p>
|
|
199
|
+
</div>
|
|
200
|
+
<p
|
|
201
|
+
data-lr-agent-cli-unsupported={id}
|
|
202
|
+
className="mt-0.5 text-[12px] text-muted-foreground"
|
|
203
|
+
>
|
|
204
|
+
{t.panelUnsupported}
|
|
205
|
+
</p>
|
|
206
|
+
<CliDetails
|
|
207
|
+
cli={cli}
|
|
208
|
+
t={t}
|
|
209
|
+
draft={draft[id] ?? ''}
|
|
210
|
+
manualError={Boolean(manualError[id])}
|
|
211
|
+
working={saving === row.id}
|
|
212
|
+
onDraft={(value) => setDraft((current) => ({ ...current, [id]: value }))}
|
|
213
|
+
onSave={() => void savePath(id)}
|
|
214
|
+
onClear={() => void clearPath(id)}
|
|
215
|
+
/>
|
|
216
|
+
</>
|
|
217
|
+
)}
|
|
218
|
+
</li>
|
|
219
|
+
);
|
|
220
|
+
})}
|
|
221
|
+
</ul>
|
|
222
|
+
</div>
|
|
223
|
+
)}
|
|
224
|
+
|
|
72
225
|
<p data-lr-agent-own-window className="mt-3 text-[13px] text-muted-foreground">
|
|
73
|
-
{
|
|
74
|
-
<Link
|
|
75
|
-
to="/help#guide-prepare"
|
|
76
|
-
data-lr-agent-own-window-link
|
|
77
|
-
className="underline-offset-2 hover:text-foreground hover:underline"
|
|
78
|
-
>
|
|
79
|
-
{lr.agents.ownWindowLink}
|
|
80
|
-
</Link>
|
|
226
|
+
{t.ownWindow}
|
|
81
227
|
</p>
|
|
82
228
|
</section>
|
|
83
229
|
);
|
|
84
230
|
}
|
|
231
|
+
|
|
232
|
+
type AgentsText = ReturnType<typeof useLrText>['agents'];
|
|
233
|
+
|
|
234
|
+
function CliDetails({
|
|
235
|
+
cli,
|
|
236
|
+
t,
|
|
237
|
+
draft,
|
|
238
|
+
manualError,
|
|
239
|
+
working,
|
|
240
|
+
onDraft,
|
|
241
|
+
onSave,
|
|
242
|
+
onClear,
|
|
243
|
+
}: {
|
|
244
|
+
cli: CliStatus;
|
|
245
|
+
t: AgentsText;
|
|
246
|
+
draft: string;
|
|
247
|
+
manualError: boolean;
|
|
248
|
+
working: boolean;
|
|
249
|
+
onDraft: (value: string) => void;
|
|
250
|
+
onSave: () => void;
|
|
251
|
+
onClear: () => void;
|
|
252
|
+
}) {
|
|
253
|
+
const values = { command: cli.loginCommand };
|
|
254
|
+
const id = cli.id;
|
|
255
|
+
|
|
256
|
+
return (
|
|
257
|
+
<div className="mt-2 pl-9">
|
|
258
|
+
{cli.state === 'missing' ? (
|
|
259
|
+
<>
|
|
260
|
+
<p
|
|
261
|
+
data-lr-agent-cli-state={id}
|
|
262
|
+
className="text-[12px] font-medium text-amber-600 dark:text-amber-400"
|
|
263
|
+
>
|
|
264
|
+
{t.missing}
|
|
265
|
+
</p>
|
|
266
|
+
<SearchedPlaces cli={cli} t={t} />
|
|
267
|
+
<a
|
|
268
|
+
href={cli.installUrl}
|
|
269
|
+
target="_blank"
|
|
270
|
+
rel="noreferrer"
|
|
271
|
+
data-lr-agent-cli-install={id}
|
|
272
|
+
className="mt-2 inline-block text-[12px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
|
|
273
|
+
>
|
|
274
|
+
{t.installLink}
|
|
275
|
+
</a>
|
|
276
|
+
<ManualPicker
|
|
277
|
+
cli={cli}
|
|
278
|
+
t={t}
|
|
279
|
+
draft={draft}
|
|
280
|
+
manualError={manualError}
|
|
281
|
+
working={working}
|
|
282
|
+
onDraft={onDraft}
|
|
283
|
+
onSave={onSave}
|
|
284
|
+
/>
|
|
285
|
+
</>
|
|
286
|
+
) : (
|
|
287
|
+
<>
|
|
288
|
+
<p
|
|
289
|
+
data-lr-agent-cli-state={id}
|
|
290
|
+
className={cn(
|
|
291
|
+
'text-[12px] font-medium',
|
|
292
|
+
cli.state === 'login'
|
|
293
|
+
? 'text-amber-600 dark:text-amber-400'
|
|
294
|
+
: 'text-muted-foreground',
|
|
295
|
+
)}
|
|
296
|
+
>
|
|
297
|
+
{cli.state === 'login' ? t.needsLogin : t.found}
|
|
298
|
+
{cli.version ? ` · ${format(t.versionLine, { version: cli.version })}` : ''}
|
|
299
|
+
</p>
|
|
300
|
+
{cli.state === 'login' && (
|
|
301
|
+
<p className="mt-1 text-[12px] text-muted-foreground">
|
|
302
|
+
{format(t.needsLoginHint, values)}
|
|
303
|
+
</p>
|
|
304
|
+
)}
|
|
305
|
+
{cli.path && (
|
|
306
|
+
<p className="mt-1 break-all font-mono text-[11px] text-muted-foreground">
|
|
307
|
+
{format(t.location, { path: cli.path })}
|
|
308
|
+
</p>
|
|
309
|
+
)}
|
|
310
|
+
{cli.manualPath && (
|
|
311
|
+
<button
|
|
312
|
+
type="button"
|
|
313
|
+
data-lr-agent-cli-clear={id}
|
|
314
|
+
disabled={working}
|
|
315
|
+
onClick={onClear}
|
|
316
|
+
className="mt-1.5 rounded text-[12px] text-muted-foreground underline-offset-2 outline-none hover:text-foreground hover:underline focus-visible:ring-2 focus-visible:ring-ring/40"
|
|
317
|
+
>
|
|
318
|
+
{t.manualClear}
|
|
319
|
+
</button>
|
|
320
|
+
)}
|
|
321
|
+
</>
|
|
322
|
+
)}
|
|
323
|
+
</div>
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function AgentMissingDetails({
|
|
328
|
+
cli,
|
|
329
|
+
t,
|
|
330
|
+
draft,
|
|
331
|
+
manualError,
|
|
332
|
+
working,
|
|
333
|
+
onDraft,
|
|
334
|
+
onSave,
|
|
335
|
+
}: {
|
|
336
|
+
cli: CliStatus;
|
|
337
|
+
t: AgentsText;
|
|
338
|
+
draft: string;
|
|
339
|
+
manualError: boolean;
|
|
340
|
+
working: boolean;
|
|
341
|
+
onDraft: (value: string) => void;
|
|
342
|
+
onSave: () => void;
|
|
343
|
+
}) {
|
|
344
|
+
return (
|
|
345
|
+
<>
|
|
346
|
+
<SearchedPlaces cli={cli} t={t} />
|
|
347
|
+
<ManualPicker
|
|
348
|
+
cli={cli}
|
|
349
|
+
t={t}
|
|
350
|
+
draft={draft}
|
|
351
|
+
manualError={manualError}
|
|
352
|
+
working={working}
|
|
353
|
+
onDraft={onDraft}
|
|
354
|
+
onSave={onSave}
|
|
355
|
+
/>
|
|
356
|
+
</>
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function SearchedPlaces({ cli, t }: { cli: CliStatus; t: AgentsText }) {
|
|
361
|
+
return (
|
|
362
|
+
<>
|
|
363
|
+
<p className="mt-1 text-[12px] text-muted-foreground">{t.searchedLabel}</p>
|
|
364
|
+
<ul
|
|
365
|
+
data-lr-agent-cli-searched={cli.id}
|
|
366
|
+
className="mt-1 max-h-28 overflow-auto rounded-[8px] bg-muted/40 px-2.5 py-2 font-mono text-[11px] leading-snug text-muted-foreground"
|
|
367
|
+
>
|
|
368
|
+
{cli.searched.map((item) => (
|
|
369
|
+
<li key={item} className="break-all">
|
|
370
|
+
{item}
|
|
371
|
+
</li>
|
|
372
|
+
))}
|
|
373
|
+
</ul>
|
|
374
|
+
</>
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function ManualPicker({
|
|
379
|
+
cli,
|
|
380
|
+
t,
|
|
381
|
+
draft,
|
|
382
|
+
manualError,
|
|
383
|
+
working,
|
|
384
|
+
onDraft,
|
|
385
|
+
onSave,
|
|
386
|
+
}: {
|
|
387
|
+
cli: CliStatus;
|
|
388
|
+
t: AgentsText;
|
|
389
|
+
draft: string;
|
|
390
|
+
manualError: boolean;
|
|
391
|
+
working: boolean;
|
|
392
|
+
onDraft: (value: string) => void;
|
|
393
|
+
onSave: () => void;
|
|
394
|
+
}) {
|
|
395
|
+
const id = cli.id;
|
|
396
|
+
return (
|
|
397
|
+
<div className="mt-2">
|
|
398
|
+
<p className="text-[12px] font-medium">{t.manualLabel}</p>
|
|
399
|
+
<div className="mt-1.5 flex flex-wrap items-center gap-2">
|
|
400
|
+
<input
|
|
401
|
+
type="text"
|
|
402
|
+
data-lr-agent-cli-input={id}
|
|
403
|
+
value={draft}
|
|
404
|
+
placeholder={t.manualPlaceholder}
|
|
405
|
+
onChange={(event) => onDraft(event.target.value)}
|
|
406
|
+
className="min-w-0 flex-1 rounded-[8px] border border-border bg-card px-2.5 py-1.5 font-mono text-[12px] outline-none focus-visible:ring-2 focus-visible:ring-ring/40"
|
|
407
|
+
/>
|
|
408
|
+
<button
|
|
409
|
+
type="button"
|
|
410
|
+
data-lr-agent-cli-save={id}
|
|
411
|
+
disabled={working || draft.trim() === ''}
|
|
412
|
+
onClick={onSave}
|
|
413
|
+
className="rounded-[8px] border border-border bg-card px-3 py-1.5 text-[12px] font-medium outline-none hover:border-[var(--lr-text-3)] focus-visible:ring-2 focus-visible:ring-ring/40 disabled:opacity-45"
|
|
414
|
+
>
|
|
415
|
+
{t.manualSave}
|
|
416
|
+
</button>
|
|
417
|
+
</div>
|
|
418
|
+
{manualError && (
|
|
419
|
+
<p data-lr-agent-cli-error={id} className="mt-1 text-[12px] text-destructive">
|
|
420
|
+
{t.manualInvalid}
|
|
421
|
+
</p>
|
|
422
|
+
)}
|
|
423
|
+
</div>
|
|
424
|
+
);
|
|
425
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { refreshStatus } from '@/lib/agent/use-agent';
|
|
3
3
|
import type { AgentProviderId } from '../../../agent/types';
|
|
4
|
+
import type { AgentCliId, CliStatus } from '../agent-cli/model';
|
|
4
5
|
|
|
5
6
|
export type AgentProviderRow = {
|
|
6
7
|
id: AgentProviderId;
|
|
@@ -9,9 +10,19 @@ export type AgentProviderRow = {
|
|
|
9
10
|
detected: boolean;
|
|
10
11
|
connectable: boolean;
|
|
11
12
|
reason: string | null;
|
|
13
|
+
cli: CliStatus | null;
|
|
12
14
|
};
|
|
13
15
|
|
|
14
|
-
type
|
|
16
|
+
export type CliAgentRow = {
|
|
17
|
+
id: AgentCliId;
|
|
18
|
+
name: string;
|
|
19
|
+
connectable: boolean;
|
|
20
|
+
cli: CliStatus;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type Catalog = { enabled: string[]; providers: AgentProviderRow[]; agents: CliAgentRow[] };
|
|
24
|
+
|
|
25
|
+
type Result = { ok: true } | { ok: false; error: string };
|
|
15
26
|
|
|
16
27
|
export function useAgentProviders() {
|
|
17
28
|
const [catalog, setCatalog] = useState<Catalog | null>(null);
|
|
@@ -26,10 +37,23 @@ export function useAgentProviders() {
|
|
|
26
37
|
}, []);
|
|
27
38
|
|
|
28
39
|
useEffect(() => {
|
|
29
|
-
if (!import.meta.env.DEV) return;
|
|
30
40
|
void load();
|
|
31
41
|
}, [load]);
|
|
32
42
|
|
|
43
|
+
const replaceCli = useCallback((cli: CliStatus) => {
|
|
44
|
+
setCatalog((current) =>
|
|
45
|
+
current
|
|
46
|
+
? {
|
|
47
|
+
...current,
|
|
48
|
+
providers: current.providers.map((row) =>
|
|
49
|
+
row.id === cli.id ? { ...row, detected: cli.state !== 'missing', cli } : row,
|
|
50
|
+
),
|
|
51
|
+
agents: current.agents.map((row) => (row.id === cli.id ? { ...row, cli } : row)),
|
|
52
|
+
}
|
|
53
|
+
: current,
|
|
54
|
+
);
|
|
55
|
+
}, []);
|
|
56
|
+
|
|
33
57
|
const setEnabled = useCallback(
|
|
34
58
|
async (id: string, on: boolean): Promise<boolean> => {
|
|
35
59
|
if (!catalog) return false;
|
|
@@ -57,5 +81,28 @@ export function useAgentProviders() {
|
|
|
57
81
|
[catalog],
|
|
58
82
|
);
|
|
59
83
|
|
|
60
|
-
|
|
84
|
+
const setCliPath = useCallback(
|
|
85
|
+
async (id: AgentCliId, path: string | null): Promise<Result> => {
|
|
86
|
+
setSaving(id);
|
|
87
|
+
try {
|
|
88
|
+
const res = await fetch('/__lr/agent-providers/cli', {
|
|
89
|
+
method: path === null ? 'DELETE' : 'PUT',
|
|
90
|
+
headers: { 'content-type': 'application/json' },
|
|
91
|
+
body: JSON.stringify(path === null ? { id } : { id, path }),
|
|
92
|
+
});
|
|
93
|
+
const body = (await res.json().catch(() => ({}))) as { cli?: CliStatus; error?: string };
|
|
94
|
+
if (!res.ok || !body.cli) return { ok: false, error: body.error ?? `HTTP ${res.status}` };
|
|
95
|
+
replaceCli(body.cli);
|
|
96
|
+
void refreshStatus();
|
|
97
|
+
return { ok: true };
|
|
98
|
+
} catch (err) {
|
|
99
|
+
return { ok: false, error: err instanceof Error ? err.message : 'failed' };
|
|
100
|
+
} finally {
|
|
101
|
+
setSaving(null);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
[replaceCli],
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
return { catalog, saving, setEnabled, setCliPath, reload: load };
|
|
61
108
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Finds the cloud-drive folders this
|
|
1
|
+
/** Finds the cloud-drive folders this machine already syncs, plus the local default. */
|
|
2
2
|
|
|
3
3
|
import { format } from '../../../locale/format';
|
|
4
4
|
import type { LrText } from '../text/types';
|
|
@@ -19,7 +19,13 @@ function kindFor(name: string): BackupPlaceKind {
|
|
|
19
19
|
return 'other';
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export function findBackupPlaces(
|
|
22
|
+
export function findBackupPlaces(
|
|
23
|
+
home: string,
|
|
24
|
+
io: PlaceIo,
|
|
25
|
+
platform: NodeJS.Platform = 'darwin',
|
|
26
|
+
): BackupPlace[] {
|
|
27
|
+
const windows = platform === 'win32';
|
|
28
|
+
const join = (...parts: string[]) => parts.join(windows ? '\\' : '/');
|
|
23
29
|
const out: BackupPlace[] = [];
|
|
24
30
|
const seen = new Set<string>();
|
|
25
31
|
const add = (path: string, label: string, kind: BackupPlaceKind) => {
|
|
@@ -28,25 +34,29 @@ export function findBackupPlaces(home: string, io: PlaceIo): BackupPlace[] {
|
|
|
28
34
|
out.push({ id: path, label, path, kind });
|
|
29
35
|
};
|
|
30
36
|
|
|
31
|
-
|
|
37
|
+
if (windows) {
|
|
38
|
+
add(join(home, 'iCloudDrive'), 'iCloud Drive', 'icloud');
|
|
39
|
+
} else {
|
|
40
|
+
add(join(home, 'Library', 'Mobile Documents', 'com~apple~CloudDocs'), 'iCloud Drive', 'icloud');
|
|
32
41
|
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
const cloudStorage = join(home, 'Library', 'CloudStorage');
|
|
43
|
+
for (const name of io.list(cloudStorage)) add(join(cloudStorage, name), name, kindFor(name));
|
|
44
|
+
}
|
|
35
45
|
|
|
36
|
-
add(
|
|
37
|
-
add(
|
|
46
|
+
add(join(home, 'Dropbox'), 'Dropbox', 'dropbox');
|
|
47
|
+
add(join(home, 'OneDrive'), 'OneDrive', 'onedrive');
|
|
38
48
|
for (const name of io.list(home)) {
|
|
39
|
-
if (name.startsWith('OneDrive - ')) add(
|
|
49
|
+
if (name.startsWith('OneDrive - ')) add(join(home, name), name, 'onedrive');
|
|
40
50
|
}
|
|
41
51
|
|
|
42
|
-
add(
|
|
52
|
+
add(join(home, 'BaiduSyncdisk'), '百度网盘同步空间', 'baidu');
|
|
43
53
|
|
|
44
|
-
const nutstore =
|
|
45
|
-
for (const name of io.list(nutstore)) add(
|
|
54
|
+
const nutstore = join(home, 'Nutstore Files');
|
|
55
|
+
for (const name of io.list(nutstore)) add(join(nutstore, name), name, 'nutstore');
|
|
46
56
|
|
|
47
57
|
// The default place is offered whether or not it exists yet: the first backup
|
|
48
58
|
// creates it.
|
|
49
|
-
const local =
|
|
59
|
+
const local = join(home, BACKUP_FOLDER_NAME);
|
|
50
60
|
if (!seen.has(local))
|
|
51
61
|
out.push({ id: local, label: BACKUP_FOLDER_NAME, path: local, kind: 'local' });
|
|
52
62
|
|
|
@@ -22,7 +22,6 @@ import {
|
|
|
22
22
|
type FeedbackRequest,
|
|
23
23
|
type InstallKind,
|
|
24
24
|
mailtoHref,
|
|
25
|
-
osLabelFor,
|
|
26
25
|
} from './model';
|
|
27
26
|
|
|
28
27
|
const OPEN_EVENT = 'lemonriver:feedback-open';
|
|
@@ -72,7 +71,7 @@ export function FeedbackHost() {
|
|
|
72
71
|
buildFeedbackInfo(
|
|
73
72
|
{
|
|
74
73
|
version: version || f.unknown,
|
|
75
|
-
os:
|
|
74
|
+
os: osVersion,
|
|
76
75
|
install,
|
|
77
76
|
page: pageForPath(request?.page ?? '/'),
|
|
78
77
|
errorKind: (request?.errorKind as FeedbackErrorKind | null | undefined) ?? null,
|
|
@@ -56,11 +56,6 @@ export function feedbackPageKind(page: LrPage): FeedbackPageKind {
|
|
|
56
56
|
return PAGE_KINDS[page] ?? 'other';
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
/** The label for the version the dev server read; null drops to "unknown". */
|
|
60
|
-
export function osLabelFor(version: string | null): string | null {
|
|
61
|
-
return version === null || version === '' ? null : `macOS ${version}`;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
59
|
/**
|
|
65
60
|
* The only description of a failure the feedback ever carries: which kind it
|
|
66
61
|
* was. Whatever else sits on the error (messages, paths, titles) is ignored.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export async function copyText(text: string): Promise<boolean> {
|
|
2
|
+
try {
|
|
3
|
+
await navigator.clipboard.writeText(text);
|
|
4
|
+
return true;
|
|
5
|
+
} catch {}
|
|
6
|
+
try {
|
|
7
|
+
const area = document.createElement('textarea');
|
|
8
|
+
area.value = text;
|
|
9
|
+
area.style.position = 'fixed';
|
|
10
|
+
area.style.opacity = '0';
|
|
11
|
+
document.body.appendChild(area);
|
|
12
|
+
area.select();
|
|
13
|
+
const ok = document.execCommand('copy');
|
|
14
|
+
area.remove();
|
|
15
|
+
return ok;
|
|
16
|
+
} catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|