diff --git a/.github/pr-screenshots/2161-invitation-journey/README.md b/.github/pr-screenshots/2161-invitation-journey/README.md new file mode 100644 index 0000000000..d1868a58a4 --- /dev/null +++ b/.github/pr-screenshots/2161-invitation-journey/README.md @@ -0,0 +1,24 @@ +# Invitation journey UAT evidence + +Batch21, 2026-10-18. Runtime `1a2c1c385fd842958a078da05bb85c841d69934e`; baseline `9a2b651844d8686a0381cbd2d991da6d5199e924`; UAT service `f10437bfbe46c4cbcbfb71bc6b599e9551669051`, schemas 5/4/5. Installed native inputs `494a20f1eb4f0666a2c90bc3c758af4e7ff5f46b` match; no rebuild. [Runtime CI](https://github.com/BotHarness/DeepSeekBot/actions/runs/39102187486) passed all applicable checks. + +## Proven + +- A real iOS deep link reaches recipient-only preview. Preview does not accept. The pending target survives a cold restart. +- Explicit Join lands in the exact guest channel without requiring a paired computer or membership in its organization. A real native message committed once and was independently read through UAT CLI. +- Reopening the accepted invitation after cold restart restores identity and the same channel/message. The CLI verifies no organization membership and sibling-channel denial. +- Revoking only the test invitation causes old-session reads to fail and removes the channel from the guest listing. +- Refresh rotates the independent synthetic phone session; logout removes local tokens, revokes its remote session, rejects its latest refresh token and preserves other sessions. Trusted public configuration remains. +- Default/max text and light/dark preview controls are reachable. Original large/light settings restored; own driver/Metro stopped and private revoked fixture removed. Other devices/Hosts/Prod untouched. + +## Evidence identities and first failures + +`before-*` captures use the baseline. `after-preview-*` captures use `8dd710bdf946ee3771fcbf445832f44d09aaaa1f`; its preview UI is unchanged in the final runtime, but the later channel-entry fix is not attributed to those captures. `final-*` captures and the 20-second `final-join-channel.mp4` use the final runtime. The contact sheet samples the real recording; it is not a substitute for the recording. + +First preview displayed a misleading sign-in-required fallback after restart; the account label now shows the verified invitation recipient or an unverified saved-session status. First acceptance committed correctly, but a missing in-memory identity hid the loaded channel. A cold-restart client test failed before the fix and passes after it; opening a channel now restores identity through the existing service checks. Both first-failure screenshots are retained. The final recording includes the brief loading transition before channel identity resolves. + +All visible accounts are dedicated synthetic UAT fixtures. Invitation URLs are recipient-bound locators, not bearer credentials; test grants were revoked after capture. No password, OTP, API key or access/refresh token is published. + +## Not proven here + +Sender native copy/share, new-instance trust and Hosted AuthKit browser return carrying an invitation, physical camera scanning, Android, and Human visual acceptance remain separate. This synthetic session test does not prove interactive Hosted AuthKit login. QR rendering/save and the combined workspace drawer are not implemented by this slice. New PRs remain Draft and unmerged. diff --git a/.github/pr-screenshots/2161-invitation-journey/after-preview-dark.png b/.github/pr-screenshots/2161-invitation-journey/after-preview-dark.png new file mode 100644 index 0000000000..d0580519f2 Binary files /dev/null and b/.github/pr-screenshots/2161-invitation-journey/after-preview-dark.png differ diff --git a/.github/pr-screenshots/2161-invitation-journey/after-preview-light.png b/.github/pr-screenshots/2161-invitation-journey/after-preview-light.png new file mode 100644 index 0000000000..523666da04 Binary files /dev/null and b/.github/pr-screenshots/2161-invitation-journey/after-preview-light.png differ diff --git a/.github/pr-screenshots/2161-invitation-journey/after-preview-max-dark.png b/.github/pr-screenshots/2161-invitation-journey/after-preview-max-dark.png new file mode 100644 index 0000000000..41708a9f7f Binary files /dev/null and b/.github/pr-screenshots/2161-invitation-journey/after-preview-max-dark.png differ diff --git a/.github/pr-screenshots/2161-invitation-journey/after-preview-max-light.png b/.github/pr-screenshots/2161-invitation-journey/after-preview-max-light.png new file mode 100644 index 0000000000..52c3c98aa4 Binary files /dev/null and b/.github/pr-screenshots/2161-invitation-journey/after-preview-max-light.png differ diff --git a/.github/pr-screenshots/2161-invitation-journey/before-entry-light.png b/.github/pr-screenshots/2161-invitation-journey/before-entry-light.png new file mode 100644 index 0000000000..ca2c6de659 Binary files /dev/null and b/.github/pr-screenshots/2161-invitation-journey/before-entry-light.png differ diff --git a/.github/pr-screenshots/2161-invitation-journey/before-inbox-light.png b/.github/pr-screenshots/2161-invitation-journey/before-inbox-light.png new file mode 100644 index 0000000000..8f8a2b6b2c Binary files /dev/null and b/.github/pr-screenshots/2161-invitation-journey/before-inbox-light.png differ diff --git a/.github/pr-screenshots/2161-invitation-journey/final-cold-reopen.png b/.github/pr-screenshots/2161-invitation-journey/final-cold-reopen.png new file mode 100644 index 0000000000..d132f8a47e Binary files /dev/null and b/.github/pr-screenshots/2161-invitation-journey/final-cold-reopen.png differ diff --git a/.github/pr-screenshots/2161-invitation-journey/final-entry-light.png b/.github/pr-screenshots/2161-invitation-journey/final-entry-light.png new file mode 100644 index 0000000000..cfe7212642 Binary files /dev/null and b/.github/pr-screenshots/2161-invitation-journey/final-entry-light.png differ diff --git a/.github/pr-screenshots/2161-invitation-journey/final-join-channel.mp4 b/.github/pr-screenshots/2161-invitation-journey/final-join-channel.mp4 new file mode 100644 index 0000000000..6822568ba4 Binary files /dev/null and b/.github/pr-screenshots/2161-invitation-journey/final-join-channel.mp4 differ diff --git a/.github/pr-screenshots/2161-invitation-journey/final-join-contact.png b/.github/pr-screenshots/2161-invitation-journey/final-join-contact.png new file mode 100644 index 0000000000..36bc5ad115 Binary files /dev/null and b/.github/pr-screenshots/2161-invitation-journey/final-join-contact.png differ diff --git a/.github/pr-screenshots/2161-invitation-journey/final-message-dark.png b/.github/pr-screenshots/2161-invitation-journey/final-message-dark.png new file mode 100644 index 0000000000..5bce7c6295 Binary files /dev/null and b/.github/pr-screenshots/2161-invitation-journey/final-message-dark.png differ diff --git a/.github/pr-screenshots/2161-invitation-journey/final-message-light.png b/.github/pr-screenshots/2161-invitation-journey/final-message-light.png new file mode 100644 index 0000000000..80421f007f Binary files /dev/null and b/.github/pr-screenshots/2161-invitation-journey/final-message-light.png differ diff --git a/.github/pr-screenshots/2161-invitation-journey/final-revoked.png b/.github/pr-screenshots/2161-invitation-journey/final-revoked.png new file mode 100644 index 0000000000..24958d5218 Binary files /dev/null and b/.github/pr-screenshots/2161-invitation-journey/final-revoked.png differ diff --git a/.github/pr-screenshots/2161-invitation-journey/first-accepted-channel-identity-failure.png b/.github/pr-screenshots/2161-invitation-journey/first-accepted-channel-identity-failure.png new file mode 100644 index 0000000000..474e3e43b8 Binary files /dev/null and b/.github/pr-screenshots/2161-invitation-journey/first-accepted-channel-identity-failure.png differ diff --git a/.github/pr-screenshots/2161-invitation-journey/first-preview-account-label-failure.png b/.github/pr-screenshots/2161-invitation-journey/first-preview-account-label-failure.png new file mode 100644 index 0000000000..fe589c414a Binary files /dev/null and b/.github/pr-screenshots/2161-invitation-journey/first-preview-account-label-failure.png differ diff --git a/.github/pr-screenshots/2161-invitation-journey/proof.json b/.github/pr-screenshots/2161-invitation-journey/proof.json new file mode 100644 index 0000000000..d4c30e98ca --- /dev/null +++ b/.github/pr-screenshots/2161-invitation-journey/proof.json @@ -0,0 +1,37 @@ +{ + "runtimeHead": "1a2c1c385fd842958a078da05bb85c841d69934e", + "baseline": "9a2b651844d8686a0381cbd2d991da6d5199e924", + "serviceHead": "f10437bfbe46c4cbcbfb71bc6b599e9551669051", + "nativeBinary": "494a20f1eb4f0666a2c90bc3c758af4e7ff5f46b", + "acceptance": { + "nativeAccepted": true, + "sameGuestChannel": true, + "noOrgMembership": true, + "siblingDenied": true, + "at": "2026-10-18T05:56:30.885Z" + }, + "revocation": { + "oneNativeMessage": true, + "ownGrantRevoked": true, + "oldSessionReadDenied": true, + "previewRevoked": true, + "at": "2026-10-18T05:58:28.877Z" + }, + "phoneSession": { + "synthetic": true, + "refreshed": true, + "coldRestart": true, + "localDeleted": true, + "remoteRevoked": true, + "latestRefreshRejected": true, + "otherSessionsPreserved": true + }, + "remaining": [ + "sender native copy/share", + "new-instance trust and HostedAuthKit return with invitation", + "physical camera QR", + "Android", + "QR rendering/save", + "combined workspace drawer" + ] +} diff --git a/apps/mobile/app/(tabs)/(home)/index.tsx b/apps/mobile/app/(tabs)/(home)/index.tsx index 703518d3ad..95313a2a48 100644 --- a/apps/mobile/app/(tabs)/(home)/index.tsx +++ b/apps/mobile/app/(tabs)/(home)/index.tsx @@ -68,7 +68,7 @@ export default function HomeScreen() { ); - if (saved === null) return ; + if (saved === null) return ; const create = (target: CreateTarget) => router.push({ pathname: '/full-client', params: fullClientParams(target) }); diff --git a/apps/mobile/app/+native-intent.tsx b/apps/mobile/app/+native-intent.tsx index 49bd002b13..6601982852 100644 --- a/apps/mobile/app/+native-intent.tsx +++ b/apps/mobile/app/+native-intent.tsx @@ -1,4 +1,23 @@ +import * as SecureStore from 'expo-secure-store'; import { cloudNativeIntent } from '../src/cloud/native-intent'; -export function redirectSystemPath({ path }: { path: string; initial: boolean }) { - return cloudNativeIntent(path); +import { parseInvitationLink } from '../src/cloud/invitation-link'; +export async function redirectSystemPath({ path }: { path: string; initial: boolean }) { + const destination = cloudNativeIntent(path); + if (destination.startsWith('/cloud-join?link=')) { + try { + const link = new URL(destination, 'https://native.invalid').searchParams.get('link')!; + parseInvitationLink(link); + await SecureStore.setItemAsync('tob.cloud.pending-join.v1', link); + } catch {} + return destination; + } + if (destination !== '/cloud-services') return destination; + try { + const pending = await SecureStore.getItemAsync('tob.cloud.pending-join.v1'); + if (pending) { + parseInvitationLink(pending); + return '/cloud-join'; + } + } catch {} + return destination; } diff --git a/apps/mobile/app/_layout.tsx b/apps/mobile/app/_layout.tsx index 82772f7530..c74d0d4adf 100644 --- a/apps/mobile/app/_layout.tsx +++ b/apps/mobile/app/_layout.tsx @@ -60,6 +60,7 @@ export default function RootLayout() { /> + + this.lock(async () => { + const target = parseInvitationLink(link); + const response = await this.json(target.server + '/.well-known/open-cloud-groups'); + if (!response.ok) return fail('INSTANCE_UNAVAILABLE'); + const config = parseInstance(response.value); + if (config.server !== target.server) return fail('INVITATION_TARGET_MISMATCH'); + return config; + }); + previewInvitation = (id: string, link: string) => + this.lock(async () => { + const target = parseInvitationLink(link); + const saved = this.entry(id); + if (saved.config.server !== target.server) return fail('INVITATION_TARGET_MISMATCH'); + const entry = await this.current(saved); + const value = parseInvitation( + await this.orgRequest( + entry, + '/' + target.invitationId, + {}, + target.guest ? '/api/channel-invitations' : '/api/invitations', + ), + ); + if (value.invitationId !== target.invitationId || (value.role === 'guest') !== target.guest) + return fail('INVALID_RESPONSE'); + return value; + }); + openChannel = (id: string, organizationId: string, channelId: string, guest = false) => + this.lock(async () => { + if (!validChannelId(channelId)) return fail('INVALID_CHANNEL'); + const entry = guest + ? await this.current(this.entry(id)) + : await this.channelEntry(id, organizationId); + if (!this.identities.has(id)) await this.me(entry); + const raw = await this.orgRequest( + entry, + (guest ? '' : '/' + organizationId + '/channels') + '/' + channelId, + {}, + guest ? '/api/guest-channels' : '/api/organizations', + ); + const channel = parseChannel(raw); + if ( + channel.channelId !== channelId || + (guest && (raw.access !== 'guest' || channel.organizationId !== organizationId)) + ) + return fail('INVALID_RESPONSE'); + return channel; + }); importConfig = (text: string, replace = false) => this.lock(async () => { const config = parseCloudQr(text); diff --git a/apps/mobile/src/cloud/invitation-link.ts b/apps/mobile/src/cloud/invitation-link.ts new file mode 100644 index 0000000000..34797cfb23 --- /dev/null +++ b/apps/mobile/src/cloud/invitation-link.ts @@ -0,0 +1,27 @@ +import { ClientError, serverOrigin } from './instance-contract'; + +export function invitationLink(server: string, invitationId: string): string { + serverOrigin(server); + if (!/^(?:invitation_[A-Za-z0-9]{1,120}|ci_[a-f0-9]{64})$/.test(invitationId)) + throw new ClientError('INVALID_INVITATION_LINK'); + return server + '/join?invitation=' + invitationId; +} +export function parseInvitationLink(raw: string) { + try { + if (raw.length > 2048 || raw !== raw.trim()) throw Error(); + const url = new URL(raw); + const id = url.searchParams.get('invitation') ?? ''; + if ( + url.username || + url.password || + url.hash || + url.pathname !== '/join' || + [...url.searchParams.keys()].length !== 1 || + invitationLink(url.origin, id) !== raw + ) + throw Error(); + return { server: url.origin, invitationId: id, guest: id.startsWith('ci_') }; + } catch { + throw new ClientError('INVALID_INVITATION_LINK'); + } +} diff --git a/apps/mobile/src/cloud/native-intent.ts b/apps/mobile/src/cloud/native-intent.ts index 2facac619b..531a4da70f 100644 --- a/apps/mobile/src/cloud/native-intent.ts +++ b/apps/mobile/src/cloud/native-intent.ts @@ -1,3 +1,19 @@ +import { parseInvitationLink } from './invitation-link'; export function cloudNativeIntent(path: string): string { - return /^ai\.botharness\.deepseekbot\.dev:/i.test(path) ? '/cloud-services' : path; + if (!/^ai\.botharness\.deepseekbot\.dev:/i.test(path)) return path; + try { + const url = new URL(path); + const link = url.searchParams.get('link'); + if ( + !url.host && + url.pathname === '/cloud-join' && + !url.hash && + [...url.searchParams.keys()].length === 1 && + link + ) { + parseInvitationLink(link); + return '/cloud-join?link=' + encodeURIComponent(link); + } + } catch {} + return '/cloud-services'; } diff --git a/apps/mobile/src/cloud/native.ts b/apps/mobile/src/cloud/native.ts index 661da3f0b0..6951f5bc7d 100644 --- a/apps/mobile/src/cloud/native.ts +++ b/apps/mobile/src/cloud/native.ts @@ -44,3 +44,10 @@ const subscribe = (listener: () => void) => { export function useCloudSnapshot() { return useSyncExternalStore(subscribe, cloudClient.getSnapshot, cloudClient.getSnapshot); } + +const JOIN_KEY = 'tob.cloud.pending-join.v1'; +export const pendingCloudJoin = { + read: () => SecureStore.getItemAsync(JOIN_KEY), + save: (link: string) => SecureStore.setItemAsync(JOIN_KEY, link), + clear: () => SecureStore.deleteItemAsync(JOIN_KEY), +}; diff --git a/apps/mobile/src/ui/cloud/channels-screen.tsx b/apps/mobile/src/ui/cloud/channels-screen.tsx index b82c669137..22a1171870 100644 --- a/apps/mobile/src/ui/cloud/channels-screen.tsx +++ b/apps/mobile/src/ui/cloud/channels-screen.tsx @@ -1,5 +1,5 @@ -import { router, useLocalSearchParams } from 'expo-router'; -import { useState } from 'react'; +import { router, useFocusEffect, useLocalSearchParams } from 'expo-router'; +import { useCallback, useRef, useState } from 'react'; import { FlatList, View, type ScrollViewProps } from 'react-native'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { cloudError } from '../../cloud/client'; @@ -37,17 +37,19 @@ function renderGuestChannelFormScroll(props: ScrollViewProps) { } export function CloudChannelsScreen() { - const { instanceId, organizationId, guest } = useLocalSearchParams<{ + const { instanceId, organizationId, guest, channelId } = useLocalSearchParams<{ instanceId: string; organizationId?: string; guest?: string; + channelId?: string; }>(); return ( ); } @@ -55,10 +57,12 @@ function ChannelWorkspace({ instanceId, organizationId, guest, + initialChannelId, }: { instanceId: string; organizationId: string; guest: boolean; + initialChannelId?: string | undefined; }) { const snapshot = useCloudSnapshot(), theme = useDesignTheme(), @@ -77,6 +81,23 @@ function ChannelWorkspace({ [error, setError] = useState(), [notice, setNotice] = useState(); const busy = working || snapshot.busy; + const opened = useRef(false); + useFocusEffect( + useCallback(() => { + if (!initialChannelId || !snapshot.ready || snapshot.busy || opened.current) return; + opened.current = true; + void run(async () => { + const channel = await cloudClient.openChannel( + instanceId, + organizationId, + initialChannelId, + guest, + ); + await history(channel); + setSelected(channel); + }); + }, [initialChannelId, instanceId, organizationId, guest, snapshot.ready, snapshot.busy]), + ); const pending = row?.pendingChannelAction; const pendingHere = ( guest @@ -163,6 +184,24 @@ function ChannelWorkspace({ )} {!!notice && {notice}} + {!!initialChannelId && !selected && ( +