Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/pr-screenshots/2161-invitation-journey/README.md
Original file line number Diff line number Diff line change
@@ -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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions .github/pr-screenshots/2161-invitation-journey/proof.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
2 changes: 1 addition & 1 deletion apps/mobile/app/(tabs)/(home)/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default function HomeScreen() {
<ActivityIndicator />
</View>
);
if (saved === null) return <Redirect href="/pair" />;
if (saved === null) return <Redirect href="/cloud-join" />;

const create = (target: CreateTarget) =>
router.push({ pathname: '/full-client', params: fullClientParams(target) });
Expand Down
23 changes: 21 additions & 2 deletions apps/mobile/app/+native-intent.tsx
Original file line number Diff line number Diff line change
@@ -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;
}
1 change: 1 addition & 0 deletions apps/mobile/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export default function RootLayout() {
/>
<Stack.Screen name="pair" options={{ title: t.pairTitle, presentation: 'modal' }} />
<Stack.Screen name="inbox/[id]" options={{ title: t.inbox }} />
<Stack.Screen name="cloud-join" options={{ title: t.cloudJoin.title }} />
<Stack.Screen name="cloud-services" options={{ title: t.cloud.title }} />
<Stack.Screen
name="cloud-organizations"
Expand Down
1 change: 1 addition & 0 deletions apps/mobile/app/cloud-join.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { CloudJoinScreen as default } from '../src/ui/cloud/join-screen';
49 changes: 49 additions & 0 deletions apps/mobile/src/cloud/client.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { parseInvitationLink } from './invitation-link';
import { parsePendingWork, type PendingWork } from './work-contract';
import { parseAgent, parseAgentHandoff, validAgentId, type AgentHandoff } from './agent-contract';
import {
Expand Down Expand Up @@ -342,6 +343,54 @@ export class CloudClient {
if (connectionKey(parseInstance(r.value)) !== connectionKey(config))
return fail('INSTANCE_CONFIG_CHANGED');
}
inspectInvitationService = (link: string) =>
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);
Expand Down
27 changes: 27 additions & 0 deletions apps/mobile/src/cloud/invitation-link.ts
Original file line number Diff line number Diff line change
@@ -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');
}
}
18 changes: 17 additions & 1 deletion apps/mobile/src/cloud/native-intent.ts
Original file line number Diff line number Diff line change
@@ -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';
}
7 changes: 7 additions & 0 deletions apps/mobile/src/cloud/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};
47 changes: 43 additions & 4 deletions apps/mobile/src/ui/cloud/channels-screen.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -37,28 +37,32 @@ 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 (
<ChannelWorkspace
key={instanceId + ':' + (guest === 'true' ? 'guest' : organizationId)}
key={instanceId + ':' + (guest === 'true' ? 'guest' : organizationId) + ':' + channelId}
instanceId={instanceId}
organizationId={organizationId ?? ''}
guest={guest === 'true'}
initialChannelId={channelId}
/>
);
}
function ChannelWorkspace({
instanceId,
organizationId,
guest,
initialChannelId,
}: {
instanceId: string;
organizationId: string;
guest: boolean;
initialChannelId?: string | undefined;
}) {
const snapshot = useCloudSnapshot(),
theme = useDesignTheme(),
Expand All @@ -77,6 +81,23 @@ function ChannelWorkspace({
[error, setError] = useState<string>(),
[notice, setNotice] = useState<string>();
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
Expand Down Expand Up @@ -163,6 +184,24 @@ function ChannelWorkspace({
</Text>
)}
{!!notice && <Text accessibilityLiveRegion="polite">{notice}</Text>}
{!!initialChannelId && !selected && (
<Button
label={t.cloudChannels.open}
disabled={busy}
onPress={() =>
void run(async () => {
const channel = await cloudClient.openChannel(
instanceId,
organizationId,
initialChannelId,
guest,
);
await history(channel);
setSelected(channel);
})
}
/>
)}
{!allowed ? (
<Text>{t.cloudChannels.selectWorkspace}</Text>
) : selected ? (
Expand Down
31 changes: 30 additions & 1 deletion apps/mobile/src/ui/cloud/invitations-screen.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import * as Clipboard from 'expo-clipboard';
import { invitationLink } from '../../cloud/invitation-link';
import { router, Stack, useLocalSearchParams } from 'expo-router';
import { useState } from 'react';
import { FlatList, View, type ScrollViewProps } from 'react-native';
import { FlatList, Share, View, type ScrollViewProps } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { cloudError } from '../../cloud/client';
import type { Invitation } from '../../cloud/invitation-contract';
Expand Down Expand Up @@ -218,6 +220,33 @@ function InvitationWorkspace({
<Text>
{t.cloudInvitations.expires} {item.expiresAt}
</Text>
{!!organizationId && item.state === 'pending' && !!row && (
<>
<Button
label={t.cloudJoin.copy}
disabled={busy}
onPress={() =>
void run(async () => {
await Clipboard.setStringAsync(
invitationLink(row.config.server, item.invitationId),
);
setNotice(t.cloudJoin.copied);
})
}
/>
<Button
label={t.cloudJoin.share}
disabled={busy}
onPress={() =>
void run(async () => {
await Share.share({
message: invitationLink(row.config.server, item.invitationId),
});
})
}
/>
</>
)}
{organizationId
? (item.state === 'pending' || (guest && item.state === 'accepted')) && (
<Button
Expand Down
Loading
Loading