Skip to content

Commit e53e02e

Browse files
feat(console): a Mobile App page in the account app shows the code that connects the ObjectOS mobile app (#34141)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi91YSeH3thYWBG8zdtU9ZDBB)_ Fixes #29314 Clause-②: yes (widening) — a new account-app navigation entry and component (`account:mobile_app`), a new `mobileApp` namespace in the `@object-ui/i18n` packs, and a new optional `features.publicBaseUrl` served on `GET /api/v1/auth/config` (declared in `AuthFeaturesConfigSchema`, registered in `PUBLIC_AUTH_CONFIG_NON_FLAG_KEYS`, typed on `AuthPublicConfig`); nothing that worked before is refused Metadata-protocol: added Skills-docs: none — `features.publicBaseUrl` is a key the server serves on its public auth config; no metadata author writes it, and no skill teaches the auth config payload ## 维护者速读 - 改了什么:个人设置(头像菜单 → Profile 所在的 account 应用)在 Profile 之后新增「移动应用」页,显示二维码和可复制的连接链接 `objectos://connect?server=<本服务器公开地址>`;服务端 `GET /api/v1/auth/config` 新增 `features.publicBaseUrl`,就是服务器发邮件、OAuth 链接时用的那个公开地址(只含 scheme、host、路径)。 - 为什么改:用户装好 ObjectOS 手机 App 后,要扫码连到自己的服务器;现在只能手敲地址。 - 风险与回滚:匿名接口多了一个地址字段,但凭据、query、fragment 在服务端和页面两头都会去掉;地址是 localhost / 内网、或公网却只走 http 时不出码,提示把 `OS_AUTH_URL` 设成 https 公网地址;从不用浏览器当前地址。spec 因新增键按规则升 minor。回滚即还原本 PR。 - 先看:`packages/plugins/plugin-auth/src/public-base-url.ts`、`ui/packages/app-shell/src/console/mobile-app/mobileConnect.ts`、`packages/spec/src/api/auth-endpoints.zod.ts`。 - 两分钟验证:`pnpm --filter @objectstack/plugin-auth exec vitest run src/public-base-url.test.ts` 应 10 个测试全过(含走真实 `/api/v1/auth/config` 的两条)。 - 需要你做的:无,席位落地。 ## What changes **Server.** - `GET /api/v1/auth/config` serves `features.publicBaseUrl`: `publicBaseUrlOf(getCanonicalOrigin())`, the canonical origin every emailed and OAuth link is built on (`OS_AUTH_URL`, then `BETTER_AUTH_URL`, then `OS_BASE_URL`; sub-path kept; `https://` prepended to a bare host; the loopback fallback when unset). - `publicBaseUrlOf` (new, `plugin-auth`) reduces it to an address: scheme, host (with a non-default port) and path, no trailing slash. A username, password, query or fragment is dropped, because the door is anonymous. A value that does not parse as an absolute URL is not served. - `AuthFeaturesConfigSchema.publicBaseUrl` (optional string, with a describe), `'publicBaseUrl'` appended to `PUBLIC_AUTH_CONFIG_NON_FLAG_KEYS`, and the regenerated `auth-endpoints.mdx` reference and `authorable-surface/api.json` baseline. **Console.** - `MobileAppPage` (new, `@object-ui/app-shell`, lazy-loaded) reads `features.publicBaseUrl` through `useAuth().getAuthConfig()` and judges it with `mobileConnectTarget`: - `ready`: a public host on `https:`. A QR code (the existing `qrcode` dependency, as an SVG `data:` image on a white frame), the same link as copyable text with **Copy link**, and one privacy line. - `unreachable` / `not-public`: `localhost`, a loopback, private, link-local or otherwise non-public host, or a scheme other than http(s). No code; the alert names the address and says to set `OS_AUTH_URL` to the public address. - `unreachable` / `not-https`: a public host on plain `http:`. The mobile app signs in through this address, so no code; the alert says to serve the server over HTTPS and set `OS_AUTH_URL` to its `https://` address. - `unpublished`: the key is absent, blank or not an absolute URL (the raw value is never shown). The alert says this server does not offer it yet; no setting is named, because none can fix it. - A failed config read shows its own message. `window.location` is never read. - The payload is `objectos://connect?server=` plus the URL-encoded `normalizeServerUrl(publicBaseUrl)`: the same address-only normalisation, applied again on the console side, so the code and every refusal carry the server's address and nothing else. - `deploymentReach`: the new `isPublicHostAddress` is scheme-agnostic; `isPublicHttpsAddress` keeps its behaviour by parsing the URL, requiring `https:`, and delegating. The Connect Agent widget is unchanged. - `registerAppComponent({ ref: 'account:mobile_app', … })` in `builtinComponents`; `AuthPublicConfig.features.publicBaseUrl?: string` in `@object-ui/auth`. - `packages/platform-objects` account app: `nav_account_mobile_app` (component nav, `componentRef: 'account:mobile_app'`, icon `smartphone`) right after Profile, with its label in all 11 app translation bundles. - A `mobileApp` namespace (15 keys) in the 10 hand-written `@object-ui/i18n` packs; `zh-Hant` regenerated with `scripts/gen-zh-hant.mjs`. - No app-store links: no setting carries them today. ## Tests - `public-base-url.test.ts` (plugin-auth): over the REAL `registerAuthRoutes` on a Hono app over a real `AuthManager`, `GET /api/v1/auth/config` serves the configured URL with its sub-path, and a configured credential, query and fragment are absent from the whole response body; `getPublicConfig()` follows `getCanonicalOrigin` (bare host, trailing slash) with a CONTROL for the loopback fallback; `publicBaseUrlOf` cases, including an unparseable value served as nothing. - `mobileConnect.test.ts`: the payload for a public URL, a sub-path and a port; 13 loopback / private / link-local addresses refused as `not-public`; another scheme refused without its credential; a public `http:` host refused as `not-https`, with a CONTROL on `https:`; eight inputs (credentials, query, fragment, trailing slash, whitespace, case, default port) normalised; the link's only parameter is `server`; a value that is not an absolute URL reads as `unpublished`. - `MobileAppPage.test.tsx`: the image `src` equals `qrcode`'s own SVG for the expected link; a credential, query or fragment reaches neither the code nor the page; Copy writes exactly the link; the not-public, not-https and unpublished refusals with their keys and values (the unpublished one names no `OS_AUTH_URL`); the failed read; every built-in locale carries every `mobileApp` key with the same placeholders; `account:mobile_app` resolves through the component registry to this page. - `account-mobile-app-nav.test.ts` (platform-objects): `nav_account_mobile_app` sits immediately after `nav_account_profile`, opens `account:mobile_app` and carries no gate, with a CONTROL that the app still parses. - `ui/e2e/mobile-app-connect-qr.spec.ts` (Playwright): the QR image decodes (`naturalWidth > 0`) at ≥150px beside the link, Copy button and privacy line; a CONTROL with a loopback URL shows the `OS_AUTH_URL` remedy and no code. - Ablations, each red then green after restore: the raw canonical origin served (1 failed); the key not served (4 failed); no console-side normalisation (12 failed); a public `http:` host treated as ready (2 failed); the registered ref renamed (1 failed); the nav entry moved before Profile (1 failed); and, in the first round, the refusal predicate removed (16), the sub-path dropped (3), a `window.location` fallback (1), a broken image `src` (the e2e image test). - Forced test edits, three, each because this PR adds a key or an entry on purpose: - `packages/cli/test/connect-agent-both-halves-wire.pin.test.ts`: the account app's served nav ids count 14, not 13 (`nav_account_mobile_app`). - `packages/spec/src/api/auth-endpoints.test.ts`: the served `features` fixture gains `publicBaseUrl`, because the test requires it to name every classified key. - `packages/plugins/plugin-auth/src/auth-manager.test.ts`: the exact `getPublicConfig().features` expectation gains `publicBaseUrl: 'http://localhost:3000'`. ## Acceptance notes - File surface deviations, seat-approved: the account app (`account.app.ts`) and its 11 translation bundles for the nav entry; the server half in `auth-endpoints.zod.ts` and `auth-manager.ts`, added after #34119 and #34099 merged, plus the new `public-base-url.ts`. - Grading: the claim's `Metadata-protocol: none` is now `added`. The new key moves the `authorable-surface/api.json` baseline, and `check-changeset-no-major.mjs` refuses `none` with a moved baseline, so `@objectstack/spec`, `@objectstack/plugin-auth` and `@objectstack/platform-objects` are `minor`; the `@object-ui/*` packages stay `patch`. - The account app has no separate "user settings" page; the account app reached from the avatar menu's Profile item is that surface. - Cloud-agnostic: nothing here reads a Cloud setting; a Cloud deployment publishes its URL through the same `OS_AUTH_URL`. ## Verification <details><summary>Derived gates</summary> - `node scripts/pm/dispatch-gates.mjs --ran` on the final record at `7c7c5ba4`: "125 derived famil(ies) accounted for — 125 run, 0 NOT-MEASURED". All 125 exit 0. - The round before it, at `cacb7dd1`, had three reds: `check:test-source-alias` (a finding: the page test's registry check reaches the metadata admin's dynamic `@objectstack/lint` import inside a clocked window; fixed in `7c7c5ba4` by the module-top import the gate prescribes), and `check:dts-closure` plus `pnpm --dir ui exec vitest run scripts/` (both read `ui/` build output that was stale after merging `main`; green after rebuilding the ui packages). - Suites at the server-half head under the lock: `@objectstack/spec` 844 files, 26993 tests (one red fixed: the served-features fixture, listed above); `@objectstack/plugin-auth` 278 files (one red fixed: the exact `features` expectation); `@objectstack/platform-objects` 123 files, 2010 passed. The mobile-app vitest (47) and the Playwright spec (2) pass on the UI changes; app-shell `tsc` and eslint are clean. - `check-changeset-no-major.mjs --event` on this body offline: level axis green with `Metadata-protocol: added` and every moved package graded `minor`. - Earlier rounds: 69 at `58280860` and 71 at `9cebce86`, all exit 0. - Records: project share `ui-seat1/29314-gates-ran-final.txt`, `ui-seat1/29314-gates-ran-r4.txt`, `ui-seat1/29314-ablations-r2.log`. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmRLqg1PuH8D83b32SV <!-- signed: domain:ui#1 · os-steve · session_01ADHkmRLqg1PuH8D83b32SV --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent 2243872 commit e53e02e

43 files changed

Lines changed: 1267 additions & 9 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
'@object-ui/auth': patch
5+
'@objectstack/platform-objects': minor
6+
'@objectstack/spec': minor
7+
'@objectstack/plugin-auth': minor
8+
---
9+
10+
feat(console): a Mobile App page in the account app shows the code that connects the ObjectOS mobile app to this server
11+
12+
Clause-②: yes (widening) — a new account-app navigation entry and component (`account:mobile_app`), a new `mobileApp` namespace in the `@object-ui/i18n` packs, and a new optional `features.publicBaseUrl` served on `GET /api/v1/auth/config` (declared in `AuthFeaturesConfigSchema`, registered in `PUBLIC_AUTH_CONFIG_NON_FLAG_KEYS`, typed on `AuthPublicConfig`); nothing that worked before is refused
13+
Metadata-protocol: added
14+
15+
The account app (avatar menu → Profile) gains a **Mobile App** entry after Profile. Its page shows a QR code that encodes `objectos://connect?server=<this server's public base URL, URL-encoded>`, the same link as copyable text, and one line saying the code holds only the server's address, never the account.
16+
17+
`GET /api/v1/auth/config` now serves `features.publicBaseUrl`: the base URL the auth layer builds every link from (`OS_AUTH_URL`, then `BETTER_AUTH_URL`, then `OS_BASE_URL`), with any sub-path mount, as an address only (scheme, host and path; a credential, query or fragment in the setting is never served). The page encodes that URL. The page normalises it the same way again before use, so the code carries the server's address and nothing else. The browser's own address is never used, because it can be an internal or proxied host. When that URL names `localhost` or a private address, or a public host on plain `http:` (the mobile app signs in through it, so it must be HTTPS), the page shows no code and says how to fix it: set `OS_AUTH_URL` on the server to its public `https://` address and restart it. A server that does not publish the field gets a page saying it does not offer this yet.
18+
19+
No app-store links are shown: no setting carries them today.

‎content/docs/references/api/auth-endpoints.mdx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ const result = AuthEndpointSchema.parse(data);
7979
| **admin** | `boolean` | optional | Admin plugin wired (forced on whenever SCIM is enabled), so creating and impersonating users is available; the console shows those actions only when it is true. Banning, unbanning, unlocking and setting a password answer without it, and whether the console offers those actions does not depend on it. Absent means not wired |
8080
| **termsUrl** | `string` | optional | Terms-of-service link shown beneath the login and register cards: the trimmed OS_TERMS_URL value when set, otherwise the public ObjectStack terms page; absent when the operator set OS_TERMS_URL to an empty or blank (whitespace-only) value to suppress the link |
8181
| **privacyUrl** | `string` | optional | Privacy-policy link shown beneath the login and register cards: the trimmed OS_PRIVACY_URL value when set, otherwise the public ObjectStack privacy page; absent when the operator set OS_PRIVACY_URL to an empty or blank (whitespace-only) value to suppress the link |
82+
| **publicBaseUrl** | `string` | optional | This deployment's public base URL, the one the auth layer builds every link it hands out on: the configured baseUrl (OS_AUTH_URL, then BETTER_AUTH_URL, then OS_BASE_URL) with any sub-path it carries, https:// prepended to a bare host, and the loopback fallback when none is set. Served as an address only: scheme, host and path, with no trailing slash, credentials, query or fragment. The console encodes it in the mobile-app connect code, and refuses to when it names a loopback or private address or a public host on plain http. Absent when the configured value is not an absolute URL |
8283

8384
### Nested Shape: `AuthFeaturesConfig.organizationEditions[number]`
8485

@@ -230,6 +231,7 @@ This schema accepts one of the following structures:
230231
| **admin** | `boolean` | optional | Admin plugin wired (forced on whenever SCIM is enabled), so creating and impersonating users is available; the console shows those actions only when it is true. Banning, unbanning, unlocking and setting a password answer without it, and whether the console offers those actions does not depend on it. Absent means not wired |
231232
| **termsUrl** | `string` | optional | Terms-of-service link shown beneath the login and register cards: the trimmed OS_TERMS_URL value when set, otherwise the public ObjectStack terms page; absent when the operator set OS_TERMS_URL to an empty or blank (whitespace-only) value to suppress the link |
232233
| **privacyUrl** | `string` | optional | Privacy-policy link shown beneath the login and register cards: the trimmed OS_PRIVACY_URL value when set, otherwise the public ObjectStack privacy page; absent when the operator set OS_PRIVACY_URL to an empty or blank (whitespace-only) value to suppress the link |
234+
| **publicBaseUrl** | `string` | optional | This deployment's public base URL, the one the auth layer builds every link it hands out on: the configured baseUrl (OS_AUTH_URL, then BETTER_AUTH_URL, then OS_BASE_URL) with any sub-path it carries, https:// prepended to a bare host, and the loopback fallback when none is set. Served as an address only: scheme, host and path, with no trailing slash, credentials, query or fragment. The console encodes it in the mobile-app connect code, and refuses to when it names a loopback or private address or a public host on plain http. Absent when the configured value is not an absolute URL |
233235

234236

235237
---

‎packages/cli/test/connect-agent-both-halves-wire.pin.test.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,10 @@ describe('#17647 — Connect-an-Agent visibility: BOTH halves, over the wire', (
222222
.toEqual(['nav_connect_agent']);
223223
expect(groupChildren(account.body?.item, 'grp_account_developer'))
224224
.toEqual(['nav_account_api_keys', 'nav_account_oauth_apps']);
225-
// The whole served tree, counted: 12 authored ids (the AI Assistant
226-
// slot among them) + the one contributed.
227-
expect(navIds(account.body?.item)).toHaveLength(13);
225+
// The whole served tree, counted: 13 authored ids (the AI Assistant
226+
// slot among them) + the one contributed. (12 authored until the
227+
// Mobile App entry, `nav_account_mobile_app`, joined after Profile.)
228+
expect(navIds(account.body?.item)).toHaveLength(14);
228229
// …and the entry's TARGET rode along, so the menu item resolves.
229230
expect(JSON.stringify(account.body)).toContain('connect_agent');
230231

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
//
3+
// The account app's Mobile App entry sits right after Profile and targets the
4+
// component the Console registers as `account:mobile_app` (the app-shell half
5+
// of this pairing is pinned in `MobileAppPage.test.tsx`, which resolves the
6+
// same ref through the component registry). A bare nav-count pin elsewhere
7+
// shows that one id joined; this one shows which, where, and what it opens.
8+
import { describe, it, expect } from 'vitest';
9+
import { AppSchema } from '@objectstack/spec/ui';
10+
11+
import { ACCOUNT_APP } from './account.app.js';
12+
13+
type NavItem = { id?: string; type?: string; componentRef?: string; requiredPermissions?: unknown };
14+
15+
const topLevel = (): NavItem[] => (ACCOUNT_APP.navigation ?? []) as NavItem[];
16+
17+
describe("the account app's Mobile App entry", () => {
18+
it('sits immediately after Profile', () => {
19+
const ids = topLevel().map((item) => item.id);
20+
const profile = ids.indexOf('nav_account_profile');
21+
expect(profile, 'the account app lost its Profile entry').toBeGreaterThanOrEqual(0);
22+
expect(ids[profile + 1]).toBe('nav_account_mobile_app');
23+
});
24+
25+
it('opens the `account:mobile_app` component, ungated', () => {
26+
const entry = topLevel().find((item) => item.id === 'nav_account_mobile_app');
27+
expect(entry).toMatchObject({ type: 'component', componentRef: 'account:mobile_app' });
28+
expect(entry?.requiredPermissions).toBeUndefined();
29+
});
30+
31+
it('CONTROL: the app with the entry still parses as an App', () => {
32+
expect(AppSchema.safeParse(ACCOUNT_APP).success).toBe(true);
33+
});
34+
});

‎packages/platform-objects/src/apps/account.app.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ export const ACCOUNT_APP: App = {
7373
componentRef: 'account:profile_card',
7474
icon: 'user-circle',
7575
},
76+
// The QR code and link that connect the ObjectOS mobile app to this
77+
// server, registered by the Console as `account:mobile_app`. Built from
78+
// the server's published public base URL; every signed-in user may
79+
// connect their own phone, so the entry carries no gate.
80+
{
81+
id: 'nav_account_mobile_app',
82+
type: 'component',
83+
label: 'Mobile App',
84+
componentRef: 'account:mobile_app',
85+
icon: 'smartphone',
86+
},
7687

7788
// --- Inbox & work assigned to me -----------------------------------
7889
// Notifications, approvals waiting on me, and the orgs I belong to.

‎packages/platform-objects/src/apps/translations/ar.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const ar: TranslationData = {
1818
grp_account_developer: { label: 'المطوّر' },
1919
grp_account_ai_assistant: { label: 'مساعد الذكاء الاصطناعي' },
2020
nav_account_profile: { label: 'الملف الشخصي' },
21+
nav_account_mobile_app: { label: 'تطبيق الجوال' },
2122
nav_account_notifications: { label: 'الإشعارات' },
2223
nav_account_approvals: { label: 'بانتظار موافقتي' },
2324
nav_account_memberships: { label: 'مؤسساتي' },

‎packages/platform-objects/src/apps/translations/de.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const de: TranslationData = {
1818
grp_account_developer: { label: 'Entwickler' },
1919
grp_account_ai_assistant: { label: 'KI-Assistent' },
2020
nav_account_profile: { label: 'Profil' },
21+
nav_account_mobile_app: { label: 'Mobile-App' },
2122
nav_account_notifications: { label: 'Benachrichtigungen' },
2223
nav_account_approvals: { label: 'Meine ausstehenden Genehmigungen' },
2324
nav_account_memberships: { label: 'Meine Organisationen' },

‎packages/platform-objects/src/apps/translations/en.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export const en: TranslationData = {
3333
grp_account_developer: { label: 'Developer' },
3434
grp_account_ai_assistant: { label: 'AI Assistant' },
3535
nav_account_profile: { label: 'Profile' },
36+
nav_account_mobile_app: { label: 'Mobile App' },
3637
nav_account_notifications: { label: 'Notifications' },
3738
nav_account_approvals: { label: 'Approvals' },
3839
nav_account_memberships: { label: 'My Organizations' },

‎packages/platform-objects/src/apps/translations/es-ES.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const esES: TranslationData = {
1818
grp_account_developer: { label: 'Desarrollador' },
1919
grp_account_ai_assistant: { label: 'Asistente de IA' },
2020
nav_account_profile: { label: 'Perfil' },
21+
nav_account_mobile_app: { label: 'Aplicación móvil' },
2122
nav_account_notifications: { label: 'Notificaciones' },
2223
nav_account_approvals: { label: 'Aprobaciones pendientes' },
2324
nav_account_memberships: { label: 'Mis organizaciones' },

‎packages/platform-objects/src/apps/translations/fr.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const fr: TranslationData = {
1818
grp_account_developer: { label: 'Développeur' },
1919
grp_account_ai_assistant: { label: 'Assistant IA' },
2020
nav_account_profile: { label: 'Profil' },
21+
nav_account_mobile_app: { label: 'Application mobile' },
2122
nav_account_notifications: { label: 'Notifications' },
2223
nav_account_approvals: { label: 'Mes approbations en attente' },
2324
nav_account_memberships: { label: 'Mes organisations' },

0 commit comments

Comments
 (0)