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.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(workbench): address Codex review on Show Page share
cyh66eb55111b8d
diff --git a/ui/src/components/ShowPagesPage.tsx b/ui/src/components/ShowPagesPage.tsxindex 454b0db8c..735547c98 100644--- a/ui/src/components/ShowPagesPage.tsx+++ b/ui/src/components/ShowPagesPage.tsx@@ -21,6 +21,7 @@ import clsx from 'clsx';import { useApi } from '../context/ApiContext';import { useToast } from '../context/ToastContext';import { copyTextToClipboard } from '../lib/utils';+import { copyHref, displayLink } from '../lib/showPageLinks';import { SearchField } from './settings/SettingsPrimitives';import { Button } from './ui/button';import { Badge } from './ui/badge';@@ -58,28 +59,6 @@ const STATUS: Record<offline: { Icon: CloudOff, badge: 'secondary', tone: 'muted', dot: 'bg-muted', tile: 'border-border-strong bg-foreground/[0.04]', iconColor: 'text-muted' },};-// Same-origin path a Show Page is served at locally — usable even when Avibe-// Cloud is off, where the cloud-qualified urls in the payload are null.-function localPath(page: ShowPage): string | null {- if (page.visibility === 'private') return `/show/${encodeURIComponent(page.session_id)}/`;- if (page.visibility === 'public' && page.share_id) return `/p/${encodeURIComponent(page.share_id)}/`;- return null;-}--function liveHref(page: ShowPage): string | null {- return page.active_url || localPath(page);-}--function copyHref(page: ShowPage): string | null {- const href = liveHref(page);- if (!href) return null;- return href.startsWith('http') ? href : window.location.origin + href;-}--function displayLink(page: ShowPage): string | null {- const href = liveHref(page);- return href ? href.replace(/^https?:\/\//, '') : null;-}interface RowProps {page: ShowPage;diff --git a/ui/src/components/workbench/ChatPage.tsx b/ui/src/components/workbench/ChatPage.tsxindex b94573f3f..c588be73d 100644--- a/ui/src/components/workbench/ChatPage.tsx+++ b/ui/src/components/workbench/ChatPage.tsx@@ -12,6 +12,7 @@ import { apiFetch } from '../../lib/apiFetch';import { normalizeChatMessageFontSize } from '../../lib/chatDisplay';import { useIosKeyboardInset } from '../../lib/useIosKeyboardInset';import { isProxyMediaUrl } from '../../lib/mediaProxy';+import { localPath, type ShowPageLinkInfo } from '../../lib/showPageLinks';import { formatLocalDateTime } from '../../lib/relativeTime';import { useFileDrop } from '../../lib/useFileDrop';import { AgentRoutePicker } from './AgentRoutePicker';@@ -791,6 +792,14 @@ export const ChatPage: React.FC = () => {}}, [sessionId, showPageMode, api, sendMessage, t]);+ // When the share control resolves the page (open) or flips its visibility, the+ // serving route changes (private → /show/, public → /p/). Re-point the iframe+ // so it never stays on a route that now 404s.+ const handleShowPagePayload = useCallback((next: ShowPageLinkInfo) => {+ const path = localPath(next);+ if (path) setShowPageUrl(path);+ }, []);+// A quick-reply click sends the chosen label as a normal user turn, tagged with// the agent message it answers so the group can lock + highlight the choice on// reload (the answered state is derived from this metadata).@@ -1045,6 +1054,7 @@ export const ChatPage: React.FC = () => {showPageMode={showPageMode}showPageBusy={showPageBusy}onToggleShowPage={toggleShowPage}+ onShowPageVisibilityChange={handleShowPagePayload}/>{showPageMode && showPageUrl && (@@ -1223,9 +1233,10 @@ interface ChatHeaderBarProps {showPageMode: boolean;showPageBusy: boolean;onToggleShowPage: () => void;+ onShowPageVisibilityChange?: (payload: ShowPageLinkInfo) => void;}-const ChatHeaderBar: React.FC<ChatHeaderBarProps> = ({ session, agents, defaultAgentName, onPatch, onBack, working, showPageMode, showPageBusy, onToggleShowPage }) => {+const ChatHeaderBar: React.FC<ChatHeaderBarProps> = ({ session, agents, defaultAgentName, onPatch, onBack, working, showPageMode, showPageBusy, onToggleShowPage, onShowPageVisibilityChange }) => {const { t } = useTranslation();const defaultAgent = defaultAgentName ? agents.find((agent) => agent.name === defaultAgentName) : null;// Backend locks once a NATIVE conversation exists — a native can only be@@ -1304,8 +1315,9 @@ const ChatHeaderBar: React.FC<ChatHeaderBarProps> = ({ session, agents, defaultAthe page + prompts the agent. It shows its label on desktop and staysicon-only on mobile. In Show Page mode a Share control sits beside theback-to-chat button. */}+ {/* Back-to-chat (or Visualize when in chat) stays leftmost; the Share+ control sits to its right, only while the Show Page is open. */}<div className="ml-auto flex items-center gap-1.5">- {showPageMode && <ShowPageShareControl sessionId={session.id} />}<Buttontype="button"variant={showPageMode ? 'secondary' : 'ghost'}@@ -1326,6 +1338,9 @@ const ChatHeaderBar: React.FC<ChatHeaderBarProps> = ({ session, agents, defaultA{showPageMode ? t('chat.showPage.backToChat') : t('chat.showPage.open')}</span></Button>+ {showPageMode && (+ <ShowPageShareControl sessionId={session.id} onPayloadChange={onShowPageVisibilityChange} />+ )}</div></div></div>diff --git a/ui/src/components/workbench/ShowPageShareControl.tsx b/ui/src/components/workbench/ShowPageShareControl.tsxindex 25e7ec10c..6a4aef3e6 100644--- a/ui/src/components/workbench/ShowPageShareControl.tsx+++ b/ui/src/components/workbench/ShowPageShareControl.tsx@@ -1,4 +1,4 @@-import React, { useState } from 'react';+import React, { useEffect, useState } from 'react';import { useTranslation } from 'react-i18next';import { Check, Copy, Loader2, Share2 } from 'lucide-react';@@ -7,21 +7,24 @@ import { Input } from '../ui/input';import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover';import { Switch } from '../ui/switch';import { useApi } from '../../context/ApiContext';+import { copyTextToClipboard } from '../../lib/utils';+import { copyHref, displayLink, type ShowPageLinkInfo } from '../../lib/showPageLinks';-type ShowPagePayload = {- visibility: string;- active_url: string | null;- public_url: string | null;- private_url: string | null;+type ShowPagePayload = ShowPageLinkInfo & {url_available: boolean;url_guidance: string | null;- share_id: string | null;+ offline: boolean;};// Share affordance shown only while the Show Page is open (the in-chat view).// A popover with the page link (copy + native share) and a public/private// toggle that flips visibility in place via the existing show-pages API.-export const ShowPageShareControl: React.FC<{ sessionId: string }> = ({ sessionId }) => {+export const ShowPageShareControl: React.FC<{+ sessionId: string;+ // Lets the chat view re-point the iframe at the route that now serves the+ // page when visibility flips (private↔public swap the serving route).+ onPayloadChange?: (payload: ShowPageLinkInfo) => void;+}> = ({ sessionId, onPayloadChange }) => {const { t } = useTranslation();const api = useApi();const [open, setOpen] = useState(false);@@ -30,22 +33,32 @@ export const ShowPageShareControl: React.FC<{ sessionId: string }> = ({ sessionIconst [busy, setBusy] = useState(false);const [copied, setCopied] = useState(false);+ useEffect(() => {+ if (payload) onPayloadChange?.(payload);+ }, [payload, onPayloadChange]);++ const offline = payload?.visibility === 'offline' || payload?.offline === true;const isPublic = payload?.visibility === 'public';- const link = payload?.active_url ?? payload?.private_url ?? '';+ // Falls back to the same-origin route when Avibe Cloud is off (payload urls null).+ const link = payload ? copyHref(payload) ?? '' : '';+ const shownLink = payload ? displayLink(payload) ?? '' : '';const canNativeShare = typeof navigator !== 'undefined' && typeof navigator.share === 'function';+ // Re-fetch on every open so a visibility/share change made elsewhere (e.g. the+ // admin Show Pages page) is reflected; keep the last payload visible while+ // refreshing so reopening doesn't flash a spinner.+ const refresh = () => {+ setLoading(!payload);+ api+ .ensureShowPage(sessionId)+ .then((res: ShowPagePayload) => setPayload(res))+ .catch(() => undefined)+ .finally(() => setLoading(false));+ };+const handleOpenChange = (next: boolean) => {setOpen(next);- // Lazily resolve the page (idempotent ensure) the first time the popover- // opens, so the link + current visibility are always fresh.- if (next && !payload && !loading) {- setLoading(true);- api- .ensureShowPage(sessionId)- .then((res: ShowPagePayload) => setPayload(res))- .catch(() => undefined)- .finally(() => setLoading(false));- }+ if (next) refresh();};const toggleVisibility = (nextPublic: boolean) => {@@ -59,20 +72,10 @@ export const ShowPageShareControl: React.FC<{ sessionId: string }> = ({ sessionIconst copyLink = async () => {if (!link) return;- let ok = false;- try {- await navigator.clipboard.writeText(link);- ok = true;- } catch {- const field = document.getElementById('show-share-link');- if (field instanceof HTMLInputElement) {- field.select();- ok = document.execCommand('copy');- }+ if (await copyTextToClipboard(link)) {+ setCopied(true);+ window.setTimeout(() => setCopied(false), 2000);}- if (!ok) return;- setCopied(true);- window.setTimeout(() => setCopied(false), 2000);};const nativeShare = async () => {@@ -106,13 +109,15 @@ export const ShowPageShareControl: React.FC<{ sessionId: string }> = ({ sessionI<Loader2 className="size-4 animate-spin" />{t('common.loading')}</div>+ ) : offline ? (+ <p className="py-1 text-sm text-muted">{t('chat.showPage.offlineNote')}</p>) : (<><div className="flex items-center gap-1.5"><Inputid="show-share-link"readOnly- value={link}+ value={shownLink}onFocus={(e) => e.currentTarget.select()}className="h-8 flex-1 text-xs"/>@@ -121,6 +126,7 @@ export const ShowPageShareControl: React.FC<{ sessionId: string }> = ({ sessionIvariant="outline"size="icon"className="size-8 shrink-0"+ disabled={!link}onClick={copyLink}aria-label={t('chat.showPage.copyLink')}title={t('chat.showPage.copyLink')}@@ -133,6 +139,7 @@ export const ShowPageShareControl: React.FC<{ sessionId: string }> = ({ sessionIvariant="outline"size="icon"className="size-8 shrink-0"+ disabled={!link}onClick={nativeShare}aria-label={t('chat.showPage.nativeShare')}title={t('chat.showPage.nativeShare')}diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.jsonindex 3173c8380..aeacd8979 100644--- a/ui/src/i18n/en.json+++ b/ui/src/i18n/en.json@@ -1770,7 +1770,8 @@"visibilityPublic": "Public","visibilityPrivate": "Private","publicDesc": "Anyone with the link can view",- "privateDesc": "Only you can view"+ "privateDesc": "Only you can view",+ "offlineNote": "This Show Page is offline and can't be shared right now."},"titlePlaceholder": "Session title","pickAgent": "Pick an agent",diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.jsonindex 35cf98dc3..782851579 100644--- a/ui/src/i18n/zh.json+++ b/ui/src/i18n/zh.json@@ -1769,7 +1769,8 @@"visibilityPublic": "公开","visibilityPrivate": "私有","publicDesc": "任何人都可以通过链接查看",- "privateDesc": "只有你能查看"+ "privateDesc": "只有你能查看",+ "offlineNote": "这个 Show Page 已离线,暂时无法分享。"},"titlePlaceholder": "会话标题","pickAgent": "选择 Agent",diff --git a/ui/src/lib/showPageLinks.ts b/ui/src/lib/showPageLinks.tsnew file mode 100644index 000000000..64146b3d3--- /dev/null+++ b/ui/src/lib/showPageLinks.ts@@ -0,0 +1,36 @@+// Show Page link helpers shared by the admin Show Pages list and the in-chat+// share control. Avibe Cloud-qualified urls in the payload are null on a local+// install (no remote access configured), so fall back to the same-origin route+// the page is actually served at locally.++export type ShowPageLinkInfo = {+ session_id: string;+ visibility: string;+ active_url: string | null;+ share_id: string | null;+};++// Same-origin path a Show Page is served at locally. Null when the page is+// offline (or public without a share id), where there is no live route.+export function localPath(page: ShowPageLinkInfo): string | null {+ if (page.visibility === 'private') return `/show/${encodeURIComponent(page.session_id)}/`;+ if (page.visibility === 'public' && page.share_id) return `/p/${encodeURIComponent(page.share_id)}/`;+ return null;+}++export function liveHref(page: ShowPageLinkInfo): string | null {+ return page.active_url || localPath(page);+}++// Absolute, copyable/shareable href (origin-qualifies the same-origin fallback).+export function copyHref(page: ShowPageLinkInfo): string | null {+ const href = liveHref(page);+ if (!href) return null;+ return href.startsWith('http') ? href : window.location.origin + href;+}++// Protocol-stripped form for compact display.+export function displayLink(page: ShowPageLinkInfo): string | null {+ const href = liveHref(page);+ return href ? href.replace(/^https?:\/\//, '') : null;+}