diff --git a/api/client-boundary.allow.ts b/api/client-boundary.allow.ts index 7c008bd9f9..830cdb2c2e 100644 --- a/api/client-boundary.allow.ts +++ b/api/client-boundary.allow.ts @@ -297,6 +297,12 @@ export const ALLOWED: Allowed[] = [ rule: "sign-in-protocol", why: "where sign-in sends a person back to finish verifying an app account", }, + { + file: "app/src/lib/auth/resume.ts", + what: "/api/auth/shell/handoff", + rule: "sign-in-protocol", + why: "where sign-in sends a phone app's sign-in sheet on to, a page the server draws (Continue to the OpenBot app): a document navigation in the sheet's browser, not a data request, so not through the generated client", + }, { file: "app/src/lib/plugins/finish-on-return.ts", what: "fetch()", diff --git a/app/index.html b/app/index.html index 8dd7b5784b..5c6e80bdb2 100644 --- a/app/index.html +++ b/app/index.html @@ -39,6 +39,52 @@ const skin = saved === "openmuse" ? "openfuse" : saved; if (skin && skin !== "openbot") document.documentElement.dataset.skin = skin; } catch {} + try { + // Inside the phone app's native shell (lib/native-shell/shell.ts works this out the same + // way, and app/tests/native-shell.test.ts holds the two together): what the shell + // injects, then its user agent, then ?native-shell=ios for testing, kept for the tab, only + // in a development build or on a development host (?native-shell=off forgets it anywhere). + // Marked for the styles, and the page takes the whole web view, which the shell lays out + // between its own bars. A browser's viewport is left as it is. + let remembered = null; + const host = String(window.location.hostname || "").toLowerCase(); + const overridable = + "%DEV%" === "true" || + host === "localhost" || + host === "127.0.0.1" || + host === "[::1]" || + host === "::1" || + host.endsWith(".localhost") || + host.endsWith(".test"); + const param = new URLSearchParams(window.location.search).get("native-shell"); + const asked = param === "off" || overridable ? param : null; + try { + if (asked === "off") window.sessionStorage.removeItem("openbot-native-shell"); + else if (asked === "ios" || asked === "android" || asked === "test") + window.sessionStorage.setItem("openbot-native-shell", "test"); + remembered = window.sessionStorage.getItem("openbot-native-shell"); + } catch {} + const injected = window.__OPENBOT_NATIVE_SHELL__; + const mark = /OpenBotShell-(\w+)/.exec(window.navigator.userAgent); + const platform = + injected && (injected.platform === "ios" || injected.platform === "android") + ? injected.platform + : mark + ? mark[1].toLowerCase() === "android" + ? "android" + : "ios" + : asked === "ios" || asked === "android" || asked === "test" + ? "test" + : overridable && asked !== "off" && remembered === "test" + ? "test" + : null; + if (platform) { + document.documentElement.dataset.nativeShell = platform; + const viewport = document.querySelector('meta[name="viewport"]'); + if (viewport && !viewport.content.includes("viewport-fit")) + viewport.content += ", viewport-fit=cover"; + } + } catch {} try { // Opened by OpenBot Desktop's setup, which faded out to the window's ground and marked the // address once (lib/desktop/from-setup.ts): the first paint fades up from that ground. The diff --git a/app/src/components/app-sidebar/account-label.tsx b/app/src/components/app-sidebar/account-label.tsx index 68091aae2e..98d6e09c2a 100644 --- a/app/src/components/app-sidebar/account-label.tsx +++ b/app/src/components/app-sidebar/account-label.tsx @@ -47,7 +47,7 @@ function initialsOf(name: string): string { .join(""); } -function UserAvatar() { +function UserAvatar({ large = false }: { large?: boolean }) { const { data: currentUser } = useQuery(currentUserQueryOptions()); const { person } = useAccountNames(); // On this computer the email is the stand-in, so its letters are never drawn either. @@ -60,7 +60,10 @@ function UserAvatar() { return (
@@ -135,6 +138,8 @@ export const accountMenuClassName = "w-max min-w-[min(16rem,var(--available-width))] max-w-[min(24rem,var(--available-width))] p-1.5"; /** The spacing of each of the account menu's rows. */ export const accountMenuItemClassName = "gap-2 px-2 py-1.5"; +/** The same rows at a thumb's height, 44px, for the phone app's native shell. */ +export const largeAccountMenuItemClassName = "gap-2 px-2 py-3"; /** * The account, as the strip draws it: the person's avatar at the strip's foot, a button that opens @@ -142,7 +147,26 @@ export const accountMenuItemClassName = "gap-2 px-2 py-1.5"; * OpenBot lists them, read in a tooltip on hover and keyboard focus, never while the menu is open. * The menu itself starts with the account row (`AccountRow`). */ -export function AccountMenu({ children }: { children: ReactNode }) { +export function AccountMenu({ + children, + label, + large = false, + side = "right", +}: { + children: ReactNode; + /** + * The button's name, in place of the person's. The phone app's native shell names it "Account", + * so its tests find it whoever is signed in. + */ + label?: string; + /** + * A thumb's size: the phone app's native shell draws the button 44px square, a whole tap target, + * round a 36px avatar. + */ + large?: boolean; + /** Where the tooltip opens: beside the strip, or below a page's header. */ + side?: "right" | "bottom"; +}) { const { person, organization } = useAccountNames(); const [menuOpen, setMenuOpen] = useState(false); return ( @@ -151,17 +175,22 @@ export function AccountMenu({ children }: { children: ReactNode }) {+ {loadFailure( + channels.error, + channels.error?.message || + "Couldn't load your conversations.", + )} +
+ +