diff --git a/FORK.md b/FORK.md index 04e651f1a8584..bb5c6b54274e1 100644 --- a/FORK.md +++ b/FORK.md @@ -439,7 +439,7 @@ migrations after upstream migrations. 68. The web testing skill matches what works on a headless host ([#546](https://github.com/Jacksondr5/j5code/issues/546), Jackson's 2026-10-11 decision: follow upstream's Browser panel, and edit its skill in place). `.agents/skills/test-t3-app/SKILL.md` keeps upstream's structure and voice. J5's edits: the state paths are `.j5code` and `~/.j5code/userdata`; the start command unsets the inherited port, host and home variables (see `AGENTS.md`); "Start the app" points at J5's `j5-live-test` skill; and "Use the Browser panel" is rewritten as the steps that worked when the panel was driven end to end on 2026-10-11 (open before judging availability, wait after pairing and after each move, read with `preview_evaluate`, retry once after a timeout, save screenshots at 1280x800, and which callers may act). Each step answers a failure seen in a test run; steps agents already get right are left out. J5's own testing practice is not in this file: it lives in J5-owned `.agents/skills/j5-live-test/`. On a pin advance, read upstream's changes to this skill and port them; if upstream documents the same panel steps, take upstream's wording and keep only the J5 paths and the `j5-live-test` pointer. 69. A connection whose person's scope is narrower than the server is narrowed to it ([#532](https://github.com/Jacksondr5/j5code/issues/532), [#636](https://github.com/Jacksondr5/j5code/issues/636), register D33, Jackson's 2026-10-09, 2026-10-11 and 2026-10-17 decisions). Upstream's permissions are per connection and cover the whole server. J5 reads, for each session, whose device it is (J5-owned `apps/server/src/j5/sharing/PersonAccess.ts`, `sessionReach`): a person's, by the binding case 70 records as the session is issued; the first owner's, by the subjects of the startup link, the desktop app, T3 Connect (`cloud-connect`, which upstream mints only for the cloud account the server is linked to) and the development credential; a service's (`peer:*`, `machine:*`, `mcp-client`, `cli-issued-session`); or a device no one has claimed. A service session and a person who holds Collaborator or Owner at server scope are wide and get upstream's own answers, the same objects. Everyone else is narrowed: a person at a project or a thread at either level, a Viewer at server scope, and an unclaimed device. A narrowed session is refused everything but an allow-list, every listed request is checked against the level the person holds at the scope it names, and the answers that name the host are reduced. All of it is J5-owned code under `apps/server/src/j5/sharing/`, reached from two upstream server files. In `apps/server/src/server.ts`, `layerAuth` is upstream's `EnvironmentAuth.layer` wrapped in `gateEnvironmentAuth` (`AccessGate.ts`): a narrowed session keeps its permissions only on the routes `accessHttpRule` allows (`/ws`, a reachable thread's loads, a preview tab's stream, downloads and uploads for a thread the person holds Collaborator on, and J5's artifact read for a reachable project), so every other route's own permission check refuses it. In `apps/server/src/ws.ts`, the per-connection `RpcAuthorization.layer(session.scopes, …)`, with upstream's feature-use recorder as its second argument, is wrapped in `layerRpcAuthorization`, which refuses a narrowed session every request not in `ACCESS_RPC_RULES` and checks each listed one: at a thread or project the payload names, at the level given (`thread`, `project`); for a person who holds Collaborator anywhere, whatever folder it names (`collaborator`: files, terminals' folders, git, previews' profiles, the host's devices; a terminal or an agent reaches every folder anyway, Jackson 2026-10-17), and the server's Playbook library, read only (AC20); for anyone (`anyone`: what a client reports of itself); for a person with a level at server scope (`server`: the Fleet page, Personas, the providers' skills, every Playbook run, read only); or answered narrowly by its handler (`narrowed`). Upstream's own permission check runs after J5's on every request, so what a level's permissions lack (settings, providers, access, relay management, environment maintenance) is refused by upstream. A request still running is ended when the person's reach changes so that it no longer meets its rule (`PersonAccess.subscribeChanges`). Whether a session is wide is read once, when the socket opens; a change that would alter it renews the session (case 70). `layerWsRpc` reads `connectionView(currentSession)` (`GuestView.ts`) once, and nine handlers pass their answer through it: `server.getConfig` (`Effect.map(j5View.config)`), `subscribeServerConfig` (`.pipe(j5View.configStream)`), `subscribeServerLifecycle` (`.pipe(j5View.lifecycleStream)`), `orchestration.subscribeShell` (`j5View.shellStream` around upstream's `subscribeOrchestrationV2Shell`), and `scheduledTasks.list` and `scheduledTasks.subscribe` (`j5View.scheduledTasks`, `j5View.scheduledTasksStream`), which list a narrowed person only the tasks bound to a thread they reach or, for a task bound to no thread, its project's, and give a Viewer no webhook address. Every narrowed session's thread shell, thread-detail stream and thread projection leave out `opens`, the last Cmd+K queries that picked the thread, which are the owner's searches, and upstream's `guestShare` (`subscribeThread` passes its stream through `.pipe(j5View.threadStream)` and `getThreadProjection` ends with `j5View.threadProjection`); `orchestration.searchThreads`, upstream's Cmd+K message search, is listed as `narrowed` and runs inside `j5View.searchThreads(input, (request, narrowed) => …)`, which hands upstream's `search` the threads the person reaches (`PersonAccess.reachableThreads`, the same parent rule as `threadLevel`; every thread for a level at server scope) and drops `olderSettledBefore`, `projectIds` and `environmentLabel`, since a narrowed sidebar has no older-settled cut and those rows are read from every settled thread ([#696](https://github.com/Jacksondr5/j5code/issues/696), Jackson 2026-10-31). The search is held to those threads in upstream's query, not filtered after it: `apps/server/src/orchestration-v2/ThreadSearch.ts` gains a server-only `threadIds` on `search`'s input and `SearchRequest`, one condition in `messageHitsQuery`'s `eligible` CTE, before the hit limit, and a `withoutOpens` input that ranks with no `opens`, so the owner's picks and open counts don't order a narrowed person's results. Upstream's global floor of the newest 10,000 index hits (and the scan's newest 20,000 messages without the index) still applies before the condition, as it does to the owner's hidden threads (Captain's ruling, 2026-10-31). A narrowed Collaborator's `thread.visit` is admitted with `opened` and `searchQuery` removed (`CommandAdmission.ts`, no upstream edit), so it moves the read marker and leaves `opens`; a Viewer's visit stays refused, unseen, since upstream's client sends it with `reportFailure: false`. Of the RPCs upstream added at that advance, `projects.listIgnoredFiles` and `device.easAccount` are listed as `collaborator`, like `projects.listEntries`, and `pullRequests.filterOptions` and `pullRequests.changeBreakdown` are not listed, as no `pullRequests.*` method is. The configuration is reduced for a Viewer and an unclaimed device (AC24) and given whole to a narrowed Collaborator, who can open a terminal on the host; the lifecycle welcome is reduced and the sidebar filtered for every narrowed session, and a Viewer's projects and threads carry placeholder folders where a Collaborator's carry the real ones. `apps/server/src/orchestration-v2/http.ts` is upstream's file: the HTTP sidebar snapshot (`GET /api/orchestration/shell`) is refused to a narrowed session, and upstream's client then reads the sidebar from the socket's feed (`packages/client-runtime/src/state/shell.ts` falls back when the HTTP load fails), so the feed is the one filtered path. A Viewer may ask `assets.createUrl` for an attachment or a tool's image only when `PersonAccess.messageAssetLevel` finds it in a thread they reach: in a message's attachments, or in a turn item's output, where a page a tool published is named; a Collaborator may ask for any asset. A favicon reaches a narrowed person through J5 and never by a host path (Jackson's 2026-10-12 decision; `GuestProjectIcons.ts`, no upstream edit): a reduced project carries `guestIconPath(projectId)` as its `faviconPath`, `ACCESS_RPC_RULES` reads the project id from a `project-favicon` request's `path`, checks `PersonAccess.projectInFeed`, and answers in place of upstream's handler with a link to `GET /api/j5/sharing/project-icon//`, signed with J5's own key, which serves the file through upstream's exported `issueAssetUrl`, `resolveAsset` and `assetFileResponse`. Both allow-lists refuse by default, so a route or request upstream adds is closed to a narrowed session until J5 lists it; `ACCESS_RPC_RULES` is keyed by the RPC group's method names, so a method upstream renames or removes fails to compile. Upstream's `ws.test.ts` gives `layerWsRpc` J5's sixth argument and mocks `PersonAccess` (a service session) and `SharedConversation`, so its sockets get upstream's own answers. The reduced configuration is built field by field (`reduceServerConfig`, `reduceProvider`), so a field upstream adds is left out for a Viewer until J5 lists it. The client half adds three J5 RPC groups and one call in each chat view: `J5AccessRpcGroup`, `J5PeopleRpcGroup` and `J5SharedConversationRpcGroup` (J5-owned `packages/contracts/src/j5/access.ts`, `people.ts` and `sharedConversation.ts`) are merged in `packages/contracts/src/rpc.ts`, and their streams (`j5.access.subscribeThreadLevel`, `j5.people.subscribeScopeChanges`, `j5.sharedConversation.subscribeThreadAuthorsChanges`) join `EnvironmentSubscriptionRpcTag` in `packages/client-runtime/src/rpc/client.ts` (one line each, the shape of cases 45 and 64); `packages/client-runtime/package.json` exports `./j5/sharing`. In `apps/server/src/ws.ts`, case 58's `layerJ5WsRpc(...)` call passes the connection's `session`, so the handlers answer for the session the socket was opened with. Upstream's web chat view (`apps/web/src/components/ChatView.tsx`) and mobile thread screen (`apps/mobile/src/features/threads/ThreadRouteScreen.tsx`) each call J5-owned `useCanOperateThread(environmentId, threadId)` from their app's `j5/sharing/access.ts` (web) or `j5/sharing/guestAccess.ts` (mobile) where they computed `canOperateThread` (one import and one call), and upstream's thread action menu (`apps/web/src/hooks/useThreadActionMenu.ts`) calls `readCanOperateThread(threadRef)` from `apps/web/src/j5/sharing/threadOperability.ts`. On a pin advance: keep the wrapping calls where the answers are produced; if upstream adds another place that sends a `ServerConfig`, a lifecycle event, a shell item or a list of scheduled tasks, a narrowed session cannot reach it until it is listed, and it must pass through `GuestView` when it is; if upstream changes how the shell feed resumes or what its items are, reread `GuestView.ts`; if upstream reshapes `messageHitsQuery`'s `eligible` CTE or ranks message hits by another per-thread record than `opens`, carry `threadIds` and `withoutOpens` with it, and if `searchThreadsWithOlderSettledRows` starts returning rows for something other than `olderSettledBefore`, drop that input for a narrowed connection too; if upstream's client stops falling back to the feed when the HTTP sidebar snapshot is refused, a narrowed person's sidebar stays empty; if upstream adds an asset kind or changes where attachments are named (`orchestration_v2_projection_messages` `$.attachments[].id`, or a turn item's payload), reread `messageAssetLevel`; if upstream reshapes its permissions, reread case 70's level mapping; if upstream changes how its client keys a favicon request or the three asset functions, reread `GuestProjectIcons.ts`, whose test runs upstream's real resolution. -70. Every device belongs to a person, holds its level's permissions, and renews when the level changes ([#535](https://github.com/Jacksondr5/j5code/issues/535), [#636](https://github.com/Jacksondr5/j5code/issues/636), register D33, Jackson's 2026-10-11 approval on [#531](https://github.com/Jacksondr5/j5code/issues/531) of one small edit inside upstream's pairing code, and his 2026-10-17 rulings). A level's permissions are listed in one place, J5-owned `packages/contracts/src/j5/levels.ts` (`LEVEL_PERMISSIONS`), and a device holds its person's highest level's set cut to the ceiling it was paired with (`devicePermissions`). Whose device a session is, and that ceiling, are recorded in J5's own table `j5_a2a_person_session` (J5 migrations 34 and 39) as upstream issues the session, without changing upstream's tables. The person a pairing credential is for is recorded in `j5_a2a_pairing_intent` (migration 39), found again by a hash of the credential because upstream's pairing code holds the credential when it issues a session. `apps/server/src/auth/EnvironmentAuth.ts` carries the edit, at seven sites: one import; two lines in `make` (`const j5TiedToPerson = yield* makePairingSessionIssuer` and `const j5ApprovesMcpClient = yield* makeMcpApprovalCheck`, each read with `Effect.serviceOption`, so upstream's own tests build the layer without them); one pipe step, `j5TiedToPerson(grant, credential)`, on each of the two `sessions.issue` calls that issue a session from a pairing grant (`createBrowserSession` and `exchangeBootstrapCredentialForAccessToken`); and one check in `consumeMcpApprovalCode`, so only a code an Owner's level backs approves an MCP client (`PairingIntents.approvesMcpClient`: not a J5 link's credential, subject `j5:link`, and not one whose intent names someone who is not an Owner); and the message a browser session from another origin is refused with is a named export, `FOREIGN_ORIGIN_DIAGNOSTIC`, so J5's renewal refuses what upstream refuses. Lowering or removing an Owner voids every MCP approval checked before it, however soon after the check it lands, and ends the MCP clients that Owner approved: J5-owned `McpApproval.layerGatedMcpOAuth` decorates upstream's `McpOAuth` (`apps/server/src/auth/McpOAuth.ts` is not edited), reads which change of Owners it is (`Access.ownersGeneration`, under the same lock as a change of level) and who approves (the person the pairing code's intent names, read before upstream spends it, or the person whose browser session approves) before upstream's `approve` checks the approval, ties both to the code in the redirect `approve` returns, and gives them to the exchange of that code; `layerGatedEnvironmentAuth` wraps `issueMcpClientSession` in `Access.issueMcpClient`, which refuses under that lock if the Owners changed since, or if no approval was given to it, and otherwise records the issued session as its approver's in J5's own table `j5_a2a_mcp_client_approver` (J5 migration 45), keyed by the session id upstream's `SessionStore.verify` reads from the token it issued. Lowering or removing that person as an Owner revokes those sessions upstream in the same transaction. Upstream's MCP sign-in issues no refresh token, so a client's session is never replaced under a new id; an MCP client approved before migration 45, or with a code that names no one (the first owner's), has no approver and is ended by hand. In `server.ts`, `McpOAuth.layer` is wrapped in `gateMcpOAuth` where `McpOAuthHttp.layer` is given it (one import and one line). For a credential with no intent the pipe step costs one read by primary key and returns upstream's own effect, and binds the session to the first owner when the credential is the startup link's, the desktop app's or T3 Connect's (`FIRST_OWNER_SUBJECTS`; if upstream mints another credential for the server's own account, add its subject there, or its device is one no one has claimed). For one with an intent it runs upstream's `sessions.issue` and the binding in one transaction (`PairingIntents.issueSession`), so the session and the record of whose it is commit together, and it issues nothing when the credential carries more than its person may hold now, when its person was removed, or when it carries the retired guest subject `j5:guest`. In `apps/server/src/server.ts`, `layerAuth` (case 69) gains one line, `Layer.provideMerge(J5PeopleLive)`, above `layerPersistence`: it gives `PersonAccess` and `PairingIntents` to upstream's `EnvironmentAuth.layer` and to J5's own services. `apps/server/src/auth/http.ts`'s `pairingCredential` handler, which Connections' "Create link" calls, records after `issuePairingCredential` that the link pairs a device for the person whose device made it, under the permissions chosen there (`recordConnectionsLinkCreator`; one import and one call, piped through `Effect.provideService` with the `SessionStore` upstream's layer reads when it is built); a link whose maker cannot be recorded is revoked before the request fails, and that includes one whose maker's session is no one's and no longer live (its person was removed while the link was made), so no such link approves an MCP client as no one. A change of level ends each of the person's sessions for renewal (`Access.ts`): the binding is marked and upstream's `SessionStore.revoke` ends the session, which closes its open sockets at once, in the transaction that changes the level. The device then renews on J5's route `POST /api/j5/session/renew` (`SessionRenewal.ts`, no upstream edit) with its old token: upstream's `SessionStore.verify` checks a token's signature before whether it was revoked and names a revoked token's session, so the route issues a session that holds the new permissions, with the old session's method, subject, client and expiry, only for a session J5 marked, once. `apps/web/src/environments/primary/auth.ts` calls `renewPrimarySession` before its sign-in gate sends a browser to pair (one import and one line), and J5-owned `SessionRenewalWatcher` reloads the page once when the primary connection drops and renewal succeeds. `apps/web/src/connection/runtime.ts` adds J5-owned `@t3tools/client-runtime/j5/session-renewal` to the connection runtime (one import and one line), which renews a saved server's bearer token when its connection is refused for authentication; `packages/client-runtime/package.json` exports it. `apps/mobile/src/connection/runtime.ts` adds the same layer to mobile's connection runtime (one import and one line), and `apps/mobile/src/App.tsx` mounts J5-owned `NameQuestionHost` (`apps/mobile/src/j5/sharing/NameQuestion.tsx`) beside upstream's `Dialog.Host` (one import and one line): it asks a device a saved server cannot place, or the first owner with no name, the name question before the device uses that server (AC5, AC6), as web's `NameDialog` does, with the rule shared in `packages/client-runtime/src/j5/sharing.ts` (`serverToAskNameFor`). DPoP sessions and a device offline past its session's life are paired again by hand; an MCP client holds no person's level, so a change of level does not touch it, except that lowering or removing an Owner ends the ones they approved. The refusal of a browser paired as one person opening a link made for another reaches the pairing page with its reason through three upstream files, each a line or a literal: `packages/contracts/src/environmentHttp.ts` (`EnvironmentAuthInvalidError`'s optional `pairingRefusal: "paired_as_someone_else"`), `apps/server/src/auth/http.ts` (`failEnvironmentAuthInvalid`'s third argument, passed by the `browserSession` handler), and `apps/web/src/environments/primary/auth.ts` (the rejected-credential error's flag). `layerGatedEnvironmentAuth` (case 69's J5-owned decorator, in `j5/sharing/AccessGate.ts`, which passes on the `use` argument upstream's `authenticateWebSocketUpgrade` takes since stable v0.1.3) wraps `createBrowserSession` to refuse that before upstream is called, so the link is not used up, and wraps `revokeSession`, `revokeClientSession`, `revokeOtherSessionsExcept` and `revokeOtherClientSessions` so that ending a device cuts it loose from its person first, and with that from any renewal. On a pin advance: if upstream adds another place that turns a pairing grant into a session, it must go through `j5TiedToPerson`, or the device is one no one has claimed; if upstream reshapes its permissions, update `LEVEL_PERMISSIONS` and the definition (`levelPermissions.test.ts` pins each level's set by upstream's names); if upstream adds a method that ends a session, wrap it in the decorator; if upstream changes `SessionStore.verify`'s order of checks or stops naming a revoked token's session, renewal stops working and must be rethought; if upstream adds a pairing path that issues a session from something other than a pairing grant, record whose its sessions are or narrow them; if upstream changes how it refuses a browser session from another origin, keep `FOREIGN_ORIGIN_DIAGNOSTIC` the message it refuses with; if upstream adds a refresh grant or any other way to renew an MCP client's session under a new id, record the new session as the old one's approver's, or lowering that Owner leaves it live; if upstream stops returning the code in `approve`'s redirect, or issues an MCP client's session other than from `exchangeCode` through `EnvironmentAuth.issueMcpClientSession`, every MCP sign-in is refused (`McpApproval.test.ts` runs upstream's own sign-in through the gate) and the tie must be rethought; if upstream provides `McpOAuth.layer` somewhere else, wrap it there too. +70. Every device belongs to a person, holds its level's permissions, and renews when the level changes ([#535](https://github.com/Jacksondr5/j5code/issues/535), [#636](https://github.com/Jacksondr5/j5code/issues/636), register D33, Jackson's 2026-10-11 approval on [#531](https://github.com/Jacksondr5/j5code/issues/531) of one small edit inside upstream's pairing code, and his 2026-10-17 rulings). A level's permissions are listed in one place, J5-owned `packages/contracts/src/j5/levels.ts` (`LEVEL_PERMISSIONS`), and a device holds its person's highest level's set cut to the ceiling it was paired with (`devicePermissions`). Whose device a session is, and that ceiling, are recorded in J5's own table `j5_a2a_person_session` (J5 migrations 34 and 39) as upstream issues the session, without changing upstream's tables. The person a pairing credential is for is recorded in `j5_a2a_pairing_intent` (migration 39), found again by a hash of the credential because upstream's pairing code holds the credential when it issues a session. `apps/server/src/auth/EnvironmentAuth.ts` carries the edit, at seven sites: one import; two lines in `make` (`const j5TiedToPerson = yield* makePairingSessionIssuer` and `const j5ApprovesMcpClient = yield* makeMcpApprovalCheck`, each read with `Effect.serviceOption`, so upstream's own tests build the layer without them); one pipe step, `j5TiedToPerson(grant, credential)`, on each of the two `sessions.issue` calls that issue a session from a pairing grant (`createBrowserSession` and `exchangeBootstrapCredentialForAccessToken`); and one check in `consumeMcpApprovalCode`, so only a code an Owner's level backs approves an MCP client (`PairingIntents.approvesMcpClient`: not a J5 link's credential, subject `j5:link`, and not one whose intent names someone who is not an Owner); and the message a browser session from another origin is refused with is a named export, `FOREIGN_ORIGIN_DIAGNOSTIC`, so J5's renewal refuses what upstream refuses. Lowering or removing an Owner voids every MCP approval checked before it, however soon after the check it lands, and ends the MCP clients that Owner approved: J5-owned `McpApproval.layerGatedMcpOAuth` decorates upstream's `McpOAuth` (`apps/server/src/auth/McpOAuth.ts` is not edited), reads which change of Owners it is (`Access.ownersGeneration`, under the same lock as a change of level) and who approves (the person the pairing code's intent names, read before upstream spends it, or the person whose browser session approves) before upstream's `approve` checks the approval, ties both to the code in the redirect `approve` returns, and gives them to the exchange of that code; `layerGatedEnvironmentAuth` wraps `issueMcpClientSession` in `Access.issueMcpClient`, which refuses under that lock if the Owners changed since, or if no approval was given to it, and otherwise records the issued session as its approver's in J5's own table `j5_a2a_mcp_client_approver` (J5 migration 45), keyed by the session id upstream's `SessionStore.verify` reads from the token it issued. Lowering or removing that person as an Owner revokes those sessions upstream in the same transaction. Upstream's MCP sign-in issues no refresh token, so a client's session is never replaced under a new id; an MCP client approved before migration 45, or with a code that names no one (the first owner's), has no approver and is ended by hand. In `server.ts`, `McpOAuth.layer` is wrapped in `gateMcpOAuth` where `McpOAuthHttp.layer` is given it (one import and one line). For a credential with no intent the pipe step costs one read by primary key and returns upstream's own effect, and binds the session to the first owner when the credential is the startup link's, the desktop app's or T3 Connect's (`FIRST_OWNER_SUBJECTS`; if upstream mints another credential for the server's own account, add its subject there, or its device is one no one has claimed). For one with an intent it runs upstream's `sessions.issue` and the binding in one transaction (`PairingIntents.issueSession`), so the session and the record of whose it is commit together, and it issues nothing when the credential carries more than its person may hold now, when its person was removed, or when it carries the retired guest subject `j5:guest`. In `apps/server/src/server.ts`, `layerAuth` (case 69) gains one line, `Layer.provideMerge(J5PeopleLive)`, above `layerPersistence`: it gives `PersonAccess` and `PairingIntents` to upstream's `EnvironmentAuth.layer` and to J5's own services. `apps/server/src/auth/http.ts`'s `pairingCredential` handler, which Connections' "Create link" calls, records after `issuePairingCredential` that the link pairs a device for the person whose device made it, under the permissions chosen there (`recordConnectionsLinkCreator`; one import and one call, piped through `Effect.provideService` with the `SessionStore` upstream's layer reads when it is built); a link whose maker cannot be recorded is revoked before the request fails, and that includes one whose maker's session is no one's and no longer live (its person was removed while the link was made), so no such link approves an MCP client as no one. A change of level ends each of the person's sessions for renewal (`Access.ts`): the binding is marked and upstream's `SessionStore.revoke` ends the session, which closes its open sockets at once, in the transaction that changes the level. The device then renews on J5's route `POST /api/j5/session/renew` (`SessionRenewal.ts`, no upstream edit) with its old token: upstream's `SessionStore.verify` checks a token's signature before whether it was revoked and names a revoked token's session, so the route issues a session that holds the new permissions, with the old session's method, subject, client and expiry, only for a session J5 marked, once. `apps/web/src/environments/primary/auth.ts` calls `renewPrimarySession` before its sign-in gate sends a browser to pair (one import and one line), and J5-owned `SessionRenewalWatcher` reloads the page once when the primary connection drops and renewal succeeds. `apps/web/src/connection/runtime.ts` adds J5-owned `@t3tools/client-runtime/j5/session-renewal` to the connection runtime (one import and one line), which renews a saved server's bearer token when its connection is refused for authentication; `packages/client-runtime/package.json` exports it. `apps/mobile/src/connection/runtime.ts` adds the same layer to mobile's connection runtime (one import and one line), and `apps/mobile/src/App.tsx` mounts J5-owned `NameQuestionHost` (`apps/mobile/src/j5/sharing/NameQuestion.tsx`) beside upstream's `Dialog.Host` (one import and one line): it asks a device a saved server cannot place, or the first owner with no name, the name question before the device uses that server (AC5, AC6), as web's `NameDialog` does, with ways out that touch only that server: "Remove this server", and for a device the server cannot place "Not now" until the app next starts ([#870](https://github.com/Jacksondr5/j5code/issues/870)), with the rule shared in `packages/client-runtime/src/j5/sharing.ts` (`serverToAskNameFor`). DPoP sessions and a device offline past its session's life are paired again by hand; an MCP client holds no person's level, so a change of level does not touch it, except that lowering or removing an Owner ends the ones they approved. The refusal of a browser paired as one person opening a link made for another reaches the pairing page with its reason through three upstream files, each a line or a literal: `packages/contracts/src/environmentHttp.ts` (`EnvironmentAuthInvalidError`'s optional `pairingRefusal: "paired_as_someone_else"`), `apps/server/src/auth/http.ts` (`failEnvironmentAuthInvalid`'s third argument, passed by the `browserSession` handler), and `apps/web/src/environments/primary/auth.ts` (the rejected-credential error's flag). `layerGatedEnvironmentAuth` (case 69's J5-owned decorator, in `j5/sharing/AccessGate.ts`, which passes on the `use` argument upstream's `authenticateWebSocketUpgrade` takes since stable v0.1.3) wraps `createBrowserSession` to refuse that before upstream is called, so the link is not used up, and wraps `revokeSession`, `revokeClientSession`, `revokeOtherSessionsExcept` and `revokeOtherClientSessions` so that ending a device cuts it loose from its person first, and with that from any renewal. On a pin advance: if upstream adds another place that turns a pairing grant into a session, it must go through `j5TiedToPerson`, or the device is one no one has claimed; if upstream reshapes its permissions, update `LEVEL_PERMISSIONS` and the definition (`levelPermissions.test.ts` pins each level's set by upstream's names); if upstream adds a method that ends a session, wrap it in the decorator; if upstream changes `SessionStore.verify`'s order of checks or stops naming a revoked token's session, renewal stops working and must be rethought; if upstream adds a pairing path that issues a session from something other than a pairing grant, record whose its sessions are or narrow them; if upstream changes how it refuses a browser session from another origin, keep `FOREIGN_ORIGIN_DIAGNOSTIC` the message it refuses with; if upstream adds a refresh grant or any other way to renew an MCP client's session under a new id, record the new session as the old one's approver's, or lowering that Owner leaves it live; if upstream stops returning the code in `approve`'s redirect, or issues an MCP client's session other than from `exchangeCode` through `EnvironmentAuth.issueMcpClientSession`, every MCP sign-in is refused (`McpApproval.test.ts` runs upstream's own sign-in through the gate) and the tie must be rethought; if upstream provides `McpOAuth.layer` somewhere else, wrap it there too. 71. An Owner shares from the app ([#535](https://github.com/Jacksondr5/j5code/issues/535), [#636](https://github.com/Jacksondr5/j5code/issues/636), register D33, Jackson's 2026-10-12 design and approval of an appended item in the thread menu, and the 2026-10-17 design review of the one Share dialog). The Share dialog (one for a thread, a project and the server), the link step and their state are J5-owned files under `apps/web/src/j5/sharing/`. Upstream's thread action menu (`apps/web/src/hooks/useThreadActionMenu.ts`, already carrying case 69's one call) gains one import and two calls: the list upstream's `buildThreadActionMenuItems` returns is passed through `withSharingMenuItems(items, threadRef)`, and after the menu closes `if (runSharingMenuAction(clicked.value, threadRef)) return;` opens the dialog J5 asked for and keeps J5's ids away from upstream's switch. `withSharingMenuItems` inserts "Share thread…" after "Copy" (disabled on a device without `access:write`, People and access AC34). For someone who is not an Owner of the thread's server it also leaves out Archive, Delete and "Project settings" (AC14, AC27), leaves out "Mark unread" for a Viewer of the thread (the read marker is everyone's, Shared conversations AC19), and puts "Leave thread" where Archive was when they hold a level on the thread itself (AC48). The ids (`j5:share-thread`, `j5:leave-thread`) are outside upstream's `ThreadActionMenuId` union, and `runSharingMenuAction` is the type guard that takes them back out, so upstream's `components/threadActionMenu.logic.ts` is untouched. `apps/web/src/hooks/useThreadActionMenu.test.ts` carries two J5 cases at its end (the item's place, and that picking it reaches none of upstream's actions). Upstream's sidebar builds and handles the same menu itself (`apps/web/src/components/Sidebar.tsx`, the thread row's right-click): one import, the builder wrapped where the list is built, `buildWithSharingMenuItems(buildThreadActionMenuItems, threadRef)({…})`, which leaves upstream's arguments where they are, and the same `if (runSharingMenuAction(clicked.value, threadRef)) return;` after the menu closes. The dialogs are opened from places that render nothing, so `apps/web/src/routes/__root.tsx` mounts J5's `` beside upstream's `` (one import, one line), the way upstream draws its own confirm and custom-snooze dialogs; the host also draws the name question a server asks before a device uses it (AC5, AC6), renews a session ended for a change of level (case 70), tells an Owner once that links made before the move to levels stopped working, and takes someone off a thread no longer theirs. `apps/web/src/components/CommandPalette.tsx` gains one import, one hook call (`useSharingPaletteItems({ activeThread, projectRef: contextualProjectRef })`, beside where `actionItems` is declared) and `actionItems.push(...sharingPaletteItems)` before the "Project settings" entry, for "Share thread", "Share project", "Share server", "Open People" and "Change your name"; the palette searches an entry's `searchTerms` only, so each entry's title is among its terms (Jackson's 2026-10-12 approval). The web menu draws an item's icon from the table in `apps/web/src/contextMenuFallback.ts`, which gains one entry, `users` (lucide's four shapes, six lines and a comment), so that J5's item lines up with its neighbours. `j5/sharing/sharingMenu.ts` and `sharingDialogs.ts` import nothing of React or the connection runtime, because that test mocks `react`. A link always opens on the server itself; the link step's route choice mirrors helpers that are private to upstream's `apps/web/src/components/settings/ConnectionsSettings.tsx` (`selectPairingEndpoint`'s default, `endpointDefaultPreferenceKey`, `endpointShareHint`), copied into J5-owned `j5/sharing/shareLink.logic.ts` with no upstream edit; what upstream already exports (`isQrShareableEndpoint`, `selectQrEndpointOption`, `pairingUrls.ts`, `QRCodeSvg`, the saved default route in `uiStateStore`) is imported. On a pin advance: compare those helpers with upstream's and carry over any change to how a route is picked or described; if upstream moves `api.contextMenu.show(items, position)` in the hook, re-apply the two calls around it, and the same in the sidebar's thread-row menu; if the palette's `actionItems` list or the root's dialog hosts move, re-apply the append and the mount where they went; if upstream renames the "copy", "archive", "delete", "project-settings" or "mark-unread" items, "Share thread…" falls to the end of the menu or an Owner's item shows to someone who is not one, and `sharingMenu.test.ts` still passes, so check both menus in a browser. 72. Settings › People, and Settings for someone who is not an Owner ([#535](https://github.com/Jacksondr5/j5code/issues/535), [#636](https://github.com/Jacksondr5/j5code/issues/636), register D33, Jackson's 2026-10-12 design and approval of the Settings navigation and route registration, and his 2026-10-17 ruling that Settings is an Owner's). The page (`apps/web/src/j5/sharing/PeoplePage.tsx`) and everything it draws are J5-owned; `apps/web/src/routes/_chat.settings.people.tsx` is a J5-owned route file in upstream's routes folder, the shape of `_chat.settings.skills.tsx` (case 42), and `routeTree.gen.ts` regenerates with it. Upstream moved Settings under the chat layout at v0.1.3, where it opens as a large modal over the thread (pingdotgg/t3code#24847), so J5's three Settings routes (People, Personas and Skills) moved from `settings.*.tsx` to `_chat.settings.*.tsx` with it. Registering a settings section takes upstream's own tables, each one entry: in `apps/web/src/components/settings/settingsSearch.ts` the `SettingsPath` union, `SETTINGS_SECTION_LABELS`, `SETTINGS_NAV_GROUPS` (People last in the Connections group, after Sharing & access; Personas and Skills first in the Agents group), `SETTINGS_CATEGORY_SCOPES` (`"connections"`) and one search item, `people`; in `SettingsSidebarNav.tsx` the icon map (`UsersIcon`); in `SettingsScopeSentence.tsx` one line adding the path to `SETTINGS_DEVICE_ONLY_PATHS`, since the page has its own server picker, and one more adding Open-source licenses, which is the same for every server and which a non-Owner sees, so it shows no server picker. Settings is an Owner's (AC27 to AC29), by four calls into J5-owned `j5/sharing/settingsAccess.tsx`, each one import and one or two lines. `SettingsSidebarNav.tsx` builds its groups through `useSettingsNavGroups(SETTINGS_NAV_GROUPS)` in place of upstream's groups, and highlights a page that list names before upstream's detail-page parent: for someone who owns no connected server it keeps only the pages in `PAGES_FOR_EVERYONE` (Appearance, SnapShots, People and Open-source licenses) and adds Open-source licenses, which upstream reaches only from About, as a group of its own (a `SettingsPath`, `/settings/open-source-licenses`, with its label, icon and scope). `useAvailableSettingsSearchItems.ts` returns `useShownSettingsSearchItems(items)`, so search finds the same pages, in the sidebar and the command palette alike. `apps/web/src/routes/_chat.settings.tsx` (upstream's `routes/settings.tsx` until v0.1.3) wraps upstream's `SettingsScopeBoundary` and the `` in ``, which shows that person a "Coming soon" notice in place of any other page, one upstream adds later among them, so a link to one (a thread's "Manage scheduled tasks") still lands; the gate is outside the boundary because a server the person does not own leaves the boundary's scope unavailable. `SettingsScopeContext.tsx` and `SettingsScopeSentence.tsx` read their servers through `useOwnedEnvironments(useEnvironments().environments)`, and `useSettingsProjectGroups.ts` its projects through `useOwnedEnvironments(useProjects())`, so Settings lists and changes only the servers and projects the person owns, in the scope picker and the project panel alike; upstream applies a change to every listed server and greys a row unless all of them allow it. Upstream's `ProjectSettingsPanel.browser.test.tsx` mocks `useOwnedEnvironments` as owning every listed server, since ownership is not what it tests. J5's Fleet page and inbox, which name a project from any server, group every server's projects themselves (`j5/logicalProjects.ts`). A server that has not answered yet counts as owned, so an Owner's Settings does not flicker. J5's own Settings pages (Personas, Playbooks, Skills) list only owned servers the same way. The project page carries no Sharing section (AC34). On a pin advance: if upstream reshapes how a settings section is declared, re-register People in the Connections group; if upstream resolves Settings' servers anywhere besides those two files, filter it there too, or a server the person does not own greys out their Settings; if upstream renames the Appearance or SnapShots path, update `PAGES_FOR_EVERYONE` (its test pins the list); if upstream adds a settings page of its own for people or access, read D33 before keeping J5's. Mobile follows the same rule ([#831](https://github.com/Jacksondr5/j5code/issues/831)) through three calls into J5-owned `apps/mobile/src/j5/sharing/settingsAccess.tsx`, each one import and one or two lines: `features/settings/SettingsRouteScreen.tsx` passes the index's sections through `useShownSettingsSections`, so for someone who owns no connected server only the device's own pages are listed (`PAGES_FOR_EVERYONE` in `settingsAccess.logic.ts`, by route name: look and input, saved servers, notifications, About and what it opens) and search finds only those; `features/settings/components/SettingsScreen.tsx`, the frame of nearly every Settings page, renders its children through `useOwnerOnlySettingsPage(route.name, …)`, which puts the same "Coming soon" notice in place of any other Settings page reached by a link, the command palette or a thread's "Manage scheduled tasks"; `features/settings/settings-environment-filter.tsx` reads its servers through `useOwnedSettingsTargets`, so mobile Settings lists and changes only the servers the person owns; and `Stack.tsx` registers Archive, the one Settings page drawn without `SettingsScreen`, as `ownerOnlySettingsRoute(ArchivedThreadsRouteScreen, "Archive")` (J5-owned `j5/sharing/ownerOnlySettingsRoute.tsx`), which for that person mounts an empty `SettingsScreen` in its place, so the notice shows under Archive's header and the archive is never read. For an Owner, `features/archive/ArchivedThreadsRouteScreen.tsx` passes its saved servers through `useOwnedSettingsTargets` (upstream's list renamed `savedEnvironments`, and one line), so Archive lists, reads and acts on only the servers they own, as web's Archive does through its Settings scope. Mobile's Personas and Playbooks pages list owned servers the same way, and a thread's Playbook progress is read by anyone who reads the thread, as on web. On a pin advance: if upstream renames a mobile Settings route that is the device's own, update `PAGES_FOR_EVERYONE`; if upstream draws another Settings page without `SettingsScreen`, register it through `ownerOnlySettingsRoute` too, or it is not gated. 73. A thread says who reaches it, and the client fits what a person's level lets them do ([#535](https://github.com/Jacksondr5/j5code/issues/535), [#541](https://github.com/Jacksondr5/j5code/issues/541), [#636](https://github.com/Jacksondr5/j5code/issues/636), register D33, Jackson's 2026-10-12 design and approval of one mount or item in each of these files, and his 2026-10-13 approvals of the route files and of the two edits that quiet what could only fail). All of it is J5-owned code under `apps/web/src/j5/sharing/`, mounted once in each upstream file, and it reads what the server says the connection is (`j5.access.getConnectionAccess`, read again when people or levels change) and the level it holds over each thread (`j5.access.subscribeThreadLevel`). `apps/web/src/components/chat/ChatHeader.tsx`: one import and `` after the breadcrumb, for a server thread; it draws nothing unless more than one person reaches the thread. `apps/web/src/components/chat/ThreadDetailsPanel.tsx`: one import and `` after `ThreadRelationshipsPanel`, under the same `density === "full" && !props.draftId` condition as its neighbours; and `const readOnly = !useCanOperateThread(…)` with `&& !readOnly` on the condition that mounts upstream's `ThreadAutomationsPanel`, so a Viewer of the thread sees no Automations. `apps/web/src/components/chat/ChatComposer.tsx`: one import, one hook call after the props are read (`useViewOnlyComposerProps(environmentId, canOperateThread)`), and one spread, `{...viewOnlyComposerProps}`, after upstream's `placeholder={…}` prop, so that someone who is not an Owner and cannot write to the thread reads "You can read this thread, but not send anything to it."; the collapsed composer's fallback literal becomes `(viewOnlyComposerProps.placeholder ?? "Ask anything...")`. The chip and the section ask the server who reaches the thread (`j5.people.listScope`) and ask again when its counter moves (`j5.people.subscribeScopeChanges`). Two route files carry a person's way in. `apps/web/src/routes/pair.tsx`: the import of upstream's `PairingRouteSurface` becomes J5's `JoinLinkPairingSurface`, and the JSX tag changes with it (three lines; upstream's `components/auth/PairingRouteSurface.tsx` is not edited). J5's surface asks `POST /api/j5/links/describe` what a link opens, without spending it, only for a link that carries J5's mark, and waits up to five seconds; everything else gets upstream's surface with the props it was given, and an ordinary pairing token is sent nowhere but upstream's own exchange. The person confirms or types their name and joins on `POST /api/j5/links/join`, which answers with an upstream pairing credential the page exchanges at once. The Share dialog puts the mark, `j5share=1`, in the fragment beside upstream's `token`; upstream reads the fragment as parameters and takes only `token`. `apps/web/src/routes/_chat.index.tsx`: one import, and `` is wrapped in ``, which renders its child at once for anyone at server scope and before the server answers, and for someone who reaches less shows their one thread, a list, or that nothing is shared with them (AC30). `apps/web/src/routes/__root.tsx`: one import, one hook call beside `primaryEnvironmentAuthenticated`, `useFirstRunSetupOffered(primaryEnvironmentAuthenticated)`, and `FirstRunGate`'s `enabled` reads its answer: the wizard is offered only to an Owner of the primary server the server has a name for, by that server's answer, so the name is asked first (AC6), and upstream's gate decides again when the answer arrives; a failed or missing answer offers nothing. `apps/web/src/routes/welcome.tsx`, the wizard's own address, gains one import and two lines before its return, `const setupRefusal = useSetupWizardRefusal(localAvailable); if (setupRefusal !== null) return setupRefusal;`, which draws nothing until the primary server answers and then sends anyone the wizard is not offered to to the first screen, where the name is asked; the hosted app, with no server of its own, is left to upstream. `apps/web/src/components/Sidebar.tsx`: one import, `const isNarrowEverywhere = useIsNarrowEverywhere()` beside the primary environment's id, and `&& !isNarrowEverywhere` on the empty list's `projects.length === 0` condition, so someone who reaches no whole server reads upstream's "No threads yet" in place of an "Add project" button that could only fail. One more quiets an upstream notice a person sees fail (J5-owned `apps/web/src/j5/sharing/upstreamNotices.ts`; Jackson's standing permission on this workstream for one import and one or two lines, used 2026-10-18): `apps/web/src/components/PermissionUpdateNotice.ts` (one import and one condition) lists in `legacyPermissionEnvironmentsAtom` only the servers J5's `permissionNoticeEnvironmentIdsAtom` names, which leaves out a server that places the connection as a person or a device it will ask about, and one that has not answered yet, as J5 sets and renews those permissions from the person's level, so "Pair again" never applies. Mobile's copy of the notice gets the same condition ([#831](https://github.com/Jacksondr5/j5code/issues/831)): `apps/mobile/src/features/connection/permissionUpdateNotice.ts` (one import and one condition) reads J5-owned `apps/mobile/src/j5/sharing/upstreamNotices.ts`, and the rule, `permissionNoticeApplies`, now lives once in `packages/client-runtime/src/j5/sharing.ts` for both clients. Upstream turned the notice from a component (`PermissionUpdateNotice.tsx`) into an atom and a coordinator that starts with the app at v0.1.3 (pingdotgg/t3code#25233), so J5's hook became that atom. The second, which showed upstream's provider updates notice only to a connection holding Manage providers, retired at the 2026-10-24 advance with the notice itself: upstream deleted `ProviderUpdateLaunchNotification` (pingdotgg/t3code#23233). Upstream also replaced `PermissionUpdateNotice`'s jsdom test, where J5 mocked the hook, with a browser test J5 does not edit. On a pin advance: if upstream moves the composer's `placeholder` prop, keep the spread after it; if upstream renames `legacyPermissionEnvironmentsAtom`, filter the notice's servers where they moved; if upstream reorders the details panel, keep People after Lineage and the condition on the Automations mount; if upstream changes how a pairing address carries its token, or starts to refuse a fragment it does not know, reread `SHARE_LINK_MARK` in J5-owned `packages/contracts/src/j5/sharing.ts`; if upstream renames `PairingRouteSurface` or changes its props, J5's surface fails to compile; if upstream's index route stops rendering `IndexDraftLanding`, re-wrap whatever it renders; if upstream renames `FirstRunGate`'s `enabled`, or decides first run before `enabled` can change, someone who is not an Owner may be offered the wizard. diff --git a/apps/mobile/src/j5/sharing/NameQuestion.tsx b/apps/mobile/src/j5/sharing/NameQuestion.tsx index 7c8505c40cb50..f147a9777660d 100644 --- a/apps/mobile/src/j5/sharing/NameQuestion.tsx +++ b/apps/mobile/src/j5/sharing/NameQuestion.tsx @@ -14,6 +14,8 @@ import { KeyboardAvoidingView } from "react-native-keyboard-controller"; import { SafeAreaView } from "react-native-safe-area-context"; import { AppText as Text, AppTextInput as TextInput } from "../../components/ui/AppText"; +import * as Dialog from "../../components/ui/Dialog"; +import { environmentCatalog } from "../../connection/catalog"; import { Button } from "../../components/ui/Button"; import { ListChoiceRow } from "../../components/ui/ListChoiceRow"; import { ListSection } from "../../components/ui/ListSection"; @@ -22,7 +24,7 @@ import { environmentPresentations } from "../../state/presentation"; import { useEnvironmentQuery } from "../../state/query"; import { useAtomCommand } from "../../state/use-atom-command"; import { j5Sharing } from "./guestAccess"; -import { identityCommands, nameToAskAtom } from "./identity"; +import { identityCommands, nameToAskAtom, putOffNameQuestionsAtom } from "./identity"; const SOMEONE_NEW = "new"; @@ -38,8 +40,9 @@ export function NameQuestionHost() { /** * "What should people and agents on call you?", asked before a device uses the server - * (People and access AC5, AC6), as web's `NameDialog` asks it. There is no way to put it off: - * until it is answered the device reaches nothing there. + * (People and access AC5, AC6), as web's `NameDialog` asks it. A device the server cannot place may + * put it off with "Not now" until the app next starts, and anyone may forget the server with + * "Remove this server"; both touch only this server. */ function NameQuestion({ environmentId, @@ -57,6 +60,7 @@ function NameQuestion({ const setFirstOwnerName = useAtomCommand(identityCommands.setFirstOwnerName, { reportFailure: false, }); + const removeServer = useAtomCommand(environmentCatalog.remove, "environment remove"); const people = kind === "claim" ? (claimable.data?.people ?? []) : []; const [choice, setChoice] = useState(SOMEONE_NEW); const [name, setName] = useState(""); @@ -100,6 +104,23 @@ function NameQuestion({ j5Sharing.refreshConnectionAccess(appAtomRegistry, environmentId); }; + const putOff = () => + appAtomRegistry.update(putOffNameQuestionsAtom, (ids) => new Set([...ids, environmentId])); + + const confirmRemove = () => + Dialog.alert( + "Remove from this device?", + `Forget ${serverName} and its cached threads on this device. Your other servers stay as they are.`, + [ + { text: "Cancel", style: "cancel" }, + { + text: "Remove", + style: "destructive", + onPress: () => void removeServer(environmentId), + }, + ], + ); + const nameInput = (label: string) => ( {}}> {/* Inline flex: on Android a `flex-1` class left this Modal's content zero-height. */} @@ -187,6 +208,26 @@ function NameQuestion({ disabled={naming && name.trim() === ""} onPress={() => void save()} /> + {/* Ways out that touch only this server. A device the server cannot place reaches nothing + there until it says whose it is, so it may put the question off; the first owner + already holds the server, so only naming or removing it ends their question (AC6). */} + {kind === "claim" ? ( +