@vibes.diy/base 14.3.402 → 14.3.404
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/components/vibe-menu/VibeMenu.js +3 -1
- package/components/vibe-menu/cards/CodeCard.js +1 -1
- package/components/vibe-menu/parts/Composer.d.ts +1 -0
- package/components/vibe-menu/parts/StopIconButton.d.ts +1 -1
- package/components/vibe-menu/parts/StopIconButton.js +6 -3
- package/components/vibe-menu/parts/use-composer-draft.d.ts +4 -0
- package/components/vibe-menu/parts/use-composer-draft.js +63 -9
- package/components/vibe-menu/slices.d.ts +1 -0
- package/hooks/img-gen/local-pictures.js +11 -3
- package/hooks/img-gen/use-img-gen.js +21 -1
- package/package.json +6 -6
|
@@ -60,7 +60,9 @@ export function VibeMenu(props) {
|
|
|
60
60
|
const baseDraft = useComposerDraft({
|
|
61
61
|
composer: withBuildAskAnswer(code.composer, code.buildAsk),
|
|
62
62
|
resetKey: viewer.appSlug,
|
|
63
|
-
persistKey: viewer.appSlug === null || viewer.ownerHandle === null
|
|
63
|
+
persistKey: viewer.appSlug === null || viewer.ownerHandle === null
|
|
64
|
+
? (viewer.draftKey ?? null)
|
|
65
|
+
: `${viewer.ownerHandle}/${viewer.appSlug}`,
|
|
64
66
|
});
|
|
65
67
|
const ownLines = draftYouLines(baseDraft, code.log).length;
|
|
66
68
|
const codeOpen = state.phase === "card" && state.section === "vibe";
|
|
@@ -408,7 +408,7 @@ export function CodeCard(props) {
|
|
|
408
408
|
const mainAction = showComposer ? (firstBuild && askOpen ? (React.createElement("div", { className: "vm-ask-slot vm-ask-foot", "data-build-ask-foot": "" },
|
|
409
409
|
React.createElement("div", { "data-stop-reserve": "", "aria-hidden": "true", inert: true, style: { visibility: "hidden" } },
|
|
410
410
|
React.createElement(StopIconButton, { disabled: true, onStop: () => undefined })),
|
|
411
|
-
React.createElement("div", { className: "vm-ask-foot-composer" }, composerNode))) : (composerNode)) : working ? (React.createElement(StopIconButton, { disabled: composer.stopDisabled === true, armedAt: latestStopArm(live?.expected?.fromMs, pinnedLeftAt.current), onStop: () => {
|
|
411
|
+
React.createElement("div", { className: "vm-ask-foot-composer" }, composerNode))) : (composerNode)) : working ? (React.createElement(StopIconButton, { disabled: composer.stopDisabled === true, armedAt: latestStopArm(live?.expected?.fromMs, pinnedLeftAt.current, composer.stopArmedAt), onStop: () => {
|
|
412
412
|
heldFirstBuild.current = null;
|
|
413
413
|
draft.stop();
|
|
414
414
|
}, latch: code.composerHidden !== true })) : bootHold ? (React.createElement("div", { "data-stop-reserve": "", "aria-hidden": "true", inert: true, style: { visibility: "hidden" } },
|
|
@@ -52,6 +52,7 @@ export interface ComposerSlice {
|
|
|
52
52
|
readonly onSubmit: (text: string, attachments: readonly PromptAttachment[], source?: "suggestion") => ComposerSubmitAnswer;
|
|
53
53
|
readonly onStop: () => void;
|
|
54
54
|
readonly stopDisabled?: boolean;
|
|
55
|
+
readonly stopArmedAt?: number;
|
|
55
56
|
readonly seed: ComposerSeed | null;
|
|
56
57
|
readonly restore: ComposerRestore | null;
|
|
57
58
|
readonly onSendBlocked?: (reason: ComposerSendBlockedReason) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
export declare const STOP_ICON_CSS = "\n[data-vibe-menu] .vm-stop-row { display: flex; justify-content: flex-end; margin: 0 0 var(--space-8); }\n[data-vibe-menu] .vm-stop-icon {\n flex: none; display: inline-flex; align-items: center; justify-content: center;\n width: 32px; height: 32px; padding: 0; border-radius: 8px;\n border: var(--stroke-rule) solid var(--line-card);\n background: var(--section-code); color: var(--on-code); cursor: pointer;\n}\n[data-vibe-menu] .vm-stop-icon:hover { background: color-mix(in oklch, var(--section-code), var(--menu-ink) 10%); }\n[data-vibe-menu] .vm-stop-icon .vm-glyph { width: 12px; height: 12px; fill: currentColor; }\n[data-vibe-menu] .vm-stop-icon[aria-disabled=\"true\"],\n[data-vibe-menu] .vm-stop-icon:disabled { opacity: 0.5; cursor: default; }\n";
|
|
2
|
+
export declare const STOP_ICON_CSS = "\n[data-vibe-menu] .vm-stop-row { display: flex; justify-content: flex-end; align-items: center; gap: var(--space-8); margin: 0 0 var(--space-8); }\n[data-vibe-menu] .vm-stop-icon {\n flex: none; display: inline-flex; align-items: center; justify-content: center;\n width: 32px; height: 32px; padding: 0; border-radius: 8px;\n border: var(--stroke-rule) solid var(--line-card);\n background: var(--section-code); color: var(--on-code); cursor: pointer;\n}\n[data-vibe-menu] .vm-stop-icon:hover { background: color-mix(in oklch, var(--section-code), var(--menu-ink) 10%); }\n[data-vibe-menu] .vm-stop-icon .vm-glyph { width: 12px; height: 12px; fill: currentColor; }\n[data-vibe-menu] .vm-stop-icon[aria-disabled=\"true\"],\n[data-vibe-menu] .vm-stop-icon:disabled { opacity: 0.5; cursor: default; }\n[data-vibe-menu] .vm-stop-held-note { font-size: 12px; color: var(--muted); }\n";
|
|
3
3
|
export interface StopIconButtonProps {
|
|
4
4
|
readonly disabled?: boolean;
|
|
5
5
|
readonly armedAt?: number;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { stopGuardHolds } from "./Composer.js";
|
|
2
|
+
import { stopGuardHolds, useStopGuardHolds } from "./Composer.js";
|
|
3
3
|
import { Glyph } from "./Glyph.js";
|
|
4
4
|
export const STOP_ICON_CSS = `
|
|
5
|
-
[data-vibe-menu] .vm-stop-row { display: flex; justify-content: flex-end; margin: 0 0 var(--space-8); }
|
|
5
|
+
[data-vibe-menu] .vm-stop-row { display: flex; justify-content: flex-end; align-items: center; gap: var(--space-8); margin: 0 0 var(--space-8); }
|
|
6
6
|
[data-vibe-menu] .vm-stop-icon {
|
|
7
7
|
flex: none; display: inline-flex; align-items: center; justify-content: center;
|
|
8
8
|
width: 32px; height: 32px; padding: 0; border-radius: 8px;
|
|
@@ -13,10 +13,12 @@ export const STOP_ICON_CSS = `
|
|
|
13
13
|
[data-vibe-menu] .vm-stop-icon .vm-glyph { width: 12px; height: 12px; fill: currentColor; }
|
|
14
14
|
[data-vibe-menu] .vm-stop-icon[aria-disabled="true"],
|
|
15
15
|
[data-vibe-menu] .vm-stop-icon:disabled { opacity: 0.5; cursor: default; }
|
|
16
|
+
[data-vibe-menu] .vm-stop-held-note { font-size: 12px; color: var(--muted); }
|
|
16
17
|
`;
|
|
17
18
|
export function StopIconButton(props) {
|
|
18
19
|
const [stopping, setStopping] = React.useState(false);
|
|
19
20
|
const blocked = props.disabled === true;
|
|
21
|
+
const held = useStopGuardHolds(props.armedAt) && !stopping && !blocked;
|
|
20
22
|
function press() {
|
|
21
23
|
if (blocked || stopping || stopGuardHolds(Date.now(), props.armedAt))
|
|
22
24
|
return;
|
|
@@ -26,6 +28,7 @@ export function StopIconButton(props) {
|
|
|
26
28
|
}
|
|
27
29
|
return (React.createElement("div", { className: "vm-stop-row" },
|
|
28
30
|
React.createElement("style", null, STOP_ICON_CSS),
|
|
29
|
-
React.createElement("
|
|
31
|
+
held ? (React.createElement("span", { className: "vm-stop-held-note", "aria-hidden": "true" }, "Starting\u2026")) : null,
|
|
32
|
+
React.createElement("button", { type: "button", className: "vm-stop-icon vm-ctab-stop", "data-stop": "", "data-stopping": stopping ? "" : undefined, "data-stop-held": held ? "" : undefined, "aria-label": held ? "Starting…" : "Stop building", "aria-disabled": blocked || held ? "true" : undefined, "aria-busy": stopping || held ? true : undefined, disabled: stopping, onClick: press },
|
|
30
33
|
React.createElement(Glyph, { name: "stop" }))));
|
|
31
34
|
}
|
|
@@ -6,6 +6,10 @@ export declare const QUEUE_STALE_BUILD_MS = 120000;
|
|
|
6
6
|
export declare const QUEUED_CHANGE_KEY = "vibes.queuedChange.";
|
|
7
7
|
export declare const HELD_CHANGE_KEY = "vibes.heldChange.";
|
|
8
8
|
export declare const HELD_FOLLOW_UP_KEY = "vibes.heldFollowUp.";
|
|
9
|
+
export declare const DRAFT_CARRY_KEY = "vibes.draftCarry.";
|
|
10
|
+
export declare function firstBuildDraftKey(chatId: string): string;
|
|
11
|
+
export declare function carryComposerDraft(fromKey: string, toKey: string): void;
|
|
12
|
+
export declare function carrySavedComposerDraft(fromKey: string, toKey: string): void;
|
|
9
13
|
export interface UseComposerDraftInput {
|
|
10
14
|
readonly composer: ComposerSlice;
|
|
11
15
|
readonly resetKey: string | null;
|
|
@@ -30,6 +30,47 @@ function takeChange(prefix, appKey) {
|
|
|
30
30
|
const text = r.isOk() ? r.Ok() : null;
|
|
31
31
|
return text === null || text === "" ? undefined : text;
|
|
32
32
|
}
|
|
33
|
+
export const DRAFT_CARRY_KEY = "vibes.draftCarry.";
|
|
34
|
+
export function firstBuildDraftKey(chatId) {
|
|
35
|
+
return `first-build:${chatId}`;
|
|
36
|
+
}
|
|
37
|
+
function isFirstBuildDraftKey(key) {
|
|
38
|
+
return key !== null && key.startsWith("first-build:");
|
|
39
|
+
}
|
|
40
|
+
function carriedKey(appKey) {
|
|
41
|
+
if (typeof sessionStorage === "undefined")
|
|
42
|
+
return appKey;
|
|
43
|
+
const r = exception2Result(() => sessionStorage.getItem(DRAFT_CARRY_KEY + appKey));
|
|
44
|
+
const to = r.isOk() ? r.Ok() : null;
|
|
45
|
+
return to === null || to === "" ? appKey : to;
|
|
46
|
+
}
|
|
47
|
+
function dropCopy(prefix, appKey) {
|
|
48
|
+
dropChange(prefix, appKey);
|
|
49
|
+
const to = carriedKey(appKey);
|
|
50
|
+
if (to !== appKey)
|
|
51
|
+
dropChange(prefix, to);
|
|
52
|
+
}
|
|
53
|
+
export function carryComposerDraft(fromKey, toKey) {
|
|
54
|
+
if (typeof sessionStorage === "undefined" || fromKey === toKey)
|
|
55
|
+
return;
|
|
56
|
+
saveChange(DRAFT_CARRY_KEY, fromKey, toKey);
|
|
57
|
+
carrySavedComposerDraft(fromKey, toKey);
|
|
58
|
+
}
|
|
59
|
+
export function carrySavedComposerDraft(fromKey, toKey) {
|
|
60
|
+
if (typeof sessionStorage === "undefined" || fromKey === toKey)
|
|
61
|
+
return;
|
|
62
|
+
const queuedBack = takeChange(QUEUED_CHANGE_KEY, fromKey);
|
|
63
|
+
if (queuedBack !== undefined) {
|
|
64
|
+
const there = takeChange(QUEUED_CHANGE_KEY, toKey);
|
|
65
|
+
saveChange(QUEUED_CHANGE_KEY, toKey, there === undefined ? queuedBack : `${there}\n${queuedBack}`);
|
|
66
|
+
}
|
|
67
|
+
const heldBack = takeChange(HELD_CHANGE_KEY, fromKey);
|
|
68
|
+
const followUp = takeChange(HELD_FOLLOW_UP_KEY, fromKey);
|
|
69
|
+
if (heldBack !== undefined)
|
|
70
|
+
saveChange(HELD_CHANGE_KEY, toKey, heldBack);
|
|
71
|
+
if (followUp !== undefined)
|
|
72
|
+
saveChange(HELD_FOLLOW_UP_KEY, toKey, followUp);
|
|
73
|
+
}
|
|
33
74
|
const ONE_FILE_TEXT = "Use the attached file.";
|
|
34
75
|
const MANY_FILES_TEXT = "Use the attached files.";
|
|
35
76
|
const NO_FILES = [];
|
|
@@ -116,31 +157,39 @@ export function useComposerDraft(input) {
|
|
|
116
157
|
dropChange(HELD_FOLLOW_UP_KEY, saveKey);
|
|
117
158
|
};
|
|
118
159
|
const persistKeyRef = React.useRef(persistKey);
|
|
160
|
+
const restoredQueueRef = React.useRef(undefined);
|
|
161
|
+
const fieldTextRef = React.useRef("");
|
|
119
162
|
const onQueueDroppedRef = React.useRef(composer.onQueueDropped);
|
|
120
163
|
React.useLayoutEffect(() => {
|
|
121
164
|
onQueueDroppedRef.current = composer.onQueueDropped;
|
|
122
165
|
});
|
|
123
166
|
React.useEffect(() => {
|
|
124
167
|
const appKey = resetKey;
|
|
168
|
+
const savingKey = () => (persistKeyRef.current === null ? null : carriedKey(persistKeyRef.current));
|
|
125
169
|
const keep = (cause) => {
|
|
126
|
-
const saveKey =
|
|
170
|
+
const saveKey = savingKey();
|
|
127
171
|
const heldText = heldTextRef.current;
|
|
128
172
|
if (heldText !== "" && saveKey !== null) {
|
|
129
173
|
saveChange(HELD_CHANGE_KEY, saveKey, heldText);
|
|
130
174
|
keepFollowUpMark(saveKey, heldText);
|
|
131
175
|
}
|
|
176
|
+
const restored = restoredQueueRef.current;
|
|
177
|
+
const stillShown = restored !== undefined && fieldTextRef.current.includes(restored) ? [restored] : [];
|
|
178
|
+
restoredQueueRef.current = undefined;
|
|
132
179
|
const pending = queuedRef.current;
|
|
133
|
-
if (pending.length === 0)
|
|
180
|
+
if (pending.length === 0 && stillShown.length === 0)
|
|
134
181
|
return;
|
|
135
182
|
queuedRef.current = [];
|
|
136
|
-
const
|
|
137
|
-
|
|
183
|
+
const words = [...stillShown, ...pending].join("\n");
|
|
184
|
+
const kept = saveKey !== null && saveChange(QUEUED_CHANGE_KEY, saveKey, words) ? "saved" : "lost";
|
|
185
|
+
if (pending.length > 0)
|
|
186
|
+
onQueueDroppedRef.current?.({ cause, messages: pending.length, kept });
|
|
138
187
|
};
|
|
139
188
|
const onPageHide = () => keep("unmount");
|
|
140
189
|
const onVisibilityChange = () => {
|
|
141
190
|
if (typeof document === "undefined" || document.visibilityState !== "hidden")
|
|
142
191
|
return;
|
|
143
|
-
const saveKey =
|
|
192
|
+
const saveKey = savingKey();
|
|
144
193
|
if (saveKey === null)
|
|
145
194
|
return;
|
|
146
195
|
const heldText = heldTextRef.current;
|
|
@@ -165,7 +214,7 @@ export function useComposerDraft(input) {
|
|
|
165
214
|
const copy = backgroundCopy.current;
|
|
166
215
|
if (copy.queued === undefined || queued.length > 0)
|
|
167
216
|
return;
|
|
168
|
-
|
|
217
|
+
dropCopy(QUEUED_CHANGE_KEY, copy.queued);
|
|
169
218
|
copy.queued = undefined;
|
|
170
219
|
}, [queued]);
|
|
171
220
|
const [restoringFilesFor, setRestoringFilesFor] = React.useState(null);
|
|
@@ -177,7 +226,9 @@ export function useComposerDraft(input) {
|
|
|
177
226
|
if (heldBack !== undefined && followUp !== undefined && followUp.trim() === heldBack.trim()) {
|
|
178
227
|
restoredHeld.current = heldBack.trim();
|
|
179
228
|
}
|
|
180
|
-
const
|
|
229
|
+
const queuedBack = takeChange(QUEUED_CHANGE_KEY, persistKey);
|
|
230
|
+
restoredQueueRef.current = isFirstBuildDraftKey(persistKey) ? queuedBack : undefined;
|
|
231
|
+
const saved = [queuedBack, heldBack].filter((t) => t !== undefined);
|
|
181
232
|
let live = true;
|
|
182
233
|
const restage = attachments.stage;
|
|
183
234
|
const store = heldAttachmentStore();
|
|
@@ -207,6 +258,9 @@ export function useComposerDraft(input) {
|
|
|
207
258
|
React.useEffect(() => {
|
|
208
259
|
queuedRef.current = queued;
|
|
209
260
|
}, [queued]);
|
|
261
|
+
React.useEffect(() => {
|
|
262
|
+
fieldTextRef.current = text;
|
|
263
|
+
}, [text]);
|
|
210
264
|
const holding = composer.hold !== undefined;
|
|
211
265
|
React.useEffect(() => {
|
|
212
266
|
heldTextRef.current = holding ? text.trim() : "";
|
|
@@ -215,8 +269,8 @@ export function useComposerDraft(input) {
|
|
|
215
269
|
const copy = backgroundCopy.current;
|
|
216
270
|
if (copy.held === undefined || holding)
|
|
217
271
|
return;
|
|
218
|
-
|
|
219
|
-
|
|
272
|
+
dropCopy(HELD_CHANGE_KEY, copy.held);
|
|
273
|
+
dropCopy(HELD_FOLLOW_UP_KEY, copy.held);
|
|
220
274
|
copy.held = undefined;
|
|
221
275
|
}, [holding]);
|
|
222
276
|
React.useEffect(() => {
|
|
@@ -7,13 +7,21 @@ function registeredApp() {
|
|
|
7
7
|
return undefined;
|
|
8
8
|
return { ownerHandle: app.ownerHandle, appSlug: app.appSlug, assetOrigin: app.assetOrigin };
|
|
9
9
|
}
|
|
10
|
+
let minterFor;
|
|
10
11
|
export function registeredLocalFileUrl() {
|
|
11
12
|
const app = registeredApp();
|
|
12
13
|
if (app === undefined)
|
|
13
14
|
return undefined;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const key = `${app.assetOrigin}\u0000${app.ownerHandle}\u0000${app.appSlug}`;
|
|
16
|
+
if (minterFor === undefined || minterFor.key !== key) {
|
|
17
|
+
minterFor = {
|
|
18
|
+
key,
|
|
19
|
+
mint: function mintLocalFileUrl(ref) {
|
|
20
|
+
return buildFilesUrl({ assetOrigin: app.assetOrigin, ownerHandle: app.ownerHandle, appSlug: app.appSlug, ...ref });
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return minterFor.mint;
|
|
17
25
|
}
|
|
18
26
|
let storeFor;
|
|
19
27
|
export function registeredPictureStore() {
|
|
@@ -26,6 +26,26 @@ function findPointerDoc(docs, handle) {
|
|
|
26
26
|
return undefined;
|
|
27
27
|
return docs.find((d) => d.type === "pointer" && d.authorHandle === handle);
|
|
28
28
|
}
|
|
29
|
+
function samePlainData(a, b) {
|
|
30
|
+
if (Object.is(a, b))
|
|
31
|
+
return true;
|
|
32
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null)
|
|
33
|
+
return false;
|
|
34
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
35
|
+
if (Array.isArray(a) === false || Array.isArray(b) === false || a.length !== b.length)
|
|
36
|
+
return false;
|
|
37
|
+
return a.every((v, i) => samePlainData(v, b[i]));
|
|
38
|
+
}
|
|
39
|
+
const plain = (o) => Object.getPrototypeOf(o) === Object.prototype || Object.getPrototypeOf(o) === null;
|
|
40
|
+
if (plain(a) === false || plain(b) === false)
|
|
41
|
+
return false;
|
|
42
|
+
const ra = a;
|
|
43
|
+
const rb = b;
|
|
44
|
+
const ka = Object.keys(ra);
|
|
45
|
+
if (ka.length !== Object.keys(rb).length)
|
|
46
|
+
return false;
|
|
47
|
+
return ka.every((k) => Object.prototype.hasOwnProperty.call(rb, k) && samePlainData(ra[k], rb[k]));
|
|
48
|
+
}
|
|
29
49
|
function withLocalPreviews(doc, previews) {
|
|
30
50
|
if (doc === null || previews.size === 0 || doc._files === undefined)
|
|
31
51
|
return doc;
|
|
@@ -534,7 +554,7 @@ export function useImgGen(opts) {
|
|
|
534
554
|
const inputIsStoredRef = incomingSourceKey !== undefined;
|
|
535
555
|
if (authoritative === false && !isRegen && (inputImage === undefined || inputIsStoredRef)) {
|
|
536
556
|
if (existingDoc)
|
|
537
|
-
setDocument(existingDoc);
|
|
557
|
+
setDocument((shown) => (samePlainData(shown, existingDoc) ? shown : existingDoc));
|
|
538
558
|
setPending(true);
|
|
539
559
|
if (confirmedMediaProbe === undefined || confirmedMediaProbe === null) {
|
|
540
560
|
if (readStartedPending === false && readPending() === false) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibes.diy/base",
|
|
3
|
-
"version": "14.3.
|
|
3
|
+
"version": "14.3.404",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@adviser/cement": "~0.5.37",
|
|
12
12
|
"@emotion/css": "~11.13.5",
|
|
13
|
-
"@vibes.diy/api-types": "14.3.
|
|
14
|
-
"@vibes.diy/use-vibes-types": "14.3.
|
|
15
|
-
"@vibes.diy/vibe-runtime": "14.3.
|
|
16
|
-
"@vibes.diy/vibe-types": "14.3.
|
|
13
|
+
"@vibes.diy/api-types": "14.3.404",
|
|
14
|
+
"@vibes.diy/use-vibes-types": "14.3.404",
|
|
15
|
+
"@vibes.diy/vibe-runtime": "14.3.404",
|
|
16
|
+
"@vibes.diy/vibe-types": "14.3.404",
|
|
17
17
|
"arktype": "~2.2.9",
|
|
18
|
-
"officeparser": "~8.
|
|
18
|
+
"officeparser": "~8.8.0",
|
|
19
19
|
"qrcode-generator": "~2.0.4",
|
|
20
20
|
"react": "~19.2.9"
|
|
21
21
|
},
|