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.

feat(workbench): Show Page share control + presentation toggle

cyh30bf724b059c
diff --git a/ui/src/components/workbench/ChatPage.tsx b/ui/src/components/workbench/ChatPage.tsx
index 28889be03..b94573f3f 100644
--- a/ui/src/components/workbench/ChatPage.tsx
+++ b/ui/src/components/workbench/ChatPage.tsx
@@ -1,7 +1,7 @@
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useLocation, useNavigate, useParams } from 'react-router-dom';
-import { AppWindow, ArrowLeft, Bell, Bot, ChevronDown, Clock, Info, Loader2, MessageSquare, Pencil, UploadCloud, X } from 'lucide-react';
+import { ArrowLeft, Bell, Bot, ChevronDown, Clock, Info, Loader2, MessageSquare, Pencil, Presentation, UploadCloud, X } from 'lucide-react';
import clsx from 'clsx';
import { useApi } from '../../context/ApiContext';
@@ -15,6 +15,7 @@ import { isProxyMediaUrl } from '../../lib/mediaProxy';
import { formatLocalDateTime } from '../../lib/relativeTime';
import { useFileDrop } from '../../lib/useFileDrop';
import { AgentRoutePicker } from './AgentRoutePicker';
+import { ShowPageShareControl } from './ShowPageShareControl';
import { InstallHint } from '../InstallHint';
import { Button } from '../ui/button';
import { ChatImage } from '../ui/chat-image';
@@ -1274,48 +1275,58 @@ const ChatHeaderBar: React.FC<ChatHeaderBarProps> = ({ session, agents, defaultA
<ArrowLeft className="size-3.5" />
</Button>
<TitleField key={session.id} title={session.title} onCommit={(title) => onPatch({ title })} />
- <AgentRoutePicker
- value={session}
- agents={agents}
- onChange={onPatch}
- disabled={pickerDisabled}
- allowedBackends={pinnedBackend ? [pinnedBackend] : undefined}
- defaultLabel={
- canClearToDefault
- ? defaultAgent
- ? t('newSession.defaultAgentNamed', { name: defaultAgent.name })
- : t('newSession.defaultAgent')
- : undefined
- }
- defaultRoute={defaultRoute}
- isDefaultRoute={inheritsDefault}
- compactMobile
- />
+ {/* Hidden while the Show Page is open so the view gets the full width. */}
+ {!showPageMode && (
+ <AgentRoutePicker
+ value={session}
+ agents={agents}
+ onChange={onPatch}
+ disabled={pickerDisabled}
+ allowedBackends={pinnedBackend ? [pinnedBackend] : undefined}
+ defaultLabel={
+ canClearToDefault
+ ? defaultAgent
+ ? t('newSession.defaultAgentNamed', { name: defaultAgent.name })
+ : t('newSession.defaultAgent')
+ : undefined
+ }
+ defaultRoute={defaultRoute}
+ isDefaultRoute={inheritsDefault}
+ compactMobile
+ />
+ )}
{/* Chat hides the brand header, so mount the install nudge here too —
IM-launched users often land straight in a chat. Renders only on iOS
Safari + not-installed; null otherwise. */}
<InstallHint />
- {/* Show Page toggle: swaps the chat surface for the session's Show Page
- (the header bar stays). First open initializes the page + prompts the
- agent. Pushed to the far right of the header row. */}
- <Button
- type="button"
- variant={showPageMode ? 'secondary' : 'ghost'}
- size="icon"
- onClick={onToggleShowPage}
- disabled={showPageBusy}
- aria-label={showPageMode ? t('chat.showPage.backToChat') : t('chat.showPage.open')}
- title={showPageMode ? t('chat.showPage.backToChat') : t('chat.showPage.open')}
- className="ml-auto size-7 shrink-0"
- >
- {showPageBusy ? (
- <Loader2 className="size-3.5 animate-spin" />
- ) : showPageMode ? (
- <MessageSquare className="size-3.5" />
- ) : (
- <AppWindow className="size-3.5" />
- )}
- </Button>
+ {/* Right-aligned actions. The Show Page toggle swaps the chat surface for
+ this session's Show Page (the header bar stays); first open initializes
+ the page + prompts the agent. It shows its label on desktop and stays
+ icon-only on mobile. In Show Page mode a Share control sits beside the
+ back-to-chat button. */}
+ <div className="ml-auto flex items-center gap-1.5">
+ {showPageMode && <ShowPageShareControl sessionId={session.id} />}
+ <Button
+ type="button"
+ variant={showPageMode ? 'secondary' : 'ghost'}
+ onClick={onToggleShowPage}
+ disabled={showPageBusy}
+ aria-label={showPageMode ? t('chat.showPage.backToChat') : t('chat.showPage.open')}
+ title={showPageMode ? t('chat.showPage.backToChat') : t('chat.showPage.open')}
+ className="h-7 shrink-0 gap-1.5 px-2"
+ >
+ {showPageBusy ? (
+ <Loader2 className="size-3.5 animate-spin" />
+ ) : showPageMode ? (
+ <MessageSquare className="size-3.5" />
+ ) : (
+ <Presentation className="size-3.5" />
+ )}
+ <span className="hidden text-xs font-medium md:inline">
+ {showPageMode ? t('chat.showPage.backToChat') : t('chat.showPage.open')}
+ </span>
+ </Button>
+ </div>
</div>
</div>
);
diff --git a/ui/src/components/workbench/ShowPageShareControl.tsx b/ui/src/components/workbench/ShowPageShareControl.tsx
new file mode 100644
index 000000000..25e7ec10c
--- /dev/null
+++ b/ui/src/components/workbench/ShowPageShareControl.tsx
@@ -0,0 +1,172 @@
+import React, { useState } from 'react';
+import { useTranslation } from 'react-i18next';
+import { Check, Copy, Loader2, Share2 } from 'lucide-react';
+
+import { Button } from '../ui/button';
+import { Input } from '../ui/input';
+import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover';
+import { Switch } from '../ui/switch';
+import { useApi } from '../../context/ApiContext';
+
+type ShowPagePayload = {
+ visibility: string;
+ active_url: string | null;
+ public_url: string | null;
+ private_url: string | null;
+ url_available: boolean;
+ url_guidance: string | null;
+ share_id: string | null;
+};
+
+// 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 }) => {
+ const { t } = useTranslation();
+ const api = useApi();
+ const [open, setOpen] = useState(false);
+ const [payload, setPayload] = useState<ShowPagePayload | null>(null);
+ const [loading, setLoading] = useState(false);
+ const [busy, setBusy] = useState(false);
+ const [copied, setCopied] = useState(false);
+
+ const isPublic = payload?.visibility === 'public';
+ const link = payload?.active_url ?? payload?.private_url ?? '';
+ const canNativeShare = typeof navigator !== 'undefined' && typeof navigator.share === 'function';
+
+ 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));
+ }
+ };
+
+ const toggleVisibility = (nextPublic: boolean) => {
+ setBusy(true);
+ api
+ .setShowPageVisibility(sessionId, nextPublic ? 'public' : 'private')
+ .then((res: ShowPagePayload) => setPayload(res))
+ .catch(() => undefined)
+ .finally(() => setBusy(false));
+ };
+
+ const 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 (!ok) return;
+ setCopied(true);
+ window.setTimeout(() => setCopied(false), 2000);
+ };
+
+ const nativeShare = async () => {
+ if (!link) return;
+ try {
+ await navigator.share({ title: t('chat.showPage.title'), url: link });
+ } catch {
+ // user dismissed the share sheet, or it is unavailable — no-op
+ }
+ };
+
+ return (
+ <Popover open={open} onOpenChange={handleOpenChange}>
+ <PopoverTrigger asChild>
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon"
+ className="size-7 shrink-0"
+ aria-label={t('chat.showPage.share')}
+ title={t('chat.showPage.share')}
+ >
+ <Share2 className="size-3.5" />
+ </Button>
+ </PopoverTrigger>
+ <PopoverContent align="end" className="w-80 space-y-3">
+ <div className="text-sm font-medium">{t('chat.showPage.shareTitle')}</div>
+
+ {loading ? (
+ <div className="flex items-center gap-2 py-2 text-sm text-muted">
+ <Loader2 className="size-4 animate-spin" />
+ {t('common.loading')}
+ </div>
+ ) : (
+ <>
+ <div className="flex items-center gap-1.5">
+ <Input
+ id="show-share-link"
+ readOnly
+ value={link}
+ onFocus={(e) => e.currentTarget.select()}
+ className="h-8 flex-1 text-xs"
+ />
+ <Button
+ type="button"
+ variant="outline"
+ size="icon"
+ className="size-8 shrink-0"
+ onClick={copyLink}
+ aria-label={t('chat.showPage.copyLink')}
+ title={t('chat.showPage.copyLink')}
+ >
+ {copied ? <Check className="size-3.5" /> : <Copy className="size-3.5" />}
+ </Button>
+ {canNativeShare && (
+ <Button
+ type="button"
+ variant="outline"
+ size="icon"
+ className="size-8 shrink-0"
+ onClick={nativeShare}
+ aria-label={t('chat.showPage.nativeShare')}
+ title={t('chat.showPage.nativeShare')}
+ >
+ <Share2 className="size-3.5" />
+ </Button>
+ )}
+ </div>
+
+ <div className="flex items-center justify-between gap-3">
+ <div className="min-w-0">
+ <div className="text-sm">
+ {isPublic ? t('chat.showPage.visibilityPublic') : t('chat.showPage.visibilityPrivate')}
+ </div>
+ <div className="text-xs text-muted">
+ {isPublic ? t('chat.showPage.publicDesc') : t('chat.showPage.privateDesc')}
+ </div>
+ </div>
+ <Switch
+ checked={isPublic}
+ disabled={busy}
+ onCheckedChange={toggleVisibility}
+ label={t('chat.showPage.visibilityPublic')}
+ />
+ </div>
+
+ {isPublic && payload && !payload.url_available && payload.url_guidance && (
+ <div className="rounded-md border border-border px-2.5 py-2 text-xs text-muted">
+ {payload.url_guidance}
+ </div>
+ )}
+ </>
+ )}
+ </PopoverContent>
+ </Popover>
+ );
+};
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index 75e1a002e..3173c8380 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -1759,10 +1759,18 @@
"back": "Back",
"untitled": "Untitled session",
"showPage": {
- "open": "View Show Page",
+ "open": "Visualize",
"backToChat": "Back to chat",
"title": "Show Page",
- "prompt": "Please visualize this session as a Show Page."
+ "prompt": "Please visualize this session as a Show Page.",
+ "share": "Share",
+ "shareTitle": "Share this Show Page",
+ "copyLink": "Copy link",
+ "nativeShare": "Share…",
+ "visibilityPublic": "Public",
+ "visibilityPrivate": "Private",
+ "publicDesc": "Anyone with the link can view",
+ "privateDesc": "Only you can view"
},
"titlePlaceholder": "Session title",
"pickAgent": "Pick an agent",
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index 59d1a61a7..35cf98dc3 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -1758,10 +1758,18 @@
"back": "返回",
"untitled": "未命名会话",
"showPage": {
- "open": "查看 Show Page",
- "backToChat": "返回对话",
+ "open": "可视化",
+ "backToChat": "回聊天",
"title": "Show Page",
- "prompt": "Please visualize this session as a Show Page."
+ "prompt": "Please visualize this session as a Show Page.",
+ "share": "分享",
+ "shareTitle": "分享这个 Show Page",
+ "copyLink": "复制链接",
+ "nativeShare": "系统分享",
+ "visibilityPublic": "公开",
+ "visibilityPrivate": "私有",
+ "publicDesc": "任何人都可以通过链接查看",
+ "privateDesc": "只有你能查看"
},
"titlePlaceholder": "会话标题",
"pickAgent": "选择 Agent",