Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(workbench): guard stale show-page share refreshes

cyhcfdd48a09cbf
diff --git a/ui/src/components/workbench/ShowPageShareControl.tsx b/ui/src/components/workbench/ShowPageShareControl.tsx
index 6a4aef3e6..cd78e5531 100644
--- a/ui/src/components/workbench/ShowPageShareControl.tsx
+++ b/ui/src/components/workbench/ShowPageShareControl.tsx
@@ -1,4 +1,4 @@
-import React, { useEffect, useState } from 'react';
+import React, { useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Check, Copy, Loader2, Share2 } from 'lucide-react';
@@ -32,6 +32,9 @@ export const ShowPageShareControl: React.FC<{
const [loading, setLoading] = useState(false);
const [busy, setBusy] = useState(false);
const [copied, setCopied] = useState(false);
+ // Monotonic guard: a slow ensure() must not overwrite a newer visibility
+ // result (or a link rotated elsewhere). Only the latest request applies.
+ const reqSeq = useRef(0);
useEffect(() => {
if (payload) onPayloadChange?.(payload);
@@ -48,12 +51,17 @@ export const ShowPageShareControl: React.FC<{
// admin Show Pages page) is reflected; keep the last payload visible while
// refreshing so reopening doesn't flash a spinner.
const refresh = () => {
+ const seq = ++reqSeq.current;
setLoading(!payload);
api
.ensureShowPage(sessionId)
- .then((res: ShowPagePayload) => setPayload(res))
+ .then((res: ShowPagePayload) => {
+ if (seq === reqSeq.current) setPayload(res);
+ })
.catch(() => undefined)
- .finally(() => setLoading(false));
+ .finally(() => {
+ if (seq === reqSeq.current) setLoading(false);
+ });
};
const handleOpenChange = (next: boolean) => {
@@ -62,12 +70,17 @@ export const ShowPageShareControl: React.FC<{
};
const toggleVisibility = (nextPublic: boolean) => {
+ const seq = ++reqSeq.current;
setBusy(true);
api
.setShowPageVisibility(sessionId, nextPublic ? 'public' : 'private')
- .then((res: ShowPagePayload) => setPayload(res))
+ .then((res: ShowPagePayload) => {
+ if (seq === reqSeq.current) setPayload(res);
+ })
.catch(() => undefined)
- .finally(() => setBusy(false));
+ .finally(() => {
+ if (seq === reqSeq.current) setBusy(false);
+ });
};
const copyLink = async () => {