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(show): simplify share access controls (#1525)
Call White0aabf0d10863
diff --git a/ui/src/components/ShowPagesPage.test.tsx b/ui/src/components/ShowPagesPage.test.tsxnew file mode 100644index 000000000..e85cfde9d--- /dev/null+++ b/ui/src/components/ShowPagesPage.test.tsx@@ -0,0 +1,108 @@+/** @vitest-environment jsdom */+import { createInstance } from 'i18next';+import { cleanup, fireEvent, render, screen } from '@testing-library/react';+import { I18nextProvider, initReactI18next } from 'react-i18next';+import { MemoryRouter } from 'react-router-dom';+import { afterEach, describe, expect, it, vi } from 'vitest';++import en from '../i18n/en.json';+import type { ShowPage } from '../lib/showPagesStore';+import { ShowPagesView } from './ShowPagesPage';++vi.mock('../context/DockContext', () => ({+ useDock: () => ({+ isPinned: () => false,+ pin: vi.fn(),+ unpin: vi.fn(),+ }),+}));++vi.mock('../context/WindowManagerContext', () => ({+ useWindowManager: () => ({+ windows: [],+ setParams: vi.fn(),+ setTitle: vi.fn(),+ }),+}));++vi.mock('./workbench/ShowPageSharingSettings', () => ({+ ShowPageSharingSettings: () => null,+}));++const i18n = createInstance();+void i18n.use(initReactI18next).init({+ lng: 'en',+ fallbackLng: 'en',+ resources: { en: { translation: en } },+ interpolation: { escapeValue: false },+});++const page = (offline: boolean): ShowPage => ({+ session_id: 'ses-1',+ visibility: offline ? 'offline' : 'private',+ access_mode: 'private',+ access_revision: 0,+ can_manage: true,+ can_publish_public: true,+ title: 'Demo page',+ platform: 'web',+ agent: 'codex',+ path: '/tmp/show/ses-1',+ icon_version: null,+ active_url: offline ? null : '/show/ses-1/',+ private_url: '/show/ses-1/',+ public_url: null,+ url_available: true,+ share_id: 'stable-link',+ offline,+ offline_at: offline ? '2026-08-18T00:00:00Z' : null,+ created_at: '2026-08-17T00:00:00Z',+ updated_at: '2026-08-18T00:00:00Z',+});++const renderView = (offline: boolean, setOffline: ReturnType<typeof vi.fn>) => render(+ <MemoryRouter>+ <I18nextProvider i18n={i18n}>+ <ShowPagesView+ pages={[page(offline)]}+ loading={false}+ loaded+ busyId={null}+ setOffline={setOffline}+ rename={vi.fn()}+ uploadIcon={vi.fn()}+ reload={vi.fn()}+ />+ </I18nextProvider>+ </MemoryRouter>,+);++afterEach(cleanup);++describe('ShowPagesView availability control', () => {+ it('treats an enabled switch as online and turning it off as going offline', () => {+ const setOffline = vi.fn();+ renderView(false, setOffline);+ fireEvent.click(screen.getByRole('button', { name: 'Details' }));++ const toggle = screen.getByRole('switch', { name: 'Page online' });+ expect(toggle.getAttribute('aria-checked')).toBe('true');+ expect(screen.getByText('This page is online. Turn it off to stop serving it.')).toBeTruthy();+ fireEvent.click(toggle);++ expect(setOffline).toHaveBeenCalledWith(page(false), true);+ });++ it('treats a disabled switch as offline and turning it on as restoring access', () => {+ const setOffline = vi.fn();+ renderView(true, setOffline);+ fireEvent.click(screen.getByRole('button', { name: 'Details' }));++ const toggle = screen.getByRole('switch', { name: 'Page online' });+ expect(toggle.getAttribute('aria-checked')).toBe('false');+ expect(screen.getByText('This page is offline. Turn it on to restore access.')).toBeTruthy();+ fireEvent.click(toggle);++ expect(setOffline).toHaveBeenCalledWith(page(true), false);+ });+});diff --git a/ui/src/components/ShowPagesPage.tsx b/ui/src/components/ShowPagesPage.tsxindex 2b090fe66..ed7ff09a1 100644--- a/ui/src/components/ShowPagesPage.tsx+++ b/ui/src/components/ShowPagesPage.tsx@@ -221,10 +221,10 @@ function ShowPageRow({</p></div><Switch- checked={page.offline}+ checked={!page.offline}disabled={busy || (page.offline ? !page.can_publish_public : !page.can_manage)}- onCheckedChange={onSetOffline}- label={t('chat.showPage.offline')}+ onCheckedChange={(online) => onSetOffline(!online)}+ label={t('chat.showPage.availability')}/></div>@@ -241,11 +241,6 @@ function ShowPageRow({{page.visibility === 'offline' ? (<p className="text-[12px] text-muted">{t('showPages.offlineNoLink')}</p>- ) : page.visibility === 'limited' ? (- <div className="flex items-start gap-2 text-[12px] text-muted">- <TriangleAlert size={14} className="mt-0.5 shrink-0 text-gold-ink" />- <span>{t('chat.showPage.sharingHelp.limited')}</span>- </div>) : (<div className="flex flex-col gap-2"><span className={LABEL}>{t('showPages.liveLink')}</span>diff --git a/ui/src/components/workbench/ShowPageShareControl.test.tsx b/ui/src/components/workbench/ShowPageShareControl.test.tsxindex c55b9f7ac..b62d00a42 100644--- a/ui/src/components/workbench/ShowPageShareControl.test.tsx+++ b/ui/src/components/workbench/ShowPageShareControl.test.tsx@@ -205,7 +205,7 @@ describe('ShowPageShareControl payload sequencing without prior access', () => {});});- it('does not present a Limited shared link before guest admission exists', async () => {+ it('presents the Limited guest-admission link', async () => {api.getShowPageAccess.mockResolvedValue({ok: true,mode: 'local',@@ -216,7 +216,8 @@ describe('ShowPageShareControl payload sequencing without prior access', () => {api.ensureShowPage.mockResolvedValue({session_id: 'ses-1',visibility: 'limited',- active_url: '/p/stable-link/',+ active_url: null,+ public_url: 'https://alice.avibe.bot/p/stable-link/',share_id: 'stable-link',url_available: true,offline: false,@@ -230,11 +231,82 @@ describe('ShowPageShareControl payload sequencing without prior access', () => {);fireEvent.click(screen.getByRole('button', { name: 'Share' }));- expect(await screen.findByText(- 'Configure the email audience now; the shared link is not active yet.',- )).toBeTruthy();- expect(screen.queryByRole('button', { name: 'Copy link' })).toBeNull();- expect(screen.queryByDisplayValue('/p/stable-link/')).toBeNull();+ expect(await screen.findByDisplayValue('https://alice.avibe.bot/p/stable-link/')).toBeTruthy();+ expect(screen.getByRole('button', { name: 'Copy link' })).toBeTruthy();+ });++ it('keeps the Limited share action disabled without Cloud identity', async () => {+ api.getShowPageAccess.mockResolvedValue({+ ok: true,+ mode: 'local',+ can_use: true,+ can_manage: false,+ can_publish_public: false,+ });+ api.ensureShowPage.mockResolvedValue({+ session_id: 'ses-1',+ visibility: 'limited',+ active_url: null,+ public_url: null,+ share_id: 'stable-link',+ url_available: false,+ offline: false,+ title: null,+ });++ render(+ <I18nextProvider i18n={i18n}>+ <ShowPageShareControl sessionId="ses-1" />+ </I18nextProvider>,+ );+ fireEvent.click(screen.getByRole('button', { name: 'Share' }));++ await waitFor(() => expect(api.ensureShowPage).toHaveBeenCalledWith('ses-1'));+ expect((screen.getByRole('button', { name: 'Copy link' }) as HTMLButtonElement).disabled).toBe(+ true,+ );+ expect(screen.queryByDisplayValue(/\/p\/stable-link\/$/)).toBeNull();+ });++ it('keeps online state and Workspace access out of the share popover', async () => {+ api.getShowPageAccess.mockResolvedValue({+ ok: true,+ mode: 'local',+ can_use: true,+ can_manage: true,+ can_publish_public: true,+ });+ api.ensureShowPage.mockResolvedValue({+ session_id: 'ses-1',+ visibility: 'private',+ active_url: '/show/ses-1/',+ share_id: 'stable-link',+ url_available: true,+ offline: false,+ title: null,+ });+ api.getShowAccessSettings.mockResolvedValue({+ show_access: {+ page_id: 'ses-1',+ access_mode: 'private',+ share_id: 'stable-link',+ revision: 0,+ normalized_emails: [],+ },+ });++ render(+ <I18nextProvider i18n={i18n}>+ <ShowPageShareControl sessionId="ses-1" canManageInstance />+ </I18nextProvider>,+ );+ fireEvent.click(screen.getByRole('button', { name: 'Share' }));++ expect(await screen.findByRole('button', { name: 'Access: Private' })).toBeTruthy();+ expect(screen.queryByText('Workspace access')).toBeNull();+ expect(screen.queryByText('Page online')).toBeNull();+ expect(screen.queryByRole('textbox', { name: 'Custom link' })).toBeNull();+ expect(api.setShowPageAvailability).not.toHaveBeenCalled();});it('shows the loading state while a first access read is pending', async () => {diff --git a/ui/src/components/workbench/ShowPageShareControl.tsx b/ui/src/components/workbench/ShowPageShareControl.tsxindex 3561c2aee..6d1d879c4 100644--- a/ui/src/components/workbench/ShowPageShareControl.tsx+++ b/ui/src/components/workbench/ShowPageShareControl.tsx@@ -15,7 +15,6 @@ import { copyHref, type ShowPageLinkInfo } from '../../lib/showPageLinks';import { copyTextToClipboard } from '../../lib/utils';import { useShowPageInventory, type ShowPage } from '../useShowPages';import { ShowPageSharingSettings } from './ShowPageSharingSettings';-import { ShowPageWorkspaceAccessControl } from './ShowPageWorkspaceAccessControl';type ShowPagePayload = ShowPageLinkInfo & {url_available: boolean;@@ -47,13 +46,11 @@ export const ShowPageShareControl: React.FC<{const { pages, mergePage, reload } = useShowPageInventory();const inventoryPage = pages.find((page) => page.session_id === sessionId);const [open, setOpen] = useState(false);- const [confirmationOpen, setConfirmationOpen] = useState(false);const [localPayload, setLocalPayload] = useState<ShowPagePayload | null>(null);const [loading, setLoading] = useState(false);const [accessLoading, setAccessLoading] = useState(false);const [access, setAccess] = useState<ShowPageAccess | null>(initialAccess);const [accessError, setAccessError] = useState(false);- const [availabilityBusy, setAvailabilityBusy] = useState(false);const [copied, setCopied] = useState(false);const reqSeq = useRef(0);const hasObservedPayloadRef = useRef(false);@@ -167,7 +164,6 @@ export const ShowPageShareControl: React.FC<{const handleOpenChange = (next: boolean) => {setOpen(next);- if (!next) setConfirmationOpen(false);onOpenChange?.(next);if (next) refresh();};@@ -176,19 +172,6 @@ export const ShowPageShareControl: React.FC<{void reloadPayload();};- const setOffline = (next: boolean) => {- if (!payload || availabilityBusy) return;- setAvailabilityBusy(true);- void api.setShowPageAvailability(sessionId, next)- .then((result) => {- if (result && result.session_id === sessionId) applyPayload(result as ShowPagePayload);- else reload();- reqSeq.current += 1;- })- .catch(() => undefined)- .finally(() => setAvailabilityBusy(false));- };-const copyLink = async () => {if (!link) return;if (await copyTextToClipboard(link)) {@@ -223,11 +206,8 @@ export const ShowPageShareControl: React.FC<{</PopoverTrigger><PopoverContentalign="end"- className="w-[min(22rem,calc(100vw-1rem))] space-y-3"+ className="w-[min(27rem,calc(100vw-1rem))] space-y-3"data-window-owner-id={ownerWindowId}- onInteractOutside={(event) => {- if (confirmationOpen) event.preventDefault();- }}><div className="text-sm font-medium">{t('chat.showPage.shareTitle')}</div>@@ -240,7 +220,7 @@ export const ShowPageShareControl: React.FC<{<p className="py-1 text-sm text-muted">{t('chat.showPage.loadError')}</p>) : null}- {payload && !offline && payload.visibility !== 'limited' ? (+ {payload && !offline ? (<div className="flex items-center gap-1.5"><Inputid="show-share-link"@@ -276,12 +256,6 @@ export const ShowPageShareControl: React.FC<{</div>) : null}- {payload && !offline && payload.visibility === 'limited' ? (- <p className="text-[11px] leading-snug text-muted">- {t('chat.showPage.sharingHelp.limited')}- </p>- ) : null}-{access?.can_publish_public ? (<div className="border-t border-border pt-3"><ShowPageSharingSettings@@ -289,44 +263,16 @@ export const ShowPageShareControl: React.FC<{canManagesessionId={sessionId}onApplied={handleShowAccessApplied}- onConfirmationOpenChange={setConfirmationOpen}ownerWindowId={ownerWindowId}+ showCustomLink={false}/></div>) : null}- <div className="border-t border-border pt-3">- <ShowPageWorkspaceAccessControl- access={access}- active={open}- sessionId={sessionId}- onConfirmationOpenChange={setConfirmationOpen}- ownerWindowId={ownerWindowId}- />- {accessError ? (- <p className="mt-2 text-[11px] leading-snug text-destructive-ink">- {t('chat.showPage.accessLoadError')}- </p>- ) : null}- </div>-- {payload ? (- <div className="border-t border-border pt-3">- <div className="flex items-center justify-between gap-3">- <div className="min-w-0">- <div className="text-sm font-medium">{t('chat.showPage.availability')}</div>- <p className="mt-0.5 text-[11px] leading-snug text-muted">- {t(offline ? 'chat.showPage.availabilityOffline' : 'chat.showPage.availabilityOnline')}- </p>- </div>- <Switch- checked={Boolean(offline)}- disabled={availabilityBusy || (offline ? !access?.can_publish_public : !access?.can_manage)}- onCheckedChange={setOffline}- label={t('chat.showPage.offline')}- />- </div>- </div>+ {accessError ? (+ <p className="border-t border-border pt-3 text-[11px] leading-snug text-destructive-ink">+ {t('chat.showPage.accessLoadError')}+ </p>) : null}{showAddToHome ? (diff --git a/ui/src/components/workbench/ShowPageSharingSettings.test.tsx b/ui/src/components/workbench/ShowPageSharingSettings.test.tsxindex 667c5f142..620eebe60 100644--- a/ui/src/components/workbench/ShowPageSharingSettings.test.tsx+++ b/ui/src/components/workbench/ShowPageSharingSettings.test.tsx@@ -38,12 +38,33 @@ const showAccess = (overrides: Partial<ShowAccess> = {}): ShowAccess => ({...overrides,});-const settings = (sessionId = 'ses-1') => (+const settings = (+ sessionId = 'ses-1',+ showCustomLink = true,+ onApplied?: (showAccess: ShowAccess) => void,+) => (<I18nextProvider i18n={i18n}>- <ShowPageSharingSettings active canManage sessionId={sessionId} />+ <ShowPageSharingSettings+ active+ canManage+ sessionId={sessionId}+ showCustomLink={showCustomLink}+ onApplied={onApplied}+ /></I18nextProvider>);-const renderSettings = (sessionId = 'ses-1') => render(settings(sessionId));+const renderSettings = (+ sessionId = 'ses-1',+ showCustomLink = true,+ onApplied?: (showAccess: ShowAccess) => void,+) => (+ render(settings(sessionId, showCustomLink, onApplied))+);++const chooseMode = async (name: 'Private' | 'Limited' | 'Fully public') => {+ fireEvent.click(await screen.findByRole('button', { name: /Access:/ }));+ fireEvent.click(screen.getByRole('option', { name: new RegExp(name) }));+};afterEach(() => {cleanup();@@ -51,25 +72,25 @@ afterEach(() => {});describe('ShowPageSharingSettings', () => {- it('offers the three closed modes and shows Limited-only fields', async () => {+ it('uses semantic icons instead of radio controls for the three access modes', async () => {api.getShowAccessSettings.mockResolvedValue({ show_access: showAccess() });renderSettings();- expect(await screen.findByRole('radio', { name: 'Private' })).toBeTruthy();- expect(screen.getByRole('radio', { name: 'Limited' })).toBeTruthy();- expect(screen.getByRole('radio', { name: 'Fully public' })).toBeTruthy();- expect(screen.queryByRole('textbox', { name: 'Limited access emails' })).toBeNull();-- fireEvent.click(screen.getByRole('radio', { name: 'Limited' }));-- expect(screen.getByRole('textbox', { name: 'Limited access emails' })).toBeTruthy();- expect((screen.getByRole('textbox', { name: 'Custom link' }) as HTMLInputElement).value).toBe(- 'stable-link',- );- expect(screen.getByText('Add at least one email address.')).toBeTruthy();+ const trigger = await screen.findByRole('button', { name: 'Access: Private' });+ expect(trigger.className).toContain('w-40');+ expect(trigger.className).not.toContain('w-full');+ expect(screen.queryAllByRole('radio')).toHaveLength(0);+ fireEvent.click(screen.getByRole('button', { name: 'Access: Private' }));++ expect(screen.getByRole('option', { name: /Private/ })).toBeTruthy();+ expect(screen.getByRole('option', { name: /Limited/ })).toBeTruthy();+ expect(screen.getByRole('option', { name: /Fully public/ })).toBeTruthy();+ expect(document.querySelector('[data-access-icon="private"]')).toBeTruthy();+ expect(document.querySelector('[data-access-icon="limited"]')).toBeTruthy();+ expect(document.querySelector('[data-access-icon="public"]')).toBeTruthy();});- it('submits mode, stable link, and normalized emails in one Apply', async () => {+ it('saves a Limited audience as soon as an email is added', async () => {api.getShowAccessSettings.mockResolvedValue({ show_access: showAccess() });api.applyShowAccess.mockResolvedValue({status: 'applied',@@ -80,18 +101,15 @@ describe('ShowPageSharingSettings', () => {}),});renderSettings();- await screen.findByRole('radio', { name: 'Private' });- fireEvent.click(screen.getByRole('radio', { name: 'Limited' }));- fireEvent.change(screen.getByRole('textbox', { name: 'Limited access emails' }), {+ await chooseMode('Limited');+ expect(screen.queryByRole('button', { name: 'Apply' })).toBeNull();+ fireEvent.change(screen.getByRole('textbox', { name: 'People with access' }), {target: { value: ' [email protected] ' },});fireEvent.click(screen.getByRole('button', { name: 'Add email' }));- fireEvent.click(screen.getByRole('button', { name: 'Apply' }));- await waitFor(() => {- expect(api.applyShowAccess).toHaveBeenCalledTimes(1);- });+ await waitFor(() => expect(api.applyShowAccess).toHaveBeenCalledTimes(1));expect(api.applyShowAccess).toHaveBeenCalledWith('ses-1', {expected_revision: 0,target_access_mode: 'limited',@@ -100,24 +118,20 @@ describe('ShowPageSharingSettings', () => {});});- it('does not let a hidden Limited email draft block another mode', async () => {+ it('saves a direct mode change without an Apply button', async () => {api.getShowAccessSettings.mockResolvedValue({ show_access: showAccess() });api.applyShowAccess.mockResolvedValue({status: 'applied',show_access: showAccess({ access_mode: 'public', revision: 1 }),});renderSettings();- await screen.findByRole('radio', { name: 'Private' });- fireEvent.click(screen.getByRole('radio', { name: 'Limited' }));- fireEvent.change(screen.getByRole('textbox', { name: 'Limited access emails' }), {+ await chooseMode('Limited');+ fireEvent.change(screen.getByRole('textbox', { name: 'People with access' }), {target: { value: '[email protected]' },});- fireEvent.click(screen.getByRole('radio', { name: 'Fully public' }));+ await chooseMode('Fully public');- const apply = screen.getByRole('button', { name: 'Apply' });- expect((apply as HTMLButtonElement).disabled).toBe(false);- fireEvent.click(apply);await waitFor(() => expect(api.applyShowAccess).toHaveBeenCalledTimes(1));expect(api.applyShowAccess).toHaveBeenCalledWith('ses-1', {expected_revision: 0,@@ -125,6 +139,7 @@ describe('ShowPageSharingSettings', () => {target_share_id: 'stable-link',target_emails: [],});+ expect(screen.queryByRole('button', { name: 'Apply' })).toBeNull();});it('disables new Limited email input at the audience limit', async () => {@@ -136,12 +151,26 @@ describe('ShowPageSharingSettings', () => {});renderSettings();- const input = await screen.findByRole('textbox', { name: 'Limited access emails' });+ const input = await screen.findByRole('textbox', { name: 'People with access' });expect((input as HTMLInputElement).disabled).toBe(true);- expect(screen.getByText('Up to 64 email addresses.')).toBeTruthy();+ expect(screen.getByText('Enter an email and press Enter to add · up to 64')).toBeTruthy();});- it('reloads the latest snapshot after a CAS conflict', async () => {+ it('does not allow removing the last email while Limited is selected', async () => {+ api.getShowAccessSettings.mockResolvedValue({+ show_access: showAccess({+ access_mode: 'limited',+ normalized_emails: ['[email protected]'],+ }),+ });+ renderSettings();++ const remove = await screen.findByRole('button', { name: 'Remove [email protected]' });+ expect((remove as HTMLButtonElement).disabled).toBe(true);+ expect(remove.getAttribute('title')).toBe('Switch to Private to remove the last email');+ });++ it('reloads the latest snapshot after an automatic CAS conflict', async () => {api.getShowAccessSettings.mockResolvedValueOnce({ show_access: showAccess() }).mockResolvedValueOnce({@@ -152,32 +181,27 @@ describe('ShowPageSharingSettings', () => {show_access: showAccess({ access_mode: 'limited', revision: 2 }),});renderSettings();- await screen.findByRole('radio', { name: 'Private' });- fireEvent.click(screen.getByRole('radio', { name: 'Fully public' }));- fireEvent.click(screen.getByRole('button', { name: 'Apply' }));+ await chooseMode('Fully public');- await waitFor(() => {- expect(api.getShowAccessSettings).toHaveBeenCalledTimes(2);- });- expect(screen.getByRole('radio', { name: 'Fully public' }).getAttribute('aria-checked')).toBe('true');+ await waitFor(() => expect(api.getShowAccessSettings).toHaveBeenCalledTimes(2));+ expect(screen.getByRole('button', { name: 'Access: Fully public' })).toBeTruthy();expect(screen.getByText(/changed elsewhere/)).toBeTruthy();});- it('keeps the slug draft visible after a collision', async () => {- api.getShowAccessSettings.mockResolvedValue({ show_access: showAccess() });+ it('keeps the custom-link draft visible after an automatic collision response', async () => {+ api.getShowAccessSettings.mockResolvedValue({+ show_access: showAccess({ access_mode: 'public' }),+ });api.applyShowAccess.mockResolvedValue({status: 'share_id_taken',- show_access: showAccess(),+ show_access: showAccess({ access_mode: 'public' }),});renderSettings();- await screen.findByRole('radio', { name: 'Private' });+ const input = await screen.findByRole('textbox', { name: 'Custom link' });- fireEvent.click(screen.getByRole('radio', { name: 'Fully public' }));- fireEvent.change(screen.getByRole('textbox', { name: 'Custom link' }), {- target: { value: 'taken-link' },- });- fireEvent.click(screen.getByRole('button', { name: 'Apply' }));+ fireEvent.change(input, { target: { value: 'taken-link' } });+ fireEvent.blur(input);expect(await screen.findByText('That custom link is already taken. Pick another.')).toBeTruthy();expect((screen.getByRole('textbox', { name: 'Custom link' }) as HTMLInputElement).value).toBe(@@ -185,6 +209,48 @@ describe('ShowPageSharingSettings', () => {);});+ it('reconciles a successful custom-link save after the editor unmounts', async () => {+ api.getShowAccessSettings.mockResolvedValue({+ show_access: showAccess({ access_mode: 'public' }),+ });+ let resolveApply = (_result: ShowAccessApplyResult) => undefined;+ api.applyShowAccess.mockReturnValue(new Promise<ShowAccessApplyResult>((resolve) => {+ resolveApply = resolve;+ }));+ const onApplied = vi.fn();+ const view = renderSettings('ses-1', true, onApplied);+ const input = await screen.findByRole('textbox', { name: 'Custom link' });++ fireEvent.change(input, { target: { value: 'new-link' } });+ fireEvent.blur(input);+ await waitFor(() => expect(api.applyShowAccess).toHaveBeenCalledTimes(1));+ view.unmount();++ await act(async () => {+ resolveApply({+ status: 'applied',+ show_access: showAccess({+ access_mode: 'public',+ revision: 1,+ share_id: 'new-link',+ }),+ });+ await Promise.resolve();+ });++ expect(onApplied).toHaveBeenCalledWith(expect.objectContaining({ share_id: 'new-link' }));+ });++ it('can hide custom-link editing when embedded in the share popover', async () => {+ api.getShowAccessSettings.mockResolvedValue({+ show_access: showAccess({ access_mode: 'public' }),+ });+ renderSettings('ses-1', false);++ expect(await screen.findByRole('button', { name: 'Access: Fully public' })).toBeTruthy();+ expect(screen.queryByRole('textbox', { name: 'Custom link' })).toBeNull();+ });+it('rejects a mismatched result identity without adopting its email list', async () => {api.getShowAccessSettings.mockResolvedValue({ show_access: showAccess() });api.applyShowAccess.mockResolvedValue({@@ -197,16 +263,14 @@ describe('ShowPageSharingSettings', () => {}),});renderSettings();- await screen.findByRole('radio', { name: 'Private' });- fireEvent.click(screen.getByRole('radio', { name: 'Fully public' }));- fireEvent.click(screen.getByRole('button', { name: 'Apply' }));+ await chooseMode('Fully public');expect(await screen.findByText('Link access could not be loaded.')).toBeTruthy();expect(screen.queryByText('[email protected]')).toBeNull();});- it('discards an in-flight Apply result after the component moves to another session', async () => {+ it('discards an in-flight autosave result after moving to another session', async () => {api.getShowAccessSettings.mockImplementation((sessionId: string) => Promise.resolve({show_access: showAccess({page_id: sessionId,@@ -218,15 +282,13 @@ describe('ShowPageSharingSettings', () => {resolveApply = resolve;}));const view = renderSettings();- await screen.findByRole('radio', { name: 'Private' });- fireEvent.click(screen.getByRole('radio', { name: 'Fully public' }));- fireEvent.click(screen.getByRole('button', { name: 'Apply' }));+ await chooseMode('Fully public');await waitFor(() => expect(api.applyShowAccess).toHaveBeenCalledTimes(1));view.rerender(settings('ses-2'));await waitFor(() => {- expect(screen.getByRole('radio', { name: 'Private' }).getAttribute('aria-checked')).toBe('true');+ expect(screen.getByRole('button', { name: 'Access: Private' })).toBeTruthy();});await act(async () => {resolveApply({@@ -240,10 +302,7 @@ describe('ShowPageSharingSettings', () => {await Promise.resolve();});- await waitFor(() => {- expect(screen.getByRole('radio', { name: 'Private' }).getAttribute('aria-checked')).toBe('true');- });- expect(screen.queryByRole('textbox', { name: 'Limited access emails' })).toBeNull();+ expect(screen.getByRole('button', { name: 'Access: Private' })).toBeTruthy();expect(screen.queryByText('[email protected]')).toBeNull();expect(screen.queryByText('Link access could not be loaded.')).toBeNull();});diff --git a/ui/src/components/workbench/ShowPageSharingSettings.tsx b/ui/src/components/workbench/ShowPageSharingSettings.tsxindex 8a26cf4da..e70bf8540 100644--- a/ui/src/components/workbench/ShowPageSharingSettings.tsx+++ b/ui/src/components/workbench/ShowPageSharingSettings.tsx@@ -1,12 +1,21 @@-import { useCallback, useEffect, useMemo, useRef, useState } from 'react';+import { useCallback, useEffect, useRef, useState } from 'react';import clsx from 'clsx';-import { Loader2, Plus, RefreshCw, X } from 'lucide-react';+import {+ Check,+ ChevronDown,+ Globe2,+ Loader2,+ LockKeyhole,+ Plus,+ RefreshCw,+ Users,+ X,+} from 'lucide-react';import { useTranslation } from 'react-i18next';import { Button } from '@/components/ui/button';-import { ConfirmDialog } from '@/components/ui/confirm-dialog';import { Input } from '@/components/ui/input';-import { SegmentedRadio } from '@/components/ui/segmented';+import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';import { useApi } from '@/context/ApiContext';import {normalizeShowAccessEmail,@@ -22,33 +31,110 @@ type Gate = 'idle' | 'loading' | 'ready' | 'conflict' | 'share_id_taken' | 'invaconst normalizedSet = (emails: string[]): string[] => [...new Set(emails)].sort();-const requiresNarrowingConfirmation = (- saved: ShowAccess,- mode: ShowAccessMode,- emails: string[],-): boolean => {- if (saved.access_mode === 'public' && mode !== 'public') return true;- if (saved.access_mode !== 'limited') return false;- if (mode === 'private') return true;- if (mode !== 'limited') return false;- const next = new Set(emails);- return saved.normalized_emails.some((email) => !next.has(email));-};+const MODE_ICONS = {+ private: LockKeyhole,+ limited: Users,+ public: Globe2,+} satisfies Record<ShowAccessMode, typeof LockKeyhole>;++function AccessModeSelect({+ value,+ disabled,+ onChange,+ ownerWindowId,+}: {+ value: ShowAccessMode;+ disabled: boolean;+ onChange: (value: ShowAccessMode) => void;+ ownerWindowId?: string;+}) {+ const { t } = useTranslation();+ const [open, setOpen] = useState(false);+ const CurrentIcon = MODE_ICONS[value];+ const modes = (['private', 'limited', 'public'] as const).map((mode) => ({+ mode,+ label: t(`chat.showPage.sharingModes.${mode}`),+ description: t(`chat.showPage.sharingHelp.${mode}`),+ }));++ return (+ <Popover open={open} onOpenChange={setOpen}>+ <PopoverTrigger asChild>+ <button+ type="button"+ disabled={disabled}+ aria-haspopup="listbox"+ aria-label={t('chat.showPage.sharingModeCurrent', {+ mode: t(`chat.showPage.sharingModes.${value}`),+ })}+ className="flex h-9 w-40 items-center gap-2 rounded-md border border-border bg-background px-3 text-left text-[13px] font-medium text-foreground outline-none transition hover:border-border-strong focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"+ >+ <CurrentIcon data-access-icon={value} className="size-4 shrink-0 text-cyan-ink" />+ <span className="min-w-0 flex-1 truncate">{t(`chat.showPage.sharingModes.${value}`)}</span>+ <ChevronDown className="size-4 shrink-0 text-muted" />+ </button>+ </PopoverTrigger>+ <PopoverContent+ align="end"+ sideOffset={4}+ role="listbox"+ aria-label={t('chat.showPage.sharingAccess')}+ data-window-owner-id={ownerWindowId}+ className="w-64 space-y-0.5 p-1"+ >+ {modes.map(({ mode, label, description }) => {+ const Icon = MODE_ICONS[mode];+ const selected = value === mode;+ return (+ <button+ key={mode}+ type="button"+ role="option"+ aria-selected={selected}+ disabled={disabled}+ onClick={() => {+ setOpen(false);+ onChange(mode);+ }}+ className={clsx(+ 'flex w-full items-start gap-2.5 rounded-sm px-2.5 py-2 text-left transition-colors',+ selected ? 'bg-mint/[0.1]' : 'hover:bg-foreground/[0.05]',+ )}+ >+ <Icon+ data-access-icon={mode}+ className={clsx(+ 'mt-0.5 size-4 shrink-0',+ selected ? 'text-mint-ink' : 'text-muted',+ )}+ />+ <span className="min-w-0 flex-1">+ <span className="block text-[13px] font-medium text-foreground">{label}</span>+ <span className="mt-0.5 block text-[11px] leading-snug text-muted">{description}</span>+ </span>+ {selected ? <Check className="mt-0.5 size-4 shrink-0 text-mint-ink" /> : null}+ </button>+ );+ })}+ </PopoverContent>+ </Popover>+ );+}export function ShowPageSharingSettings({active,canManage,sessionId,onApplied,- onConfirmationOpenChange,ownerWindowId,+ showCustomLink = true,}: {active: boolean;canManage: boolean;sessionId: string;onApplied?: (showAccess: ShowAccess) => void;- onConfirmationOpenChange?: (open: boolean) => void;ownerWindowId?: string;+ showCustomLink?: boolean;}) {const { t } = useTranslation();const api = useApi();@@ -60,18 +146,15 @@ export function ShowPageSharingSettings({const [emailDraft, setEmailDraft] = useState('');const [emailInvalid, setEmailInvalid] = useState(false);const [saving, setSaving] = useState(false);- const [confirmNarrowing, setConfirmNarrowing] = useState(false);const generationRef = useRef(0);+ const savingRef = useRef(false);+ const savedRef = useRef<ShowAccess | null>(null);const sessionIdRef = useRef(sessionId);sessionIdRef.current = sessionId;- const setConfirmationOpen = useCallback((next: boolean) => {- setConfirmNarrowing(next);- onConfirmationOpenChange?.(next);- }, [onConfirmationOpenChange]);-const adopt = useCallback((showAccess: ShowAccess) => {if (showAccess.page_id !== sessionId) throw new Error('ShowAccess page identity mismatch');+ savedRef.current = showAccess;setSaved(showAccess);setMode(showAccess.access_mode);setShareId(showAccess.share_id ?? '');@@ -96,6 +179,8 @@ export function ShowPageSharingSettings({useEffect(() => {generationRef.current += 1;+ savingRef.current = false;+ savedRef.current = null;setSaved(null);setMode('private');setShareId('');@@ -103,61 +188,67 @@ export function ShowPageSharingSettings({setEmailDraft('');setEmailInvalid(false);setSaving(false);- setConfirmationOpen(false);setGate('idle');if (active && canManage) void load();return () => {generationRef.current += 1;+ savingRef.current = false;};- }, [active, canManage, load, sessionId, setConfirmationOpen]);+ }, [active, canManage, load, sessionId]);const normalizedShareId = shareId.trim() || null;const sharedMode = mode === 'limited' || mode === 'public';const shareIdInvalid = sharedMode && (!normalizedShareId || !isValidShareId(normalizedShareId));- const targetEmails = useMemo(- () => showAccessTargetEmails(mode, emails),- [emails, mode],- );const dirty = Boolean(saved && showAccessDraftChanged(saved, mode, normalizedShareId, emails),);- const draftBlocked = mode === 'limited'- && Boolean(emailDraft.replace(/^[\t\n\f\r\v ]+|[\t\n\f\r\v ]+$/g, ''));const emailLimitReached = emails.length >= SHOW_ACCESS_EMAIL_MAX_COUNT;- const invalid = shareIdInvalid || (mode === 'limited' && targetEmails.length === 0);const editable = canManage && gate !== 'loading' && !saving;- const addEmail = () => {- if (emailLimitReached) return;- const normalized = normalizeShowAccessEmail(emailDraft);- if (!normalized) {- setEmailInvalid(true);- return;- }- setEmails((current) => normalizedSet([...current, normalized]));- setEmailDraft('');- setEmailInvalid(false);- };-- const commit = async () => {- if (!saved || !dirty || invalid || draftBlocked || !editable) return;+ const commit = async (+ nextMode: ShowAccessMode,+ nextShareId: string,+ nextEmails: string[],+ ) => {+ const current = savedRef.current;+ const targetShareId = nextShareId.trim() || null;+ const nextTargetEmails = showAccessTargetEmails(nextMode, nextEmails);+ const nextInvalid = (nextMode !== 'private' && (!targetShareId || !isValidShareId(targetShareId)))+ || (nextMode === 'limited' && nextTargetEmails.length === 0);+ if (+ !current+ || savingRef.current+ || nextInvalid+ || !canManage+ || gate === 'loading'+ || !showAccessDraftChanged(current, nextMode, targetShareId, nextEmails)+ ) return;const generation = generationRef.current;const requestSessionId = sessionId;const isCurrent = () => (generation === generationRef.current && requestSessionId === sessionIdRef.current);+ savingRef.current = true;setSaving(true);- setConfirmationOpen(false);try {const result = await api.applyShowAccess(requestSessionId, {- expected_revision: saved.revision,- target_access_mode: mode,- target_share_id: normalizedShareId,- target_emails: targetEmails,+ expected_revision: current.revision,+ target_access_mode: nextMode,+ target_share_id: targetShareId,+ target_emails: nextTargetEmails,});- if (!isCurrent()) return;if (result.show_access.page_id !== requestSessionId) throw new Error('ShowAccess page identity mismatch');+ if (!isCurrent()) {+ // Collapsing the row unmounts this editor, but the successful write still+ // has to reconcile the shared inventory so its copied link is not stale.+ // A real session change updates sessionIdRef and remains discarded.+ if (result.status === 'applied' && requestSessionId === sessionIdRef.current) {+ onApplied?.(result.show_access);+ }+ return;+ }if (result.status === 'conflict') {+ savingRef.current = false;setSaving(false);await load('conflict');return;@@ -173,217 +264,252 @@ export function ShowPageSharingSettings({if (!isCurrent()) return;setGate('error');} finally {- if (isCurrent()) setSaving(false);+ if (isCurrent()) {+ savingRef.current = false;+ setSaving(false);+ }}};- const save = () => {- if (!saved || !dirty || invalid || draftBlocked || !editable) return;- if (requiresNarrowingConfirmation(saved, mode, targetEmails)) {- setConfirmationOpen(true);+ const changeMode = (nextMode: ShowAccessMode) => {+ if (!editable || nextMode === mode) return;+ setMode(nextMode);+ setEmailInvalid(false);+ if (nextMode === 'limited' && emails.length === 0) return;+ void commit(nextMode, shareId, emails);+ };++ const addEmail = () => {+ if (!editable || emailLimitReached) return;+ const normalized = normalizeShowAccessEmail(emailDraft);+ if (!normalized) {+ setEmailInvalid(true);return;}- void commit();+ const nextEmails = normalizedSet([...emails, normalized]);+ setEmails(nextEmails);+ setEmailDraft('');+ setEmailInvalid(false);+ if (mode === 'limited') void commit(mode, shareId, nextEmails);+ };++ const removeEmail = (email: string) => {+ if (!editable || (mode === 'limited' && emails.length <= 1)) return;+ const nextEmails = emails.filter((value) => value !== email);+ setEmails(nextEmails);+ if (mode === 'limited') void commit(mode, shareId, nextEmails);+ };++ const saveShareId = () => {+ if (!editable || shareIdInvalid) return;+ void commit(mode, shareId, emails);};if (!canManage) return null;return (- <>- <section className="space-y-2.5" aria-label={t('chat.showPage.sharingAccess')}>- <div>+ <section className="space-y-2.5" aria-label={t('chat.showPage.sharingAccess')}>+ {gate === 'loading' || gate === 'idle' ? (+ <div className="flex min-h-9 items-center justify-between gap-3"><div className="text-sm font-medium">{t('chat.showPage.sharingAccess')}</div>- <p className="mt-0.5 text-[11px] leading-snug text-muted">- {t('chat.showPage.sharingAccessDesc')}- </p>- </div>-- {gate === 'loading' || gate === 'idle' ? (- <div className="flex h-9 items-center gap-1.5 text-[11px] text-muted">+ <div className="flex items-center gap-1.5 text-[11px] text-muted"><Loader2 className="size-3.5 animate-spin" />{t('chat.showPage.loadingSharingAccess')}</div>- ) : saved ? (- <>- <SegmentedRadio<ShowAccessMode>+ </div>+ ) : saved ? (+ <>+ <div className="flex items-center justify-between gap-3">+ <div className="min-w-0">+ <div className="text-sm font-medium">{t('chat.showPage.sharingAccess')}</div>+ <div className="mt-0.5 flex items-center gap-1 text-[11px] text-muted" role="status">+ {saving ? (+ <>+ <Loader2 className="size-3 animate-spin" />+ {t('common.saving')}+ </>+ ) : (+ <>+ <Check className="size-3 text-mint-ink" />+ {t('chat.showPage.sharingAutoSave')}+ </>+ )}+ </div>+ </div>+ <AccessModeSelectvalue={mode}- onChange={(next) => {- if (editable) setMode(next);- }}disabled={!editable}- ariaLabel={t('chat.showPage.sharingAccess')}- options={[- { id: 'private', label: t('chat.showPage.sharingModes.private') },- { id: 'limited', label: t('chat.showPage.sharingModes.limited') },- { id: 'public', label: t('chat.showPage.sharingModes.public') },- ]}+ onChange={changeMode}+ ownerWindowId={ownerWindowId}/>- <p className="text-[11px] leading-snug text-muted">- {t(`chat.showPage.sharingHelp.${mode}`)}- </p>+ </div>- {mode === 'limited' ? (- <div className="space-y-2">- <div className="flex items-start gap-1.5">- <div className="min-w-0 flex-1">- <Input- type="email"- value={emailDraft}- disabled={!editable || emailLimitReached}- onChange={(event) => {- setEmailDraft(event.target.value);- setEmailInvalid(false);- }}- onKeyDown={(event) => {- if (event.key !== 'Enter') return;- event.preventDefault();- addEmail();- }}- placeholder={t('chat.showPage.emailPlaceholder')}- aria-label={t('chat.showPage.limitedEmails')}- aria-invalid={emailInvalid || undefined}- className={clsx('h-8 text-xs', emailInvalid && 'border-destructive')}- />- {emailInvalid ? (- <p className="mt-1 text-[11px] text-destructive-ink">- {t('chat.showPage.emailInvalid')}- </p>- ) : null}- </div>- <Button- type="button"- size="icon"- variant="outline"- className="size-8 shrink-0"- disabled={!editable || !emailDraft || emailLimitReached}- onClick={addEmail}- aria-label={t('chat.showPage.addEmail')}- >- <Plus className="size-3.5" />- </Button>- </div>- {emails.length ? (- <div className="max-h-32 divide-y divide-border overflow-y-auto rounded-md border border-border">- {emails.map((email) => (- <div key={email} className="flex min-h-8 items-center gap-2 px-2">- <span className="min-w-0 flex-1 truncate font-mono text-[11px]">{email}</span>- <Button- type="button"- size="icon"- variant="ghost"- className="size-6 shrink-0"- disabled={!editable}- onClick={() => setEmails((current) => current.filter((value) => value !== email))}- aria-label={t('chat.showPage.removeEmail', { email })}- >- <X className="size-3" />- </Button>- </div>- ))}- </div>- ) : (- <p className="text-[11px] text-destructive-ink">- {t('chat.showPage.limitedEmailRequired')}- </p>- )}- <p className="text-[11px] text-muted">- {t('chat.showPage.limitedEmailLimit', { count: SHOW_ACCESS_EMAIL_MAX_COUNT })}- </p>+ {mode === 'limited' ? (+ <div className="space-y-2">+ <div className="flex items-center justify-between gap-2">+ <span className="text-[11px] font-medium text-foreground">+ {t('chat.showPage.limitedEmails')}+ </span>+ {saved.access_mode === 'limited' && !dirty && !saving ? (+ <span className="flex items-center gap-1 text-[11px] text-mint-ink">+ <Check className="size-3" />+ {t('common.saved')}+ </span>+ ) : null}</div>- ) : null}-- {sharedMode ? (- <div className="space-y-1">- <div className="flex items-center gap-1.5">- <span className="shrink-0 font-mono text-xs text-muted">/p/</span>+ <div className="flex items-start gap-1.5">+ <div className="min-w-0 flex-1"><Input- value={shareId}- spellCheck={false}- autoCapitalize="none"- autoCorrect="off"- maxLength={SHARE_ID_MAX_LENGTH}- disabled={!editable}+ type="email"+ value={emailDraft}+ disabled={!editable || emailLimitReached}onChange={(event) => {- setShareId(event.target.value);- if (gate === 'share_id_taken') setGate('ready');+ setEmailDraft(event.target.value);+ setEmailInvalid(false);+ }}+ onKeyDown={(event) => {+ if (event.key !== 'Enter') return;+ event.preventDefault();+ addEmail();}}- aria-label={t('showPages.shareId.label')}- aria-invalid={shareIdInvalid || gate === 'share_id_taken' || undefined}- className={clsx(- 'h-8 min-w-0 flex-1 font-mono text-xs',- (shareIdInvalid || gate === 'share_id_taken') && 'border-destructive',- )}+ placeholder={t('chat.showPage.emailPlaceholder')}+ aria-label={t('chat.showPage.limitedEmails')}+ aria-invalid={emailInvalid || undefined}+ className={clsx('h-8 text-xs', emailInvalid && 'border-destructive')}/>+ {emailInvalid ? (+ <p className="mt-1 text-[11px] text-destructive-ink">+ {t('chat.showPage.emailInvalid')}+ </p>+ ) : null}</div>- {shareIdInvalid || gate === 'share_id_taken' ? (- <p className="text-[11px] text-destructive-ink">- {gate === 'share_id_taken'- ? t('showPages.shareId.errors.taken')- : t('showPages.shareId.errors.invalid')}- </p>- ) : null}- </div>- ) : null}-- {['conflict', 'invalid', 'error'].includes(gate) ? (- <div className="flex items-center justify-between gap-2 border-t border-border pt-2">- <span className="text-[11px] leading-snug text-destructive-ink">- {t(`chat.showPage.sharingErrors.${gate}`)}- </span><Buttontype="button"size="icon"- variant="ghost"- className="size-7 shrink-0"- onClick={() => void load()}- aria-label={t('common.retry')}+ variant="outline"+ className="size-8 shrink-0"+ disabled={!editable || !emailDraft || emailLimitReached}+ onClick={addEmail}+ aria-label={t('chat.showPage.addEmail')}>- <RefreshCw className="size-3.5" />+ <Plus className="size-3.5" /></Button></div>- ) : null}+ {emails.length ? (+ <div className="flex max-h-32 flex-wrap gap-1.5 overflow-y-auto">+ {emails.map((email) => {+ const lastLimitedEmail = mode === 'limited' && emails.length === 1;+ return (+ <span+ key={email}+ className="inline-flex h-7 max-w-full items-center gap-1 rounded-md border border-border bg-foreground/[0.04] pl-2.5 pr-1 text-[11px] text-foreground"+ >+ <span className="min-w-0 truncate font-mono">{email}</span>+ <Button+ type="button"+ size="icon"+ variant="ghost"+ className="size-5 shrink-0"+ disabled={!editable || lastLimitedEmail}+ onClick={() => removeEmail(email)}+ aria-label={t('chat.showPage.removeEmail', { email })}+ title={lastLimitedEmail+ ? t('chat.showPage.keepOneLimitedEmail')+ : t('chat.showPage.removeEmail', { email })}+ >+ <X className="size-3" />+ </Button>+ </span>+ );+ })}+ </div>+ ) : (+ <p className="text-[11px] text-destructive-ink">+ {t('chat.showPage.limitedEmailRequired')}+ </p>+ )}+ <p className="text-[11px] text-muted">+ {t('chat.showPage.limitedEmailHint', { count: SHOW_ACCESS_EMAIL_MAX_COUNT })}+ </p>+ </div>+ ) : null}- <div className="flex justify-end">+ {showCustomLink && sharedMode ? (+ <div className="space-y-1">+ <div className="flex items-center gap-1.5">+ <span className="shrink-0 font-mono text-xs text-muted">/p/</span>+ <Input+ value={shareId}+ spellCheck={false}+ autoCapitalize="none"+ autoCorrect="off"+ maxLength={SHARE_ID_MAX_LENGTH}+ disabled={!editable}+ onChange={(event) => {+ setShareId(event.target.value);+ if (gate === 'share_id_taken') setGate('ready');+ }}+ onBlur={saveShareId}+ onKeyDown={(event) => {+ if (event.key !== 'Enter') return;+ event.preventDefault();+ event.currentTarget.blur();+ }}+ aria-label={t('showPages.shareId.label')}+ aria-invalid={shareIdInvalid || gate === 'share_id_taken' || undefined}+ className={clsx(+ 'h-8 min-w-0 flex-1 font-mono text-xs',+ (shareIdInvalid || gate === 'share_id_taken') && 'border-destructive',+ )}+ />+ </div>+ {shareIdInvalid || gate === 'share_id_taken' ? (+ <p className="text-[11px] text-destructive-ink">+ {gate === 'share_id_taken'+ ? t('showPages.shareId.errors.taken')+ : t('showPages.shareId.errors.invalid')}+ </p>+ ) : (+ <p className="text-[11px] text-muted">{t('chat.showPage.shareIdAutoSaveHint')}</p>+ )}+ </div>+ ) : null}++ {['conflict', 'invalid', 'error'].includes(gate) ? (+ <div className="flex items-center justify-between gap-2 border-t border-border pt-2">+ <span className="text-[11px] leading-snug text-destructive-ink">+ {t(`chat.showPage.sharingErrors.${gate}`)}+ </span><Buttontype="button"- size="sm"- variant="outline"- className="h-7"- disabled={!dirty || invalid || draftBlocked || !editable}- onClick={save}+ size="icon"+ variant="ghost"+ className="size-7 shrink-0"+ onClick={() => void load()}+ aria-label={t('common.retry')}>- {saving ? <Loader2 className="size-3.5 animate-spin" /> : null}- {t('chat.showPage.applySharingAccess')}+ <RefreshCw className="size-3.5" /></Button></div>- </>- ) : (- <div className="flex items-center justify-between gap-2">- <span className="text-[11px] text-destructive-ink">- {t('chat.showPage.sharingErrors.error')}- </span>- <Button- type="button"- size="icon"- variant="ghost"- className="size-7"- onClick={() => void load()}- aria-label={t('common.retry')}- >- <RefreshCw className="size-3.5" />- </Button>- </div>- )}- </section>- <ConfirmDialog- open={confirmNarrowing}- onOpenChange={setConfirmationOpen}- title={t('chat.showPage.narrowSharingTitle')}- description={t('chat.showPage.narrowSharingBody')}- confirmLabel={t('chat.showPage.applySharingAccess')}- onConfirm={commit}- windowOwnerId={ownerWindowId}- />- </>+ ) : null}+ </>+ ) : (+ <div className="flex items-center justify-between gap-2">+ <span className="text-[11px] text-destructive-ink">+ {t('chat.showPage.sharingErrors.error')}+ </span>+ <Button+ type="button"+ size="icon"+ variant="ghost"+ className="size-7"+ onClick={() => void load()}+ aria-label={t('common.retry')}+ >+ <RefreshCw className="size-3.5" />+ </Button>+ </div>+ )}+ </section>);}diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.jsonindex 47cbec65a..3ca5b890b 100644--- a/ui/src/i18n/en.json+++ b/ui/src/i18n/en.json@@ -3545,30 +3545,30 @@"copyLink": "Copy link","nativeShare": "Share…","access": "Access",- "sharingAccess": "Link access",- "sharingAccessDesc": "Controls the shared /p link independently from Workspace access.",- "loadingSharingAccess": "Loading link access…",+ "sharingAccess": "Access",+ "sharingModeCurrent": "Access: {{mode}}",+ "sharingAutoSave": "Changes save automatically",+ "loadingSharingAccess": "Loading access…","sharingModes": {"private": "Private","limited": "Limited","public": "Fully public"},"sharingHelp": {- "private": "The shared link is disabled.",- "limited": "Configure the email audience now; the shared link is not active yet.",- "public": "Anyone with the link can open the shared page."+ "private": "Only you can access this page",+ "limited": "Only people in the list can access",+ "public": "Anyone can access without signing in"},- "limitedEmails": "Limited access emails",+ "limitedEmails": "People with access","limitedEmailRequired": "Add at least one email address.",- "limitedEmailLimit": "Up to {{count}} email addresses.",+ "limitedEmailHint": "Enter an email and press Enter to add · up to {{count}}",+ "keepOneLimitedEmail": "Switch to Private to remove the last email",+ "shareIdAutoSaveHint": "Press Enter or leave the field to save","sharingErrors": {"conflict": "Link access changed elsewhere. The latest version has been loaded.","invalid": "Review the mode, link, and email list.","error": "Link access could not be loaded."},- "applySharingAccess": "Apply",- "narrowSharingTitle": "Restrict link access?",- "narrowSharingBody": "People who lose access will be denied on their next page request.","workspaceAccess": "Workspace access","workspaceAccessDesc": "Who can open this page after signing in.","workspaceLevels": {@@ -3607,10 +3607,9 @@"removeEmail": "Remove {{email}}","emailInvalid": "Enter a valid email address.","accessLoadError": "Access details could not be loaded. Sharing changes are disabled.",- "availability": "Availability",- "offline": "Offline",- "availabilityOnline": "Online and serving its configured access mode.",- "availabilityOffline": "Offline for everyone; link access is retained.",+ "availability": "Page online",+ "availabilityOnline": "This page is online. Turn it off to stop serving it.",+ "availabilityOffline": "This page is offline. Turn it on to restore access.","loadError": "Couldn't load this Show Page.","pinToDock": "Pin to Dock","pinToDockCaption": "Opens as an app from the Dock",diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.jsonindex dc8d2afd9..d2a8bafd0 100644--- a/ui/src/i18n/zh.json+++ b/ui/src/i18n/zh.json@@ -3545,30 +3545,30 @@"copyLink": "复制链接","nativeShare": "系统分享","access": "权限",- "sharingAccess": "链接访问",- "sharingAccessDesc": "独立控制分享链接 /p,不改变 Workspace 权限。",- "loadingSharingAccess": "正在加载链接访问设置…",+ "sharingAccess": "访问范围",+ "sharingModeCurrent": "访问范围:{{mode}}",+ "sharingAutoSave": "更改会自动保存",+ "loadingSharingAccess": "正在加载访问范围…","sharingModes": {"private": "私有",- "limited": "指定用户",+ "limited": "有限访问","public": "完全公开"},"sharingHelp": {- "private": "分享链接已停用。",- "limited": "可先配置邮箱名单;分享链接暂未启用。",- "public": "任何拿到链接的人都可以打开分享页面。"+ "private": "仅你可以访问此页面",+ "limited": "仅允许列表中的用户访问",+ "public": "任何人无需登录即可访问"},- "limitedEmails": "指定用户邮箱",+ "limitedEmails": "允许访问的用户","limitedEmailRequired": "请至少添加一个邮箱。",- "limitedEmailLimit": "最多添加 {{count}} 个邮箱。",+ "limitedEmailHint": "输入邮箱后按回车添加 · 最多 {{count}} 个",+ "keepOneLimitedEmail": "切换为私有后可移除最后一个邮箱",+ "shareIdAutoSaveHint": "按回车或离开输入框后自动保存","sharingErrors": {"conflict": "链接访问设置已在其他位置更新,已载入最新版本。","invalid": "请检查访问模式、链接和邮箱列表。","error": "无法加载链接访问设置。"},- "applySharingAccess": "应用",- "narrowSharingTitle": "收紧链接访问范围?",- "narrowSharingBody": "失去权限的用户在下一次请求页面时将被拒绝。","workspaceAccess": "登录访问范围","workspaceAccessDesc": "控制登录后哪些人可以打开此页面。","workspaceLevels": {@@ -3607,10 +3607,9 @@"removeEmail": "移除 {{email}}","emailInvalid": "请输入有效的邮箱地址。","accessLoadError": "无法加载权限详情,分享设置已停用。",- "availability": "在线状态",- "offline": "下线",- "availabilityOnline": "页面在线,并按当前链接访问模式提供服务。",- "availabilityOffline": "所有人暂时无法访问;链接访问设置会保留。",+ "availability": "页面在线",+ "availabilityOnline": "当前页面在线,关闭可下线页面不再提供访问。",+ "availabilityOffline": "当前页面已下线,开启可恢复访问。","loadError": "无法加载这个 Show Page。","pinToDock": "固定到 Dock","pinToDockCaption": "作为应用从 Dock 打开",diff --git a/ui/src/lib/showPageLinks.test.ts b/ui/src/lib/showPageLinks.test.tsindex b332b6913..862512119 100644--- a/ui/src/lib/showPageLinks.test.ts+++ b/ui/src/lib/showPageLinks.test.ts@@ -18,12 +18,33 @@ describe('Show Page link routes', () => {expect(editorPath(page('unexpected'))).toBeNull();});- it('does not expose Limited as a live link before signed-in guest admission exists', () => {+ it('keeps Limited share links on the signed-in guest route', () => {const limited = {...page('limited'),- active_url: 'https://show.example.test/p/shared-link/',+ public_url: 'https://show.example.test/p/shared-link/',};- expect(localPath(limited)).toBeNull();+ expect(localPath(limited)).toBe('/p/shared-link/');+ expect(liveHref(limited)).toBe('https://show.example.test/p/shared-link/');+ expect(copyHref(limited)).toBe('https://show.example.test/p/shared-link/');+ });++ it('prefers the Cloud-qualified Limited URL over the local fallback', () => {+ const limited = {+ ...page('limited'),+ active_url: '/p/shared-link/',+ public_url: 'https://alice.avibe.bot/p/shared-link/',+ };++ expect(copyHref(limited)).toBe('https://alice.avibe.bot/p/shared-link/');+ });++ it('does not expose a Limited link without a Cloud-qualified URL', () => {+ const limited = {+ ...page('limited'),+ active_url: '/p/shared-link/',+ public_url: null,+ };+expect(liveHref(limited)).toBeNull();expect(copyHref(limited)).toBeNull();});diff --git a/ui/src/lib/showPageLinks.ts b/ui/src/lib/showPageLinks.tsindex 888a32f6a..3f5700430 100644--- a/ui/src/lib/showPageLinks.ts+++ b/ui/src/lib/showPageLinks.ts@@ -1,20 +1,20 @@// 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.+// share control.export type ShowPageLinkInfo = {session_id: string;visibility: string;active_url: string | null;+ public_url?: string | null;share_id: string | null;};-// Same-origin path a Show Page is served at locally. Null when there is no live-// route, including Limited until signed-in guest admission is implemented.+// Same-origin path a Show Page is served at locally. Limited and Public share+// one stable /p route; the server decides whether to start identity admission+// or serve the page anonymously.export function localPath(page: ShowPageLinkInfo): string | null {if (page.visibility === 'private') return `/show/${encodeURIComponent(page.session_id)}/`;- if (page.visibility === 'public' && page.share_id) {+ if ((page.visibility === 'limited' || page.visibility === 'public') && page.share_id) {return `/p/${encodeURIComponent(page.share_id)}/`;}return null;@@ -30,9 +30,10 @@ export function editorPath(page: ShowPageLinkInfo): string | null {}export function liveHref(page: ShowPageLinkInfo): string | null {- // Limited is configurable in this lane, but its signed-in guest admission is- // not active yet. Ignore even a stale server-projected URL until that exists.- if (page.visibility === 'limited') return null;+ // Limited admission depends on Avibe Cloud identity. The server-projected+ // public URL is therefore the only usable share link; a local /p fallback+ // would lead recipients to an authorization flow this installation cannot run.+ if (page.visibility === 'limited') return page.public_url ?? null;return page.active_url || localPath(page);}