From 5807d2e7191f31478195c7b813570f93611ef4d9 Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Tue, 13 Oct 2026 02:22:55 -0400 Subject: [PATCH 01/17] feat(web): a member can give a guest Collaborate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Share dialog's Collaborate choice, the level controls on the People page, a project's Sharing section and the thread panel, and the "Let … collaborate?" dialog, which confirms a name the person gave themselves before raising them. The Collaborate line says what a collaborator can do today: the in-app browser is not open to a guest. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/j5/sharing/LevelControl.tsx | 75 ++++--- apps/web/src/j5/sharing/PromoteDialog.tsx | 190 ++++++++++++++++++ apps/web/src/j5/sharing/ShareDialog.tsx | 51 ++--- apps/web/src/j5/sharing/SharingDialogHost.tsx | 11 + apps/web/src/j5/sharing/ThreadPeople.tsx | 53 ++++- apps/web/src/j5/sharing/guestAccess.ts | 17 ++ apps/web/src/j5/sharing/promote.logic.test.ts | 26 +++ apps/web/src/j5/sharing/promote.logic.ts | 24 +++ apps/web/src/j5/sharing/sharingDialogs.ts | 12 ++ .../client-runtime/src/j5/sharing.test.ts | 24 +++ packages/client-runtime/src/j5/sharing.ts | 21 ++ 11 files changed, 420 insertions(+), 84 deletions(-) create mode 100644 apps/web/src/j5/sharing/PromoteDialog.tsx create mode 100644 apps/web/src/j5/sharing/promote.logic.test.ts create mode 100644 apps/web/src/j5/sharing/promote.logic.ts diff --git a/apps/web/src/j5/sharing/LevelControl.tsx b/apps/web/src/j5/sharing/LevelControl.tsx index 57dcac4d90c59..dc989b8703652 100644 --- a/apps/web/src/j5/sharing/LevelControl.tsx +++ b/apps/web/src/j5/sharing/LevelControl.tsx @@ -1,7 +1,6 @@ import type { EnvironmentId } from "@t3tools/contracts"; import type { SharingGrant, SharingGrantLevel, SharingPerson } from "@t3tools/contracts/j5"; -import { Badge } from "../../components/ui/badge"; import { Select, SelectItem, @@ -10,21 +9,16 @@ import { SelectValue, } from "../../components/ui/select"; import { toastManager } from "../../components/ui/toast"; -import { Tooltip, TooltipPopup, TooltipTrigger } from "../../components/ui/tooltip"; import { useAtomCommand } from "../../state/use-atom-command"; import { levelLabel } from "./shareLink.logic"; +import { openSharingDialog } from "./sharingDialogs"; import { refreshSharing, refusalMessage, sharingManage } from "./sharingManage"; import { showReturnedPerson } from "./returnedPeople"; /** - * Whether a guest can be raised to Collaborate yet. Nothing lets a guest send to an agent today, - * so the level is listed and cannot be chosen, as in the Share dialog. - */ -const COLLABORATE_IS_OFFERED = false; - -/** - * The level one person holds on one project or thread. A person who typed their own name cannot - * be given Collaborate until a member confirms it (Shared server AC27), so their control says so. + * The level one person holds on one project or thread. Lowering to View happens at once. Raising + * to Collaborate opens the dialog that says what it allows and, for a person who typed their own + * name, confirms it first (Shared server AC27). */ export function LevelControl({ environmentId, @@ -40,6 +34,19 @@ export function LevelControl({ const putGrant = useAtomCommand(sharingManage.putGrant, { reportFailure: false }); const change = async (level: SharingGrantLevel) => { if (level === grant.level) return; + if (level === "collaborate") { + openSharingDialog({ + kind: "promote", + environmentId, + person: { + personId: person.personId, + name: person.displayName ?? "this person", + nameSelfGiven: person.nameSelfGiven, + }, + target: grant.target, + }); + return; + } const result = await putGrant({ environmentId, input: { personId: person.personId, target: grant.target, level }, @@ -54,35 +61,25 @@ export function LevelControl({ refreshSharing(environmentId); }; - const control = ( - - ); - if (!person.nameSelfGiven || !canManage) return
{control}
; return ( - - }>{control} - Confirm their name first - +
+ +
); } diff --git a/apps/web/src/j5/sharing/PromoteDialog.tsx b/apps/web/src/j5/sharing/PromoteDialog.tsx new file mode 100644 index 0000000000000..4e33006f44afd --- /dev/null +++ b/apps/web/src/j5/sharing/PromoteDialog.tsx @@ -0,0 +1,190 @@ +import { useAtomValue } from "@effect/atom-react"; +import type { EnvironmentId } from "@t3tools/contracts"; +import { isPersonName, type SharingGrantTarget } from "@t3tools/contracts/j5"; +import { useState } from "react"; + +import { Alert, AlertDescription } from "../../components/ui/alert"; +import { Badge } from "../../components/ui/badge"; +import { Button } from "../../components/ui/button"; +import { + Dialog, + DialogDescription, + DialogFooter, + DialogHeader, + DialogPanel, + DialogPopup, + DialogTitle, +} from "../../components/ui/dialog"; +import { Input } from "../../components/ui/input"; +import { useEnvironmentQuery } from "../../state/query"; +import { useAtomCommand } from "../../state/use-atom-command"; +import { nameToShowAgain, promotionSendsName } from "./promote.logic"; +import { NAME_NOT_USABLE } from "./shareLink.logic"; +import { peopleQuery, refreshSharing, refusalMessage, sharingManage } from "./sharingManage"; + +/** + * A member raises someone from View to Collaborate on one thread or project. The name goes on + * that person's messages to the agent from here on, so it is shown to be checked, and a name the + * person typed themselves is confirmed by saving (Shared server AC27). No link is made. + */ +export function PromoteDialog({ + environmentId, + person, + target, + onClose, +}: { + readonly environmentId: EnvironmentId; + readonly person: { + readonly personId: string; + readonly name: string; + readonly nameSelfGiven: boolean; + }; + readonly target: SharingGrantTarget; + readonly onClose: () => void; +}) { + const canManage = useAtomValue(sharingManage.putGrant.permissionAtom(environmentId)); + const rename = useAtomCommand(sharingManage.renamePerson, { reportFailure: false }); + const putGrant = useAtomCommand(sharingManage.putGrant, { reportFailure: false }); + const [name, setName] = useState(person.name); + // The name as the server holds it now; the list is read again when anyone changes a person. + const people = useEnvironmentQuery(canManage ? peopleQuery(environmentId) : null); + const storedName = + people.data?.people.find((listed) => listed.personId === person.personId)?.displayName ?? null; + const [seenName, setSeenName] = useState(person.name); + const [note, setNote] = useState(""); + const [busy, setBusy] = useState(false); + const [error, setError] = useState(null); + const typedName = name.trim(); + const shownName = typedName === "" ? "them" : typedName; + + const save = async () => { + if (!isPersonName(typedName)) { + setError(NAME_NOT_USABLE); + return; + } + const renamedTo = nameToShowAgain({ seen: seenName, stored: storedName }); + if (renamedTo !== null) { + // Someone renamed them while this was open: saving now would write the older name back. + setName(renamedTo); + setSeenName(renamedTo); + setError( + `Their name was changed to ${renamedTo} while this was open. Check it, then save again.`, + ); + return; + } + setBusy(true); + setError(null); + if (promotionSendsName({ name: seenName, typed: name, nameSelfGiven: person.nameSelfGiven })) { + const renamed = await rename({ + environmentId, + input: { personId: person.personId, displayName: typedName }, + }); + if (renamed._tag === "Failure") { + setBusy(false); + setError(refusalMessage(renamed)); + return; + } + } + const purpose = note.trim(); + const result = await putGrant({ + environmentId, + input: { + personId: person.personId, + target, + level: "collaborate", + ...(purpose === "" ? {} : { note: purpose }), + }, + }); + setBusy(false); + // The name may have been saved even when the level was refused. + refreshSharing(environmentId); + if (result._tag === "Failure") { + setError(refusalMessage(result)); + return; + } + onClose(); + }; + + return ( + (open ? undefined : onClose())}> + + {/* `contents`: the popup lays out its header, panel and footer itself. */} +
{ + event.preventDefault(); + void save(); + }} + > + + Let {person.name} collaborate? + + {person.name} will be able to send messages to the agent and answer its prompts. + + + + + + + +

+ + You are inviting {shownName} to talk to and control an AI agent on your device. + {" "} + Make sure you trust them. Anything the agent can do,{" "} + {typedName === "" ? "they" : typedName} can ask it to do. +

+
+
+ {error !== null ?

{error}

: null} +
+ + + + +
+
+
+ ); +} diff --git a/apps/web/src/j5/sharing/ShareDialog.tsx b/apps/web/src/j5/sharing/ShareDialog.tsx index d39ee0147ead2..0b44617d0b186 100644 --- a/apps/web/src/j5/sharing/ShareDialog.tsx +++ b/apps/web/src/j5/sharing/ShareDialog.tsx @@ -18,7 +18,6 @@ import { AutocompleteList, AutocompletePopup, } from "../../components/ui/autocomplete"; -import { Badge } from "../../components/ui/badge"; import { Button } from "../../components/ui/button"; import { Dialog, @@ -43,6 +42,7 @@ import { namedLinkMeta, type LinkLifetime, } from "./shareLink.logic"; +import { COLLABORATE_DESCRIPTION } from "./promote.logic"; import { ShareLinkPanel } from "./ShareLinkPanel"; import { TargetPicker } from "./TargetPicker"; import { @@ -53,13 +53,6 @@ import { sharingManage, } from "./sharingManage"; -/** - * Whether a guest can be given Collaborate yet. Nothing lets a guest send to an agent today, so - * the level is listed and cannot be chosen; the fields and the warning that go with it are built - * and appear once it can. - */ -const COLLABORATE_IS_OFFERED = false; - const LEVELS: ReadonlyArray<{ readonly level: SharingGrantLevel; readonly description: string; @@ -73,7 +66,8 @@ const LEVELS: ReadonlyArray<{ }, { level: "collaborate", - description: "Also message the agent, answer its prompts and drive the in-app browser.", + // The design's line also promised the in-app browser, which is not open to a guest. + description: COLLABORATE_DESCRIPTION, }, ]; @@ -305,34 +299,19 @@ export function ShareDialog({ disabled={busy} onValueChange={(value) => setLevel(value as SharingGrantLevel)} > - {LEVELS.map((option) => { - const unavailable = option.level === "collaborate" && !COLLABORATE_IS_OFFERED; - return ( - + ))} diff --git a/apps/web/src/j5/sharing/SharingDialogHost.tsx b/apps/web/src/j5/sharing/SharingDialogHost.tsx index 4d70a46f4b075..0e512c7427441 100644 --- a/apps/web/src/j5/sharing/SharingDialogHost.tsx +++ b/apps/web/src/j5/sharing/SharingDialogHost.tsx @@ -18,6 +18,7 @@ import { } from "./ownerName"; import { ownerNameCheck, serverToAskOwnerNameFor } from "./ownerName.logic"; import { OwnerNameDialog } from "./OwnerNameDialog"; +import { PromoteDialog } from "./PromoteDialog"; import { ShareDialog } from "./ShareDialog"; import { closeSharingDialog, sharingDialogStore } from "./sharingDialogs"; import { sharingManage } from "./sharingManage"; @@ -74,6 +75,16 @@ function SharingDialogs() { onClose={closeSharingDialog} /> ); + case "promote": + return ( + + ); case "rename": return ( { if (personId === null) return; @@ -356,6 +357,22 @@ function GuestRow({ refreshSharing(environmentId); }; + const lower = async () => { + if (personId === null) return; + const result = await putGrant({ + environmentId, + input: { personId, target: { kind: "thread", threadId }, level: "view" }, + }); + if (result._tag === "Failure") { + toastManager.add({ + type: "error", + title: "Could not change the level", + description: refusalMessage(result), + }); + } + refreshSharing(environmentId); + }; + return (
@@ -386,7 +403,18 @@ function GuestRow({ - + void lower()} + onCollaborate={() => + openSharingDialog({ + kind: "promote", + environmentId, + person: { personId, name, nameSelfGiven: guest.nameSelfGiven }, + target: { kind: "thread", threadId }, + }) + } + /> @@ -411,16 +439,23 @@ function GuestRow({ ); } -/** View and Collaborate as the level menu lists them. Collaborate cannot be chosen yet. */ -function LevelItems({ current }: { readonly current: SharingGrantLevel }) { +/** View and Collaborate as the level menu lists them; the level held is ticked. */ +function LevelItems({ + current, + onView, + onCollaborate, +}: { + readonly current: SharingGrantLevel; + readonly onView: () => void; + readonly onCollaborate: () => void; +}) { return ( <> - View{current === "view" ? " ✓" : ""} - - Collaborate - - coming soon - + + View{current === "view" ? " ✓" : ""} + + + Collaborate{current === "collaborate" ? " ✓" : ""} ); diff --git a/apps/web/src/j5/sharing/guestAccess.ts b/apps/web/src/j5/sharing/guestAccess.ts index c657d97e45784..f59a83769fd32 100644 --- a/apps/web/src/j5/sharing/guestAccess.ts +++ b/apps/web/src/j5/sharing/guestAccess.ts @@ -5,6 +5,7 @@ import { type EnvironmentId, type ThreadId, } from "@t3tools/contracts"; +import type { SharingThreadLevel } from "@t3tools/contracts/j5"; import { Atom } from "effect/reactivity"; import { environmentCatalog } from "../../connection/catalog"; @@ -73,6 +74,22 @@ export function useIsGuest(environmentId: EnvironmentId | null): boolean { return useAtomValue(environmentId === null ? NOT_A_GUEST : j5Sharing.isGuest(environmentId)); } +const NO_GUEST_LEVEL = Atom.make(null); + +/** + * What a guest holds on a thread: `null` for a member, else "view", "collaborate" or "none". For + * the places a collaborating guest is offered less than a member (no Stop, no steering, text + * only); whether the thread can be written to at all stays `useCanOperateThread`. + */ +export function useGuestThreadLevel( + environmentId: EnvironmentId | null, + threadId: ThreadId | null, +): SharingThreadLevel | null { + return useAtomValue( + environmentId === null ? NO_GUEST_LEVEL : j5Sharing.guestThreadLevel(environmentId, threadId), + ); +} + /** What J5's Skills page says when every connected server is a guest one. */ export const GUEST_SKILLS_UNAVAILABLE = "Skills are not available on a server you are a guest on."; diff --git a/apps/web/src/j5/sharing/promote.logic.test.ts b/apps/web/src/j5/sharing/promote.logic.test.ts new file mode 100644 index 0000000000000..b0636ac5a1a97 --- /dev/null +++ b/apps/web/src/j5/sharing/promote.logic.test.ts @@ -0,0 +1,26 @@ +import { describe, expect, it } from "vite-plus/test"; + +import { nameToShowAgain, promotionSendsName } from "./promote.logic"; + +describe("raising someone to Collaborate", () => { + it("confirms a name they gave themselves, changed or not", () => { + expect(promotionSendsName({ name: "Sam", typed: "Sam", nameSelfGiven: true })).toBe(true); + expect(promotionSendsName({ name: "Sam", typed: "Sam T.", nameSelfGiven: true })).toBe(true); + }); + + it("sends a name a member gave only when it was changed", () => { + expect(promotionSendsName({ name: "Sam", typed: " Sam ", nameSelfGiven: false })).toBe(false); + expect(promotionSendsName({ name: "Sam", typed: "Samir", nameSelfGiven: false })).toBe(true); + }); +}); + +describe("a person renamed elsewhere while the dialog was open", () => { + it("is shown under their new name before anything is saved", () => { + expect(nameToShowAgain({ seen: "Sam", stored: "Samir" })).toBe("Samir"); + }); + + it("is saved straight away when the name is as the member saw it, or is not known", () => { + expect(nameToShowAgain({ seen: "Sam", stored: "Sam" })).toBeNull(); + expect(nameToShowAgain({ seen: "Sam", stored: null })).toBeNull(); + }); +}); diff --git a/apps/web/src/j5/sharing/promote.logic.ts b/apps/web/src/j5/sharing/promote.logic.ts new file mode 100644 index 0000000000000..53ec39b570465 --- /dev/null +++ b/apps/web/src/j5/sharing/promote.logic.ts @@ -0,0 +1,24 @@ +/** The line the Share dialog and the promotion dialog put under Collaborate. */ +export const COLLABORATE_DESCRIPTION = "Also send messages to the agent and answer its prompts."; + +/** + * Whether raising someone to Collaborate must first send their name. A name they typed when they + * joined is confirmed by a member sending it, changed or not, and the server refuses Collaborate + * until then (Shared server AC27). A name a member gave is sent only when it was changed. + */ +export const promotionSendsName = (input: { + readonly name: string; + readonly typed: string; + readonly nameSelfGiven: boolean; +}) => input.nameSelfGiven || input.typed.trim() !== input.name; + +/** + * The name to show the member again before anything is saved, or `null` to go ahead. The dialog + * opens with a person's name and may stay open while someone else renames them; saving would + * then write the older name back over the newer one unseen. `seen` is the stored name the member + * last had in front of them, `stored` the one the server holds now (`null` while it is not known). + */ +export const nameToShowAgain = (input: { + readonly seen: string; + readonly stored: string | null; +}): string | null => (input.stored !== null && input.stored !== input.seen ? input.stored : null); diff --git a/apps/web/src/j5/sharing/sharingDialogs.ts b/apps/web/src/j5/sharing/sharingDialogs.ts index 44ff3d15964d3..686b302896225 100644 --- a/apps/web/src/j5/sharing/sharingDialogs.ts +++ b/apps/web/src/j5/sharing/sharingDialogs.ts @@ -32,6 +32,18 @@ export type SharingDialogRequest = readonly environmentId: EnvironmentId; readonly person: { readonly personId: string; readonly name: string }; } + | { + /** A member raises someone from View to Collaborate on one thread or project. */ + readonly kind: "promote"; + readonly environmentId: EnvironmentId; + readonly person: { + readonly personId: string; + readonly name: string; + /** They typed it when they joined; saving the dialog confirms it. */ + readonly nameSelfGiven: boolean; + }; + readonly target: SharingGrantTarget; + } | { /** A guest gives up what a thread was shared with them through. */ readonly kind: "leave"; diff --git a/packages/client-runtime/src/j5/sharing.test.ts b/packages/client-runtime/src/j5/sharing.test.ts index 3a3ef423828be..82dd4e423bc3a 100644 --- a/packages/client-runtime/src/j5/sharing.test.ts +++ b/packages/client-runtime/src/j5/sharing.test.ts @@ -188,6 +188,30 @@ describe("a guest's connection", () => { }), ); + it.effect("tells a guest who collaborates from a member, thread by thread", () => + Effect.gen(function* () { + const { layer, registry, viewedLevel } = yield* environments(); + const sharing = createSharingEnvironmentAtoms(Atom.runtime(layer)); + const viewed = sharing.guestThreadLevel(SHARED_SERVER, VIEWED); + const joined = sharing.guestThreadLevel(SHARED_SERVER, JOINED); + const draft = sharing.guestThreadLevel(SHARED_SERVER, null); + const own = sharing.guestThreadLevel(MEMBER_SERVER, VIEWED); + for (const atom of [viewed, joined, draft, own]) yield* AtomRegistry.mount(registry, atom); + + expect(yield* settlesAt(registry, joined, "collaborate")).toBe(true); + expect(yield* settlesAt(registry, viewed, "view")).toBe(true); + expect(registry.get(draft)).toBe("none"); + yield* SubscriptionRef.set(viewedLevel, "collaborate"); + expect(yield* settlesAt(registry, viewed, "collaborate")).toBe(true); + + // A member holds no level: nothing a member is offered depends on one. + expect(yield* settlesAt(registry, sharing.connectionKind(MEMBER_SERVER), "member")).toBe( + true, + ); + expect(registry.get(own)).toBe(null); + }), + ); + it.effect("is offered a thread's actions only where it holds Collaborate", () => Effect.gen(function* () { const { layer, registry } = yield* environments(); diff --git a/packages/client-runtime/src/j5/sharing.ts b/packages/client-runtime/src/j5/sharing.ts index bdd0b7cdd9b42..5c7adcfe77281 100644 --- a/packages/client-runtime/src/j5/sharing.ts +++ b/packages/client-runtime/src/j5/sharing.ts @@ -144,6 +144,25 @@ export function createSharingEnvironmentAtoms( }).pipe(Atom.withLabel(`j5:sharing:thread-operable:${key}`)); }); + /** + * What a guest holds on a thread, for the parts of a client that differ between a guest who + * collaborates and a member: `null` for a connection not known to be a guest's, and "none" + * for a guest's until the server has sent the level. Whether the thread can be written to at + * all is `threadOperable`, the one answer upstream's files ask. + */ + const guestThreadLevel = Atom.family((key: string) => { + const [environmentId, threadId] = JSON.parse(key) as [EnvironmentId, ThreadId | null]; + return Atom.make((get): SharingThreadLevel | null => { + if (get(connectionKind(environmentId)) !== "guest") return null; + if (threadId === null) return "none"; + return ( + Option.getOrNull( + AsyncResult.value(get(threadAccess({ environmentId, input: { threadId } }))), + )?.level ?? "none" + ); + }).pipe(Atom.withLabel(`j5:sharing:guest-thread-level:${key}`)); + }); + /** Whether the connection is known to be a guest's; false until the server has said so. */ const isGuest = Atom.family((environmentId: EnvironmentId) => Atom.make((get) => get(connectionKind(environmentId)) === "guest").pipe( @@ -170,6 +189,8 @@ export function createSharingEnvironmentAtoms( ): boolean => input.permitted && registry.get(threadOperable(threadKey(input.environmentId, input.threadId))), + guestThreadLevel: (environmentId: EnvironmentId, threadId: ThreadId | null) => + guestThreadLevel(threadKey(environmentId, threadId)), /** Whether sharing lets this connection write to the thread; upstream's permission is separate. */ threadOperable: (environmentId: EnvironmentId, threadId: ThreadId | null) => threadOperable(threadKey(environmentId, threadId)), From 89e3a1de90267af01ef9880e82d06276e5c9d6e2 Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Tue, 13 Oct 2026 02:24:48 -0400 Subject: [PATCH 02/17] feat(web): what a guest's composer leaves out, as J5's own answers Text only, three answers to an approval, a follow-up that always queues, no stopping a run, and a queued edit sent as text. Nothing calls these yet; each upstream call is its own commit. Co-Authored-By: Claude Opus 5.5 --- .../j5/sharing/guestComposer.logic.test.ts | 46 +++++++++++++ .../web/src/j5/sharing/guestComposer.logic.ts | 43 ++++++++++++ apps/web/src/j5/sharing/guestComposer.ts | 67 +++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 apps/web/src/j5/sharing/guestComposer.logic.test.ts create mode 100644 apps/web/src/j5/sharing/guestComposer.logic.ts create mode 100644 apps/web/src/j5/sharing/guestComposer.ts diff --git a/apps/web/src/j5/sharing/guestComposer.logic.test.ts b/apps/web/src/j5/sharing/guestComposer.logic.test.ts new file mode 100644 index 0000000000000..ea44aeeec3329 --- /dev/null +++ b/apps/web/src/j5/sharing/guestComposer.logic.test.ts @@ -0,0 +1,46 @@ +import { describe, expect, it } from "vite-plus/test"; + +import { approvalOptionsFor, queuedEditFor } from "./guestComposer.logic"; + +describe("the answers an approval offers", () => { + const listed = [ + { decision: "accept", label: "Run it" }, + { decision: "acceptAlways", label: "Always run it" }, + { decision: "decline", label: "No" }, + ] as const; + + it("are the provider's own for a member, or upstream's default when it lists none", () => { + expect(approvalOptionsFor(false, listed)).toBe(listed); + expect(approvalOptionsFor(false, undefined)).toBeUndefined(); + }); + + it("leave a guest only this one request to approve, decline or cancel", () => { + expect(approvalOptionsFor(true, listed)?.map((option) => option.decision)).toEqual([ + "accept", + "decline", + ]); + expect(approvalOptionsFor(true, undefined)?.map((option) => option.decision)).toEqual([ + "cancel", + "decline", + "accept", + ]); + // A provider that listed only lasting answers still leaves a guest a way to answer. + expect( + approvalOptionsFor(true, [{ decision: "acceptForSession", label: "For this session" }])?.map( + (option) => option.decision, + ), + ).toEqual(["cancel", "decline", "accept"]); + }); +}); + +describe("changing a queued message", () => { + const input = { runId: "run-1", text: "fixed typo", edit: { attachments: [], context: {} } }; + + it("sends a guest's as text alone", () => { + expect(queuedEditFor(true, input)).toEqual({ runId: "run-1", text: "fixed typo" }); + }); + + it("sends a member's as upstream built it", () => { + expect(queuedEditFor(false, input)).toBe(input); + }); +}); diff --git a/apps/web/src/j5/sharing/guestComposer.logic.ts b/apps/web/src/j5/sharing/guestComposer.logic.ts new file mode 100644 index 0000000000000..c97db4eb9bd40 --- /dev/null +++ b/apps/web/src/j5/sharing/guestComposer.logic.ts @@ -0,0 +1,43 @@ +import type { ProviderApprovalOption } from "@t3tools/contracts"; + +/** What a guest is told when they try to send more than text. */ +export const GUEST_TEXT_ONLY = + "A guest can send text only: no attachments, mentions or other context."; + +// The server takes these three from a guest and refuses "for this session" and "always". +const GUEST_APPROVAL_OPTIONS = [ + { decision: "cancel", label: "Cancel" }, + { decision: "decline", label: "Decline" }, + { decision: "accept", label: "Approve" }, +] satisfies ReadonlyArray; + +/** + * The answers an approval offers. A member gets what the provider listed, untouched (`undefined` + * leaves upstream's own default list in place). A guest approves or declines this one request: a + * member decides anything that lasts longer (Shared conversations AC8). + */ +export function approvalOptionsFor( + isGuest: boolean, + options: ReadonlyArray | undefined, +): ReadonlyArray | undefined { + if (!isGuest) return options; + const allowed = new Set(GUEST_APPROVAL_OPTIONS.map((option) => option.decision)); + const listed = (options ?? GUEST_APPROVAL_OPTIONS).filter((option) => + allowed.has(option.decision), + ); + return listed.length === 0 ? GUEST_APPROVAL_OPTIONS : listed; +} + +/** + * What a guest's command to change a queued message of their own carries: the text. The server + * refuses a guest's attachments and context, which upstream's edit always sends. A member's + * command is returned as it is. + */ +export function queuedEditFor( + isGuest: boolean, + input: Input, +): Input { + if (!isGuest || input.edit === undefined) return input; + const { edit: _edit, ...textOnly } = input; + return textOnly as Input; +} diff --git a/apps/web/src/j5/sharing/guestComposer.ts b/apps/web/src/j5/sharing/guestComposer.ts new file mode 100644 index 0000000000000..e9ce168e637f1 --- /dev/null +++ b/apps/web/src/j5/sharing/guestComposer.ts @@ -0,0 +1,67 @@ +import type { EnvironmentId, ProviderApprovalOption } from "@t3tools/contracts"; +import { useCallback, useMemo } from "react"; + +import { toastManager } from "../../components/ui/toast"; +import { appAtomRegistry } from "../../rpc/atomRegistry"; +import { j5Sharing, useIsGuest } from "./guestAccess"; +import { approvalOptionsFor, GUEST_TEXT_ONLY, queuedEditFor } from "./guestComposer.logic"; + +/** + * What a guest's composer leaves out (Shared conversations AC14 to AC16). A guest who may write + * to a thread sends text: the server rebuilds their message from it and refuses attachments and + * context. Their message queues behind running work and never steers it, and they do not stop a + * run. For a member every answer here is upstream's own. + */ +export function useGuestComposer(environmentId: EnvironmentId | null) { + const isGuest = useIsGuest(environmentId); + return useMemo( + () => ({ + /** No attach control, and no @, $ or / menu, since each adds what the server refuses. */ + textOnly: isGuest, + /** Says why and returns true when a guest tries to add files, by paste or drop. */ + refusesFiles: () => { + if (!isGuest) return false; + toastManager.add({ type: "error", title: GUEST_TEXT_ONLY }); + return true; + }, + /** A guest's follow-up always queues, whatever this person's own setting is elsewhere. */ + followUpBehavior: (setting: Setting): Setting | "queue" => + isGuest ? "queue" : setting, + approvalOptions: (options: ReadonlyArray | undefined) => + approvalOptionsFor(isGuest, options), + }), + [isGuest], + ); +} + +/** Whether this connection may stop a run: upstream's answer for a member, never for a guest. */ +export function useMayInterruptThread( + environmentId: EnvironmentId | null, + canOperateThread: boolean, +): boolean { + return useIsGuest(environmentId) ? false : canOperateThread; +} + +/** + * Wraps upstream's command that changes a queued message so that a guest's carries its text + * alone; see `queuedEditFor`. Whose connection it is is read when the command runs. + */ +export function useGuestEditsAsText< + Target extends { + readonly environmentId: EnvironmentId; + readonly input: { readonly edit?: unknown }; + }, + Result, +>(command: (target: Target) => Result): (target: Target) => Result { + return useCallback( + (target: Target) => + command({ + ...target, + input: queuedEditFor( + appAtomRegistry.get(j5Sharing.isGuest(target.environmentId)), + target.input, + ), + }), + [command], + ); +} From b8131fa129da7798db17f41c2bc0132dab05c1be Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Tue, 13 Oct 2026 02:24:58 -0400 Subject: [PATCH 03/17] feat(web): a guest is not offered Stop Upstream edit awaiting Jackson's approval: ChatView.tsx, one import and the condition that draws the Stop button. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/ChatView.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 42286510e80c2..fd5d62b1cd88c 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -40,6 +40,7 @@ import { feedbackBannerItem } from "./chat/ComposerFeedback"; import { usageLimitsBannerItem } from "./chat/ComposerUsageLimits"; import { CrewRosterGate } from "../j5/crew/CrewRosterGate"; import { useCanOperateThread } from "../j5/sharing/guestAccess"; +import { useMayInterruptThread } from "../j5/sharing/guestComposer"; import { expandPlaybookPrompt } from "@t3tools/client-runtime/j5/playbooks"; import { PlaybookBoard } from "../j5/playbooks/PlaybookBoard"; import { getTerminalLabel } from "@t3tools/shared/terminalLabels"; @@ -4580,8 +4581,10 @@ export default function ChatView(props: ChatViewProps) { const focusComposer = useCallback(() => { composerRef.current?.focusAtEnd(); }, [composerRef]); + // J5: a guest who may write to a shared thread still never stops a run. const canInterruptRunningThread = - canOperateThread && deriveCanInterruptRunningThread(activeThread !== undefined, activeRuntime); + useMayInterruptThread(environmentId, canOperateThread) && + deriveCanInterruptRunningThread(activeThread !== undefined, activeRuntime); const onInterrupt = useCallback(async () => { if ( !activeThread || From fae159840a1470c692601ad908635f04b669bd45 Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Tue, 13 Oct 2026 02:25:53 -0400 Subject: [PATCH 04/17] feat(web): a guest changes their own queued message Upstream edit awaiting Jackson's approval: ChatView.tsx, the command that saves an edited queued message passes through J5, which sends a guest's as text alone. Upstream's edit always carries attachments and context, which the server refuses from a guest. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/ChatView.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index fd5d62b1cd88c..d13002f0805ca 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -40,7 +40,7 @@ import { feedbackBannerItem } from "./chat/ComposerFeedback"; import { usageLimitsBannerItem } from "./chat/ComposerUsageLimits"; import { CrewRosterGate } from "../j5/crew/CrewRosterGate"; import { useCanOperateThread } from "../j5/sharing/guestAccess"; -import { useMayInterruptThread } from "../j5/sharing/guestComposer"; +import { useGuestEditsAsText, useMayInterruptThread } from "../j5/sharing/guestComposer"; import { expandPlaybookPrompt } from "@t3tools/client-runtime/j5/playbooks"; import { PlaybookBoard } from "../j5/playbooks/PlaybookBoard"; import { getTerminalLabel } from "@t3tools/shared/terminalLabels"; @@ -4652,9 +4652,11 @@ export default function ChatView(props: ChatViewProps) { }, [activeThreadId, environmentId, interactionMode, isServerThread, runtimeMode, startThreadTurn], ); - const editQueuedRunCommand = useAtomCommand(threadEnvironment.editQueuedRun, { + const editQueuedRunAsBuilt = useAtomCommand(threadEnvironment.editQueuedRun, { reportFailure: false, }); + // J5: a guest's edit of their own queued message is sent as text alone. + const editQueuedRunCommand = useGuestEditsAsText(editQueuedRunAsBuilt); const queuedRunsControlRef = useRef(null); const queuedEditSaveInFlightRef = useRef(false); const [isSavingQueuedEdit, setIsSavingQueuedEdit] = useState(false); From 0918b3edd8306c144db65bafb2a3d8df690bcaec Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Tue, 13 Oct 2026 02:26:25 -0400 Subject: [PATCH 05/17] feat(web): a guest's composer offers no attachments Upstream edit awaiting Jackson's approval: ChatComposer.tsx, one import, one hook call, the attach control's condition, and one line that refuses files added by paste or drop with a plain message. The server refuses a guest's attachments. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/chat/ChatComposer.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/web/src/components/chat/ChatComposer.tsx b/apps/web/src/components/chat/ChatComposer.tsx index 6a0d64f01f9b5..fd310b59b4d94 100644 --- a/apps/web/src/components/chat/ChatComposer.tsx +++ b/apps/web/src/components/chat/ChatComposer.tsx @@ -1,3 +1,4 @@ +import { useGuestComposer } from "../../j5/sharing/guestComposer"; import { useViewOnlyComposerProps } from "../../j5/sharing/viewOnlyComposer"; import { formatProviderSkillDisplayName } from "@t3tools/shared/inlineSkills"; import { useAgentMentionPicker } from "../../j5/agents/useAgentMentionPicker"; @@ -1827,6 +1828,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) onRemoveEditingQueuedAttachment, } = props; const viewOnlyComposerProps = useViewOnlyComposerProps(environmentId, canOperateThread); + const guestComposer = useGuestComposer(environmentId); const isLiteralPendingAnswer = activePendingProgress?.activeQuestion?.initialAnswer !== undefined; const primaryEnvironmentId = usePrimaryEnvironmentId(); const composerDraftTargetKey = composerTargetKey(composerDraftTarget); @@ -5878,6 +5880,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) }, ): Promise => { if (!activeThreadId || files.length === 0 || isRevertingCheckpointRef.current) return false; + if (guestComposer.refusesFiles()) return false; if ( pendingUserInputs.length > 0 && (!supportsQuestionAttachments || From 07559de0b6f4e7257b354661fb56f7ebcc384a95 Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Tue, 13 Oct 2026 02:26:44 -0400 Subject: [PATCH 06/17] feat(web): a guest's composer offers no mention, skill or command menu Upstream edit awaiting Jackson's approval: ChatComposer.tsx, the menu's list is empty for a guest (one condition and its dependency). Each entry adds context or changes a setting, which the server refuses or drops from a guest. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/chat/ChatComposer.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/chat/ChatComposer.tsx b/apps/web/src/components/chat/ChatComposer.tsx index fd310b59b4d94..a83880879ad75 100644 --- a/apps/web/src/components/chat/ChatComposer.tsx +++ b/apps/web/src/components/chat/ChatComposer.tsx @@ -2691,7 +2691,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) ); const effectiveAgentAssignment = agentPersonaAssignment ?? draftAgent.assignment ?? undefined; const composerMenuItems = useMemo(() => { - if (!composerTrigger) return []; + if (!composerTrigger || guestComposer.textOnly) return []; if (composerTrigger.kind === "agent") return agentPicker.items; if (composerTrigger.kind === "slash-playbook") return playbookMenuItems(playbookQuery.data?.playbooks ?? [], composerTrigger, prompt); @@ -2860,6 +2860,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) } return []; }, [ + guestComposer.textOnly, activeThreadId, agentPicker.items, playbookQuery.data, From 2cd8ea609c67488ddddf8936191b5586334763bc Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Tue, 13 Oct 2026 02:26:49 -0400 Subject: [PATCH 07/17] feat(web): a guest's send button never reads as steering Upstream edit awaiting Jackson's approval: ChatComposer.tsx, one line. A guest's message always queues behind running work, whatever follow-up behaviour the person has set for their own servers. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/chat/ChatComposer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/src/components/chat/ChatComposer.tsx b/apps/web/src/components/chat/ChatComposer.tsx index a83880879ad75..8dec6af9a0219 100644 --- a/apps/web/src/components/chat/ChatComposer.tsx +++ b/apps/web/src/components/chat/ChatComposer.tsx @@ -7746,7 +7746,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) pendingAction={pendingPrimaryAction} isRunning={phase === "running"} canInterrupt={canInterrupt} - followUpBehavior={settings.followUpBehavior} + followUpBehavior={guestComposer.followUpBehavior(settings.followUpBehavior)} alternateShortcutLabel={shortcutLabelForCommand( keybindings, "composer.sendAlternate", From 78b0487a5a979fc5d1d5d381f11e120b2ed97a3c Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Tue, 13 Oct 2026 02:27:01 -0400 Subject: [PATCH 08/17] feat(web): a guest approves or declines one request, and no more Upstream edit awaiting Jackson's approval: ChatComposer.tsx, one line. The approval's answers pass through J5, which leaves a guest Approve, Decline and Cancel; "for this session" and "always" are a member's to decide and the server refuses them from a guest. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/chat/ChatComposer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/src/components/chat/ChatComposer.tsx b/apps/web/src/components/chat/ChatComposer.tsx index 8dec6af9a0219..77d1090fb7f9d 100644 --- a/apps/web/src/components/chat/ChatComposer.tsx +++ b/apps/web/src/components/chat/ChatComposer.tsx @@ -6867,7 +6867,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) isResponding={respondingRequestIds.includes( activePendingApproval.requestId, )} - options={activePendingApproval.options} + options={guestComposer.approvalOptions(activePendingApproval.options)} canRespond={activePendingApproval.responseCapability === "live"} onRespondToApproval={onRespondToApproval} /> From cb0f870b21ea05b4d1819a16bf61a2de9ba922d6 Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Tue, 13 Oct 2026 02:27:02 -0400 Subject: [PATCH 09/17] fix(web): a question's Dismiss is disabled for a connection that cannot answer Upstream edit awaiting Jackson's approval: ComposerPendingUserInputPanel.tsx, one line. Dismiss ignored the panel's `disabled`, so a View guest (and a member's connection without the operate permission) was offered a Dismiss the server refuses. This reads as a small upstream bug in its own right. Co-Authored-By: Claude Opus 5.5 --- .../src/components/chat/ComposerPendingUserInputPanel.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/web/src/components/chat/ComposerPendingUserInputPanel.tsx b/apps/web/src/components/chat/ComposerPendingUserInputPanel.tsx index 483eeb57a6e3f..b4ae8a927402c 100644 --- a/apps/web/src/components/chat/ComposerPendingUserInputPanel.tsx +++ b/apps/web/src/components/chat/ComposerPendingUserInputPanel.tsx @@ -226,18 +226,18 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard( render={} aria-label="Dismiss question without answering" title="Dismiss question without answering" - disabled={isResponding} + disabled={isResponding || disabled} data-pending-user-input-dismiss onClick={(event) => { event.preventDefault(); event.stopPropagation(); - onDismiss(prompt.requestId); + if (!disabled) onDismiss(prompt.requestId); }} onKeyDown={(event) => { if (event.key !== "Enter" && event.key !== " ") return; event.preventDefault(); event.stopPropagation(); - onDismiss(prompt.requestId); + if (!disabled) onDismiss(prompt.requestId); }} /> ) : null} From d5fad91d0e9cf10c5816657b0a0639a4a5b10a41 Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Tue, 13 Oct 2026 02:30:09 -0400 Subject: [PATCH 10/17] feat(web): who wrote each message of a shared conversation, from the server's record The author list is asked for only when a thread holds a text that begins as an authored message does, and again when the thread brings a new one. With it: the rules for a queued message (a guest changes and withdraws their own, never steers or reorders) and the text the queue shows. Co-Authored-By: Claude Opus 5.5 --- .../sharing/sharedConversation.logic.test.ts | 120 ++++++++++++++++++ .../j5/sharing/sharedConversation.logic.ts | 66 ++++++++++ apps/web/src/j5/sharing/sharedConversation.ts | 72 +++++++++++ 3 files changed, 258 insertions(+) create mode 100644 apps/web/src/j5/sharing/sharedConversation.logic.test.ts create mode 100644 apps/web/src/j5/sharing/sharedConversation.logic.ts create mode 100644 apps/web/src/j5/sharing/sharedConversation.ts diff --git a/apps/web/src/j5/sharing/sharedConversation.logic.test.ts b/apps/web/src/j5/sharing/sharedConversation.logic.test.ts new file mode 100644 index 0000000000000..771aa4fcfe77b --- /dev/null +++ b/apps/web/src/j5/sharing/sharedConversation.logic.test.ts @@ -0,0 +1,120 @@ +import { describe, expect, it } from "vite-plus/test"; + +import { + authorName, + authorsByMessage, + mayHaveAuthorLine, + queuedMessageRules, + queuedMessageTexts, + withoutAuthorLine, +} from "./sharedConversation.logic"; + +const priya = { messageId: "m1", displayName: "Priya", kind: "guest", you: false } as const; +const me = { messageId: "m2", displayName: "Jackson M.", kind: "member", you: true } as const; + +describe("the author line", () => { + it("is taken off every shape the server writes", () => { + expect(withoutAuthorLine("[Message from Priya (guest)]\n\nrun the tests")).toBe( + "run the tests", + ); + expect(withoutAuthorLine("[Message from a member]\n\nhello")).toBe("hello"); + expect( + withoutAuthorLine("[Message from Priya (guest), edited by Jackson M. (member)]\n\nfixed"), + ).toBe("fixed"); + }); + + it("matches every form the server writes", () => { + for (const line of [ + "[Message from Priya (guest)]", + "[Message from Jackson M. (member)]", + "[Message from a member]", + "[Message from a guest]", + "[Message from Priya (guest), edited by Jackson M. (member)]", + "[Message from a guest, edited by a member]", + ]) { + expect(mayHaveAuthorLine(`${line}\n\nwords`)).toBe(true); + expect(withoutAuthorLine(`${line}\n\nwords`)).toBe("words"); + } + }); + + it("does not match J5's older envelopes, which also begin with Message from", () => { + for (const envelope of [ + // A person's inbox reply, an automation's message, an outside agent's message. + "[Message from human:local-operator]\n\nyes, go ahead\n\n", + "[Message from automation task:nightly in project Billing]\n\nrun it\n\n", + "[Message from outside agent Reviewer (outside:42)]\n\nlooks fine\n\n", + ]) { + expect(mayHaveAuthorLine(envelope)).toBe(false); + expect(withoutAuthorLine(envelope)).toBe(envelope); + } + }); + + it("leaves alone a text that only mentions one", () => { + const quoted = "see [Message from Priya (guest)]\n\nabove"; + expect(mayHaveAuthorLine(quoted)).toBe(false); + expect(withoutAuthorLine(quoted)).toBe(quoted); + expect(withoutAuthorLine("[Message from Priya (guest)] same line")).toBe( + "[Message from Priya (guest)] same line", + ); + }); +}); + +describe("a queued message in a shared conversation", () => { + const authors = authorsByMessage([priya, me]); + + it("is a member's to change, withdraw or steer, whoever wrote it", () => { + expect(queuedMessageRules({ isGuest: false, author: authors.get("m1") })).toEqual({ + mayChange: true, + maySteer: true, + }); + expect(queuedMessageRules({ isGuest: false, author: undefined })).toEqual({ + mayChange: true, + maySteer: true, + }); + }); + + it("is a guest's to change or withdraw only when it is their own, and never to steer", () => { + expect(queuedMessageRules({ isGuest: true, author: { you: true } })).toEqual({ + mayChange: true, + maySteer: false, + }); + expect(queuedMessageRules({ isGuest: true, author: { you: false } }).mayChange).toBe(false); + // Not yet in the server's record, such as a message still on its way. + expect(queuedMessageRules({ isGuest: true, author: undefined }).mayChange).toBe(false); + }); + + it("shows the person's own words, with a name on someone else's", () => { + expect(queuedMessageTexts("[Message from Jackson M. (member)]\n\nmine", me).shown).toBe("mine"); + expect(queuedMessageTexts("[Message from Priya (guest)]\n\nhers", priya).shown).toBe( + "Priya: hers", + ); + expect( + queuedMessageTexts("[Message from a guest]\n\ntheirs", { ...priya, displayName: null }).shown, + ).toBe("A guest: theirs"); + }); + + it("hands an editor what the author typed, never the name the queue shows", () => { + // A member who edits a guest's queued message sends back the guest's words, edited. + expect(queuedMessageTexts("[Message from Priya (guest)]\n\nhers", priya).typed).toBe("hers"); + expect( + queuedMessageTexts( + "[Message from Priya (guest), edited by Jackson M. (member)]\n\nhers, fixed", + priya, + ).typed, + ).toBe("hers, fixed"); + }); + + it("leaves a kind a person wrote into their own name out of it", () => { + const posing = { ...priya, displayName: "Jackson (member)" }; + expect(authorName(posing)).toBe("Jackson"); + expect(authorName({ ...priya, displayName: "(Member)" })).toBe("A guest"); + expect(queuedMessageTexts("[Message from Jackson (guest)]\n\nhi", posing).shown).toBe( + "Jackson: hi", + ); + }); + + it("shows a text the server holds no author for as it is", () => { + const typed = "[Message from Priya (guest)]\n\ntyped before sharing"; + expect(queuedMessageTexts(typed, undefined)).toEqual({ typed, shown: typed }); + }); +}); diff --git a/apps/web/src/j5/sharing/sharedConversation.logic.ts b/apps/web/src/j5/sharing/sharedConversation.logic.ts new file mode 100644 index 0000000000000..eeefc454f3c23 --- /dev/null +++ b/apps/web/src/j5/sharing/sharedConversation.logic.ts @@ -0,0 +1,66 @@ +import type { SharingMessageAuthor } from "@t3tools/contracts/j5"; + +// The line the server puts first on a person's message once a thread is a shared conversation +// (`authorLine` in the server's `j5/sharing/SharedConversation.ts`): "[Message from Priya (guest)]", +// "[Message from a member]", or either followed by ", edited by ". It is +// matched exactly, with its "(member)" or "(guest)", because J5's older envelopes also begin +// "[Message from …]" (an inbox reply, an automation, an outside agent) and none of those is a +// reason to ask the server who wrote a message. +const AUTHOR_LABEL = "(?:a (?:member|guest)|[^\\]\\n]* \\((?:member|guest)\\))"; +const AUTHOR_LINE = new RegExp( + `^\\[Message from ${AUTHOR_LABEL}(?:, edited by ${AUTHOR_LABEL})?\\]\\n\\n`, +); + +/** Whether a text begins the way an authored message does; only the server's record says it is one. */ +export const mayHaveAuthorLine = (text: string) => AUTHOR_LINE.test(text); + +/** A message's text as its author typed it. */ +export const withoutAuthorLine = (text: string) => text.replace(AUTHOR_LINE, ""); + +export type AuthorsByMessage = ReadonlyMap; + +export const authorsByMessage = (authors: ReadonlyArray): AuthorsByMessage => + new Map(authors.map((author) => [author.messageId, author])); + +/** + * "Priya", or "A guest" for someone the server holds no name for. A parenthesised "member" or + * "guest" inside a name is left out, as the server leaves it out of the line the agent reads, so + * the only such word beside a name is the platform's own tag: a guest named "Jackson (member)" + * is drawn as Jackson, tagged guest. + */ +export function authorName(author: Pick): string { + const name = (author.displayName ?? "") + .replace(/\(\s*(?:member|guest)\s*\)/gi, " ") + .replace(/\s+/g, " ") + .trim(); + return name !== "" ? name : author.kind === "guest" ? "A guest" : "A member"; +} + +/** + * What one queued message offers one person (Shared conversations AC14 to AC16). A member may + * change, withdraw and steer any of them. A guest changes and withdraws their own and nothing + * else, and never steers: the server holds whose each one is and refuses the rest. + */ +export function queuedMessageRules(input: { + readonly isGuest: boolean; + readonly author: Pick | undefined; +}): { readonly mayChange: boolean; readonly maySteer: boolean } { + if (!input.isGuest) return { mayChange: true, maySteer: true }; + return { mayChange: input.author?.you === true, maySteer: false }; +} + +/** + * A queued message's two texts. `typed` is what its author typed: what an editor is handed and + * what is sent back when it is saved. `shown` is what the queue's line reads, with the name first + * on someone else's; it is for display only, since the agent would read a name sent back as part + * of the message. A text the server holds no author for is both, as it is: a line that looks like + * an author's may have been typed before the thread was shared. + */ +export function queuedMessageTexts( + text: string, + author: Pick | undefined, +): { readonly typed: string; readonly shown: string } { + if (author === undefined) return { typed: text, shown: text }; + const typed = withoutAuthorLine(text); + return { typed, shown: author.you ? typed : `${authorName(author)}: ${typed}` }; +} diff --git a/apps/web/src/j5/sharing/sharedConversation.ts b/apps/web/src/j5/sharing/sharedConversation.ts new file mode 100644 index 0000000000000..db846a3ca6ac9 --- /dev/null +++ b/apps/web/src/j5/sharing/sharedConversation.ts @@ -0,0 +1,72 @@ +import { createEnvironmentRpcQueryAtomFamily } from "@t3tools/client-runtime/state/runtime"; +import type { EnvironmentId, ThreadId } from "@t3tools/contracts"; +import { J5_SHARING_WS_METHODS } from "@t3tools/contracts/j5"; +import { useEffect, useMemo } from "react"; + +import { connectionAtomRuntime } from "../../connection/runtime"; +import { useEnvironmentQuery } from "../../state/query"; +import { useIsGuest } from "./guestAccess"; +import { + authorsByMessage, + mayHaveAuthorLine, + queuedMessageRules, + queuedMessageTexts, + type AuthorsByMessage, +} from "./sharedConversation.logic"; + +const threadAuthors = createEnvironmentRpcQueryAtomFamily(connectionAtomRuntime, { + label: "environment-data:j5-sharing:thread-authors", + tag: J5_SHARING_WS_METHODS.listThreadAuthors, + staleTimeMs: 0, +}); + +const NO_AUTHORS: AuthorsByMessage = new Map(); + +/** + * Who wrote each message of a shared conversation, from the server's record. It is asked only + * when the thread holds a text that begins as an authored one does, so a thread that was never + * shared costs nothing, and asked again when `changes` does: the server has no feed for it, and + * a new row only ever comes with a message or an answer the thread's own stream already brings. + */ +export function useThreadAuthors( + environmentId: EnvironmentId | null, + threadId: ThreadId | null, + texts: ReadonlyArray, + changes: string, +): AuthorsByMessage { + const wanted = environmentId !== null && threadId !== null && texts.some(mayHaveAuthorLine); + const query = useEnvironmentQuery( + wanted ? threadAuthors({ environmentId, input: { threadId } }) : null, + ); + const { refresh } = query; + useEffect(() => { + if (wanted) refresh(); + }, [changes, refresh, wanted]); + const authors = query.data?.authors; + return useMemo(() => (authors === undefined ? NO_AUTHORS : authorsByMessage(authors)), [authors]); +} + +/** + * The queue of a shared conversation as one person may use it: each message with the words its + * author typed, a name on someone else's, and whether this person may change or withdraw it. A + * guest neither steers nor reorders. For a thread that is not shared every item is as upstream + * made it and everything is allowed. + */ +export function useSharedQueue< + Item extends { readonly messageId: string | null; readonly text: string }, +>(environmentId: EnvironmentId, threadId: ThreadId, queued: ReadonlyArray) { + const isGuest = useIsGuest(environmentId); + const authors = useThreadAuthors( + environmentId, + threadId, + queued.map((item) => item.text), + queued.map((item) => item.messageId).join(), + ); + const items = queued.map((item) => { + const author = item.messageId === null ? undefined : authors.get(item.messageId); + const { typed, shown } = queuedMessageTexts(item.text, author); + // `text` goes to the editor and back to the server; `preview` is only ever drawn. + return { ...item, text: typed, preview: shown, ...queuedMessageRules({ isGuest, author }) }; + }); + return { items, mayReorder: !isGuest }; +} From acbd8ae6e74107c94a13e5245fb76fc28853af81 Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Tue, 13 Oct 2026 02:30:09 -0400 Subject: [PATCH 11/17] feat(web): a shared conversation's queue shows who wrote what, and a guest changes only their own Upstream edit awaiting Jackson's approval: QueuedRunsControl.tsx, one import, the list of queued items passed through one J5 hook, and its answer on four conditions (reorder, Edit, Steer, Remove). Co-Authored-By: Claude Opus 5.5 --- .../src/components/chat/QueuedRunsControl.tsx | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/apps/web/src/components/chat/QueuedRunsControl.tsx b/apps/web/src/components/chat/QueuedRunsControl.tsx index 12c7f46c49b1b..3796ef32623c8 100644 --- a/apps/web/src/components/chat/QueuedRunsControl.tsx +++ b/apps/web/src/components/chat/QueuedRunsControl.tsx @@ -1,3 +1,4 @@ +import { useSharedQueue } from "../../j5/sharing/sharedConversation"; import { scopeThreadRef } from "@t3tools/client-runtime/environment"; import { deriveThreadQueueWorkflowState } from "@t3tools/client-runtime/state/thread-workflows"; import { replaceComposerContextReferences } from "@t3tools/shared/composerContextReferences"; @@ -93,7 +94,7 @@ export function QueuedRunsControl({ ); const queued = workflow?.queuedRuns ?? []; const activeRun = workflow?.activeRun ?? null; - const canReorder = workflow?.canReorder === true; + const canReorderAsBuilt = workflow?.canReorder === true; const queuedImageAttachmentIds = useMemo(() => { const ids: string[] = []; for (const { attachments } of workflow?.queuedRuns ?? []) { @@ -135,7 +136,7 @@ export function QueuedRunsControl({ const optimisticQueued = props.optimisticMessages.filter( (message) => message.inputIntent === "queued_turn" && !acknowledgedMessageIds.has(message.id), ); - const items = [ + const queuedItems = [ ...queued.map(({ run, text, attachments }, serverIndex) => ({ key: run.id, runId: run.id, @@ -169,6 +170,10 @@ export function QueuedRunsControl({ pending: true, })), ]; + // J5: in a shared conversation each message shows who wrote it, and a guest changes only their own. + const sharedQueue = useSharedQueue(props.environmentId, props.threadId, queuedItems); + const items = sharedQueue.items; + const canReorder = canReorderAsBuilt && sharedQueue.mayReorder; const participantLabels = useParticipantLabels( props.environmentId, items.flatMap((item) => participantIdsForThreadA2AEnvelope(item.text)), @@ -281,7 +286,7 @@ export function QueuedRunsControl({ } id={queueListId}> {items.map((item) => { - const previewText = replaceComposerContextReferences(item.text, (reference) => + const previewText = replaceComposerContextReferences(item.preview, (reference) => reference.kind === "image" && item.thumbnails.length > 0 ? "" : reference.label, ).trim(); const delivery = formatThreadA2AQueuedDelivery(item.text, participantLabels); @@ -434,7 +439,9 @@ export function QueuedRunsControl({ size="icon-xs" variant="ghost-muted" aria-label="Edit queued message" - disabled={item.runId === null || busyRunId !== null} + disabled={ + item.runId === null || busyRunId !== null || !item.mayChange + } onClick={() => { if (item.runId !== null && item.messageId !== null) { props.onEditQueuedRun({ @@ -462,6 +469,7 @@ export function QueuedRunsControl({ disabled={ item.runId === null || busyRunId !== null || + !item.maySteer || !workflow?.canPromoteToSteer } onClick={() => { @@ -485,7 +493,9 @@ export function QueuedRunsControl({ render={ { if (item.runId !== null) void remove(item.runId); }} From 840dc1ac4e72b0ea49987b32487cb31b92c55f02 Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Tue, 13 Oct 2026 02:43:55 -0400 Subject: [PATCH 12/17] docs: record the collaborate client's upstream edits (FORK case 75) Co-Authored-By: Claude Opus 5.5 --- docs/j5/product/upstream.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/j5/product/upstream.md b/docs/j5/product/upstream.md index 6ca2cd7976901..ee519786003cb 100644 --- a/docs/j5/product/upstream.md +++ b/docs/j5/product/upstream.md @@ -536,3 +536,4 @@ J5 kept a run from resuming after a usage-limit reset when the person had presse - 2026-10-13 — D33: a guest's message carries composer context, with no attachments yet ([#597](https://github.com/Jacksondr5/j5code/issues/597)); the agent is not told who answered an approval; a thread grant writes to the one agent it names and reads those beneath it ([#534](https://github.com/Jacksondr5/j5code/issues/534)); both `ws.ts` wraps approved (Jackson; [#533](https://github.com/Jacksondr5/j5code/issues/533)). - 2026-10-13 — D33: a person's reply from the inbox names them, and says where they stand in a shared conversation (Jackson; [#533](https://github.com/Jacksondr5/j5code/issues/533)). - 2026-10-13 — D33: upstream's launch request is taken in as a message is, so a thread started in a shared project is a shared conversation from its first message; the second `ws.ts` wrap approved (Jackson; [#533](https://github.com/Jacksondr5/j5code/issues/533)). +- 2026-10-13 — D33: a Collaborate guest's composer, queue and approval answers in the web client; draft, each upstream edit awaiting approval (the build lead for Jackson; [#533](https://github.com/Jacksondr5/j5code/issues/533)). From 2ddcc93600222ed862e8c76e1a1bdeea26860070 Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Tue, 13 Oct 2026 17:31:41 -0400 Subject: [PATCH 13/17] feat(web): a guest is not offered "Edit from here" Upstream edit, under the standing permission for one import and one or two lines that hide what a guest could only see refused: MessagesTimeline.tsx, one import and two lines in the button that rewinds a thread from a message. The server refuses a guest's rewind. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/chat/MessagesTimeline.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/web/src/components/chat/MessagesTimeline.tsx b/apps/web/src/components/chat/MessagesTimeline.tsx index 9156e5910bac7..c848662ed459b 100644 --- a/apps/web/src/components/chat/MessagesTimeline.tsx +++ b/apps/web/src/components/chat/MessagesTimeline.tsx @@ -1,3 +1,4 @@ +import { useIsGuest } from "../../j5/sharing/guestAccess"; import { ThreadFindTimelineContext } from "./ThreadFindProvider"; import { shouldPreserveAssistantLineBreaks } from "@t3tools/shared/markdownPipeline"; import { MarkdownFindContext, useFindRevealRef } from "./markdownFindContext"; @@ -2732,6 +2733,8 @@ function RevertUserMessageButton({ }) { const ctx = use(TimelineRowCtx); const activity = use(TimelineRowActivityCtx); + // J5: a guest cannot rewind a thread; the server refuses it, so it is not offered. + if (useIsGuest(ctx.threadRef?.environmentId ?? null)) return null; return ( From c8d1c0eb62566de93707bd19adce51aec1cd2c31 Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Tue, 13 Oct 2026 17:31:50 -0400 Subject: [PATCH 14/17] test(web): the author fixtures carry the record's note field Co-Authored-By: Claude Opus 5.5 --- .../j5/sharing/sharedConversation.logic.test.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/web/src/j5/sharing/sharedConversation.logic.test.ts b/apps/web/src/j5/sharing/sharedConversation.logic.test.ts index 771aa4fcfe77b..ffadd99f01258 100644 --- a/apps/web/src/j5/sharing/sharedConversation.logic.test.ts +++ b/apps/web/src/j5/sharing/sharedConversation.logic.test.ts @@ -9,8 +9,20 @@ import { withoutAuthorLine, } from "./sharedConversation.logic"; -const priya = { messageId: "m1", displayName: "Priya", kind: "guest", you: false } as const; -const me = { messageId: "m2", displayName: "Jackson M.", kind: "member", you: true } as const; +const priya = { + messageId: "m1", + displayName: "Priya", + kind: "guest", + you: false, + note: null, +} as const; +const me = { + messageId: "m2", + displayName: "Jackson M.", + kind: "member", + you: true, + note: null, +} as const; describe("the author line", () => { it("is taken off every shape the server writes", () => { From ea5a427c22c329ac47a265bb036aa2255c7b625e Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Tue, 13 Oct 2026 19:47:22 -0400 Subject: [PATCH 15/17] docs: record the collaborate client's upstream edits as FORK case 76 Main took case 74 and the server's case moved to 75, so this layer's case is 76. Co-Authored-By: Claude Opus 5.5 --- FORK.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/FORK.md b/FORK.md index 9652d4a536f78..9fef623c6c949 100644 --- a/FORK.md +++ b/FORK.md @@ -429,6 +429,7 @@ migrations after upstream migrations. 73. A shared thread says who is on it, and a guest's client fits what a guest can do ([#535](https://github.com/Jacksondr5/j5code/issues/535), [#541](https://github.com/Jacksondr5/j5code/issues/541), register D33, Jackson's 2026-10-12 design and approval of one mount or item in each of these files). All of it is J5-owned code under `apps/web/src/j5/sharing/`, mounted once in each upstream file. `apps/web/src/components/chat/ChatHeader.tsx`: one import and `` after the breadcrumb, for a server thread; it draws nothing unless a guest holds a grant on the thread or its project. `apps/web/src/components/chat/ThreadDetailsPanel.tsx`: one import and `` after `ThreadRelationshipsPanel`, under the same `density === "full" && !props.draftId` condition as its neighbours; it uses upstream's exported `ThreadDetailsSection`. `apps/web/src/components/chat/ChatComposer.tsx`: one import, one hook call after the props are read (`useViewOnlyComposerProps(environmentId, canOperateThread)`), and one spread, `{...viewOnlyComposerProps}`, placed after upstream's `placeholder={…}` prop so that it replaces the placeholder for a guest whose level on the thread is View and is empty for everyone else; a first branch in upstream's nested ternary would have re-indented all of it. The composer collapsed to one line on a narrow window has its own fallback text, `"Ask anything..."`, a few hundred lines above; that literal becomes `(viewOnlyComposerProps.placeholder ?? "Ask anything...")` (one line and a comment). A guest's thread menu needs no further upstream line: case 71's two calls in `useThreadActionMenu.ts` and `Sidebar.tsx` now drop Archive, Delete, "Project settings" and "Share thread…" for a guest and put "Leave thread" where Archive was (`j5/sharing/sharingMenu.ts`, told who is a guest by `guestAccess.ts` so that it still imports nothing of the connection runtime). The chip and the section ask the server who reaches the thread (`j5.sharing.listThreadPeople`) and ask again when its counter moves (`j5.sharing.subscribeThreadPeopleChanges`); that stream joins `EnvironmentSubscriptionRpcTag` in `packages/client-runtime/src/rpc/client.ts`, one more line beside case 69's `subscribeThreadAccess`. Two route files carry the guest's way in (Jackson's 2026-10-13 approval). `apps/web/src/routes/pair.tsx`: the import of upstream's `PairingRouteSurface` becomes an import of J5's `GuestAwarePairingSurface`, and the JSX tag changes with it (three lines; the props are the same and upstream's `components/auth/PairingRouteSurface.tsx` is not edited). J5's surface asks `POST /api/j5/sharing/describe` what the link opens, without spending it, only for a link that carries J5's mark, and waits up to five seconds for the answer. Everything else gets upstream's surface with the props it was given: no token, and any link without the mark, at once and with no request made about it (an ordinary pairing token is sent nowhere but upstream's own exchange); a marked link when the server cannot be asked or does not answer in time. Case 71's link step puts that mark, `j5share=1`, in the fragment beside upstream's `token`; upstream reads the fragment as parameters and takes only `token`, in the direct and the hosted form. `apps/web/src/routes/_chat.index.tsx`: one import, and `` is wrapped in ``. For a member the wrapper renders its child at once, with the sharing answer pending or failed; it holds the frame only for a browser that remembers being paired through a share link (one `localStorage` key, written by the pairing surface and overwritten by the server's answer), and for a guest it shows their thread, a list, or that nothing is shared with them. Upstream's hosted pairing surface is left alone, so a named link opened through the hosted app pairs as upstream has it, and a join link is never offered in the hosted form. Two edits quiet what a guest could only see fail (the build lead under Jackson's 2026-10-13 standing permission for one import and one or two lines). `ThreadDetailsPanel.tsx`, beside the People mount: one more import, `const isGuest = useIsGuest(props.environmentId)` at the top of the component, and `&& !isGuest` on the condition that mounts upstream's `ThreadAutomationsPanel`, which asks for the server's scheduled tasks. `apps/web/src/components/settings/SettingsSidebarNav.tsx`: case 72's nav-filter condition becomes one call into J5, `shownForConnection(item.to)` from `useSettingsNavShown()` (the file gains two lines over case 72), which also leaves Scheduled Tasks, Source Control and Archive, and J5's own Personas and Skills, out of the Settings sidebar of a person who is a guest on every connected server (someone who is also a member of another keeps them; People follows the primary server's own answer); those pages still show upstream's own error to a guest who types their address. `apps/web/src/routes/__root.tsx` (Jackson approved it on 2026-10-13 with one rule: a client is changed only for a person who is a guest on every server they are connected to, never because one of several is a guest one): one import, one hook call beside `primaryEnvironmentAuthenticated`, `useFirstRunSetupOffered(primaryEnvironmentAuthenticated)`, and `FirstRunGate`'s `enabled` reads its answer. For a browser never paired through a share link the answer is upstream's own; a browser that remembers being paired through one is not sent to the setup wizard, which asks a guest to connect computers and import projects, and is offered it again when the server's answer says member and the key clears, or as soon as any other connected server says this person is a member of it (the hook lives in J5's `j5/sharing/firstRunSetup.ts`). `apps/web/src/components/Sidebar.tsx` (approved the same day, under the same rule): one import, `const isGuest = useIsGuestEverywhere()` beside the primary environment's id, and `&& !isGuest` on the empty list's `projects.length === 0` condition, so a guest with nothing shared reads upstream's own "No threads yet" in place of "No projects yet" over an "Add project" button that could only fail. `apps/web/src/j5/artifacts/ArtifactsPage.tsx` is J5's own file. On a pin advance: if upstream moves the composer's `placeholder` prop, keep the spread after it, or a View guest reads upstream's "Ask anything…" over a composer that cannot send; if upstream renames the menu's `archive` or `delete` items, a guest sees them again, disabled, and `sharingMenu.test.ts` still passes, so check a guest's menu in a browser; if upstream reorders the details panel, keep People after Lineage and the guest condition on the Automations mount; if upstream adds a Settings page that asks a guest for what it is not given, add its path to `HIDDEN_FROM_A_GUEST` in `j5/sharing/peopleAccess.ts`; 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` (the web client and the live-test rig's `guest` both mark a link there), whose test in `apps/web/src/j5/sharing/shareLink.logic.test.ts` reads a marked address with upstream's own `getPairingTokenFromUrl`; 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, or a guest's first screen is a draft they cannot send; if upstream renames `FirstRunGate`'s `enabled` or gates first run elsewhere, a guest with nothing shared lands on the setup wizard again. 74. An agent's browser tab is private unless it names a profile (register D34, Jackson's 2026-10-13 decision). Upstream's `resolveOpenProfile` in `apps/server/src/preview/ServerBrowser.ts` gives a `preview_open` call without a `profileId` the person's default profile, whose stored state every agent tab on the server shares. J5 changes that one return to `INCOGNITO_BROWSER_PROFILE_ID`, which the file already imports, so the tab gets its own throwaway storage through upstream's existing incognito path. A named profile resolves as upstream's does. The `preview_open` description in `apps/server/src/mcp/toolkits/preview/tools.ts` changes one clause to say what omitting `profileId` now means. `ServerBrowser.test.ts` changes two expectations and their test titles. On a pin advance, keep the return and the description clause; if upstream makes agent tabs private by default, take upstream's and retire this case and D34. 75. A guest who holds Collaborate writes to the agent, and the agent is told who is speaking ([#533](https://github.com/Jacksondr5/j5code/issues/533), register D33, Jackson's 2026-10-09 and 2026-10-11 rulings; both `ws.ts` edits approved by Jackson, 2026-10-13). All of it is J5-owned code under `apps/server/src/j5/sharing/` (`GuestCommands.ts`, `SharedConversation.ts`, `sharedConversationNotes.ts`) and `apps/server/src/j5/a2a/`, reached from one upstream file. In `apps/server/src/ws.ts`, `layerWsRpc` reads `sharedConversation` once and returns upstream's handler record with `orchestration.dispatchCommand` wrapped: `admit(currentSession, command)` runs before upstream's own handler and hands it the command to dispatch, and `orchestration.launchThread` is wrapped the same way with `admitLaunch(currentSession, input)`, because a new thread's first message comes in the launch request and not as a command (approved by Jackson, 2026-10-13; one import, one type import, one read, and the wrapped return; nothing inside upstream's handlers changes, and nothing runs after them). These two are the only requests by which a client puts a person's message on a thread; if upstream adds a third, it must be wrapped too. For a member's connection in a thread no guest holds Collaborate on, `admit` returns the very command it was given. What that costs a member: with no Collaborate grant anywhere on the server, two point reads for a message or for a launch with a first message, two for an approval, three for an answer to a question, two for a queued edit and none for any other command; with a Collaborate grant somewhere on the server, one walk up the thread's parents more for each of those reads that asks whether the thread is shared. In a shared conversation it puts the author's line first in a person's message text. For a guest's connection it refuses every command type but the five in `GUEST_COMMAND_TYPES` and rebuilds each from the fields a guest may set, so a guest's message always uses upstream's `queue_after_active`, and sends each on under `guestCommandId`, a command id inside a space that is that one person's (upstream replays any id it holds a receipt for on the thread as success, so no guest may name an id anyone else uses; a guest's own retry still finds its receipt). The guest gate's rule for `orchestration.dispatchCommand` reads the thread from the command itself and needs Collaborate on it. A platform note to the agent is never a message of its own: it goes at the top of the message a person sends next, in the same stored text, so J5 sends nothing through upstream for it. J5's one command of its own is `queued-run.cancel`, through `ThreadManagementService.dispatch`, to withdraw a queued message, under an id with a random part; it then reads the run again and logs an error if it is still queued. Nothing in `Orchestrator.ts`, the adapters or upstream's contracts is edited; who wrote a message and who answered a prompt are J5's own tables (migrations 39 to 41). **At each advance:** J5 reads upstream's records by SQL in four places. (1) `orchestration_v2_projection_runs`: a run's `run_id`, `thread_id`, `status` (`queued`, `cancelled`, `failed`, `interrupted` and `rolled_back` are the values it tests for, typed against upstream's union where they are named in code) and the `userMessageId` and `startedAt` in its `payload_json`, to know whose queued message a run is, to withdraw one, and to know whether a message ever reached the agent. (2) `orchestration_v2_projection_messages`: a message by `message_id`, and its `run_id`, for the same question and to refuse a guest's send that names an existing message. (3) `orchestration_events`, upstream's event log: `command_id`, `aggregate_kind = 'thread'`, `stream_id` as the thread, `event_type = 'runtime-request.updated'` and the `id` in `payload_json`, to know which command settled a prompt. That read is by `command_id` on every read of who answered, so it depends on upstream's index `idx_orch_events_command_id`; if upstream drops it, add one in a J5 migration. (4) `orchestration_v2_projection_runtime_requests`: a request's `kind` and `status` by `runtime_request_id` and `thread_id` (`user_input` and `pending` are the values it tests for), so a guest answers only a prompt that is waiting, a question in words and any other prompt by a decision. Check also that upstream still replays a command id it holds a receipt for, and still makes its recovery ids from the thread and a time: `guestCommandId` exists because of both. `apps/server/src/j5/sharing/SharedConversation.integration.test.ts` runs a shared conversation over upstream's real orchestrator and fails if the runs, the messages or the log's columns are reshaped; run it. It cannot raise a prompt without a provider, so it pins the log on a message's event: the event type is held instead by `PROMPT_SETTLED_EVENT` in `SharedConversation.ts`, typed against upstream's event union, which fails to compile on a rename. Check by hand that upstream still logs that event with the answering command's id when a prompt is answered or dismissed, that the log's compaction (`ProjectionMaintenance.ts`) still keeps it, and that a rewind still marks runs `rolled_back` and keeps their messages. Re-read `GUEST_COMMAND_TYPES` against upstream's command union for new types. +76. A guest who holds Collaborate uses the web client ([#533](https://github.com/Jacksondr5/j5code/issues/533), register D33; **draft: every upstream edit here awaits Jackson's approval, each its own commit so it can be dropped alone**). The level controls, the "Let … collaborate?" dialog and every decision are J5-owned files under `apps/web/src/j5/sharing/` (`PromoteDialog.tsx`, `guestComposer.ts`, `sharedConversation.ts` and their `.logic.ts`). The Share dialog's Collaborate line says "Also send messages to the agent and answer its prompts."; the design's line also promised the in-app browser, which is not open to a guest. Upstream's files gain calls into those. `apps/web/src/components/ChatView.tsx`: one more import; the condition that draws Stop reads `useMayInterruptThread(environmentId, canOperateThread)` in place of `canOperateThread` (false for a guest, upstream's answer otherwise); and the command that saves an edited queued message is wrapped, `useGuestEditsAsText(editQueuedRunAsBuilt)`, so a guest's carries its text alone (upstream's always carries attachments and context, which the server refuses from a guest). `apps/web/src/components/chat/ChatComposer.tsx`: one import and one hook call, `useGuestComposer(environmentId)`, beside case 73's; its answers on four lines: `if (guestComposer.refusesFiles()) return false;` at the top of `addComposerAttachments` (paste and drop; the attach control itself is already absent for a guest, whose server reports no file uploads, but upstream accepts a pasted image whatever the server says), `|| guestComposer.textOnly` on the first line of the @ / $ / slash menu's list with its dependency, `guestComposer.followUpBehavior(settings.followUpBehavior)` where the send button is told how a follow-up goes, and `guestComposer.approvalOptions(activePendingApproval.options)` where an approval is given its answers (a guest gets accept, decline and cancel). `apps/web/src/components/chat/QueuedRunsControl.tsx`: one import, the built list renamed `queuedItems` and passed through `useSharedQueue(…)`, which returns each item with `text` as the words its author typed (what the editor is handed and what is sent back), `preview` as what the line shows (a name first on someone else's), and `mayChange` / `maySteer`; the line that builds the preview reads `item.preview`, and those two and `mayReorder` join four conditions (reorder, Edit, Steer, Remove). `apps/web/src/components/chat/ComposerPendingUserInputPanel.tsx`: Dismiss's `disabled={isResponding}` becomes `disabled={isResponding || disabled}` and its click and key handlers call `onDismiss` only `if (!disabled)` (three lines), since it ignored the panel's own `disabled` and is drawn as a `span`, which a `disabled` attribute does not stop (it reads as a small upstream bug: a connection that cannot answer was offered a Dismiss the server refuses). `apps/web/src/components/chat/MessagesTimeline.tsx`: one import and two lines at the top of `RevertUserMessageButton` (`if (useIsGuest(ctx.threadRef?.environmentId ?? null)) return null;`), so a guest's own message does not offer "Edit from here", which rewinds the thread and which the server refuses from a guest (the build lead, under Jackson's 2026-10-13 standing permission). Not edited, and so still offered to a guest and dropped or refused by the server: the model, effort and access pickers, dragging a thread or file onto the composer as context, the queue's two keyboard shortcuts, and Stop for background work. A guest's client still sends upstream's `thread.visit` when a message arrives and is refused; nothing shows. On a pin advance: if upstream moves any of these conditions, re-apply the J5 answer beside it and check a guest's composer and queue in a browser, since nothing fails to compile when a call is lost except the two renamed constants (`editQueuedRunAsBuilt`, `queuedItems`); if upstream starts sending anything else with `message.dispatch` or `queued-run.edit`, reread the server's `GuestCommands.ts`. ## Pin and upstream advance runbook @@ -761,7 +762,7 @@ explicitly marked. | `packages/client-runtime/src/rpc/client.ts` | A | 45, 64, 69, 73 | | `apps/web/src/composer-logic.ts` | A | 45, 49 | | `apps/server/src/auth/RpcAuthorization.ts` | A | 42, 44, 45, 64 | -| `apps/web/src/components/ChatView.tsx` | A | 19, 24, 45, 49, 69 | +| `apps/web/src/components/ChatView.tsx` | A | 19, 24, 45, 49, 69, 76 | | `apps/web/src/environments/primary/auth.ts` | N | 70 | | `apps/web/src/components/CommandPalette.logic.test.ts` | R | 34 | | `apps/web/src/components/CommandPalette.logic.ts` | R | 34 | @@ -772,10 +773,12 @@ explicitly marked. | `apps/web/src/components/Sidebar.logic.ts` | R | 21 | | `apps/web/src/components/Sidebar.tsx` | A | 21–23, 71, 73 | | `apps/web/src/components/chat/ChatComposer.tsx` | A | Saved-agent mentions, Role library, 45, 49, 73 | +| `apps/web/src/components/chat/ChatComposer.tsx` (continued) | A | 76 | | `apps/web/src/components/chat/MessagesTimeline.test.tsx` | N | B | | `apps/web/src/components/chat/timelineMinimapItems.ts` | A | 24 | -| `apps/web/src/components/chat/MessagesTimeline.tsx` | A | B, 7, 24 | -| `apps/web/src/components/chat/QueuedRunsControl.tsx` | A | 24 | +| `apps/web/src/components/chat/MessagesTimeline.tsx` | A | B, 7, 24, 76 | +| `apps/web/src/components/chat/QueuedRunsControl.tsx` | A | 24, 76 | +| `apps/web/src/components/chat/ComposerPendingUserInputPanel.tsx` | N | 76 | | `apps/web/src/components/sidebar/SidebarChrome.tsx` | A | 6, 33, B | | `apps/web/src/confirmDialog.test.ts` | R | 22 | | `apps/web/src/confirmDialog.ts` | R | 22 | From cdc37e14624ddacea839ff0abdee84b3edc0e816 Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Tue, 13 Oct 2026 21:31:04 -0400 Subject: [PATCH 16/17] feat(web): a guest's composer offers mentions and context again, and keeps refusing attachments The server now takes mentions and the other composer context from a Collaborate guest, on a message and on a queued edit, and still refuses attachments. So the @, $ and / menu opens for a guest as for anyone, and a guest's edit of a queued message goes as upstream builds it, context included. Two upstream edits are taken back out: the menu's condition in ChatComposer.tsx and the wrap of the queued-edit command in ChatView.tsx. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/ChatView.tsx | 6 +-- apps/web/src/components/chat/ChatComposer.tsx | 3 +- .../j5/sharing/guestComposer.logic.test.ts | 14 +------ .../web/src/j5/sharing/guestComposer.logic.ts | 19 +-------- apps/web/src/j5/sharing/guestComposer.ts | 41 ++++--------------- 5 files changed, 13 insertions(+), 70 deletions(-) diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index d13002f0805ca..fd5d62b1cd88c 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -40,7 +40,7 @@ import { feedbackBannerItem } from "./chat/ComposerFeedback"; import { usageLimitsBannerItem } from "./chat/ComposerUsageLimits"; import { CrewRosterGate } from "../j5/crew/CrewRosterGate"; import { useCanOperateThread } from "../j5/sharing/guestAccess"; -import { useGuestEditsAsText, useMayInterruptThread } from "../j5/sharing/guestComposer"; +import { useMayInterruptThread } from "../j5/sharing/guestComposer"; import { expandPlaybookPrompt } from "@t3tools/client-runtime/j5/playbooks"; import { PlaybookBoard } from "../j5/playbooks/PlaybookBoard"; import { getTerminalLabel } from "@t3tools/shared/terminalLabels"; @@ -4652,11 +4652,9 @@ export default function ChatView(props: ChatViewProps) { }, [activeThreadId, environmentId, interactionMode, isServerThread, runtimeMode, startThreadTurn], ); - const editQueuedRunAsBuilt = useAtomCommand(threadEnvironment.editQueuedRun, { + const editQueuedRunCommand = useAtomCommand(threadEnvironment.editQueuedRun, { reportFailure: false, }); - // J5: a guest's edit of their own queued message is sent as text alone. - const editQueuedRunCommand = useGuestEditsAsText(editQueuedRunAsBuilt); const queuedRunsControlRef = useRef(null); const queuedEditSaveInFlightRef = useRef(false); const [isSavingQueuedEdit, setIsSavingQueuedEdit] = useState(false); diff --git a/apps/web/src/components/chat/ChatComposer.tsx b/apps/web/src/components/chat/ChatComposer.tsx index 77d1090fb7f9d..25d029b892b61 100644 --- a/apps/web/src/components/chat/ChatComposer.tsx +++ b/apps/web/src/components/chat/ChatComposer.tsx @@ -2691,7 +2691,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) ); const effectiveAgentAssignment = agentPersonaAssignment ?? draftAgent.assignment ?? undefined; const composerMenuItems = useMemo(() => { - if (!composerTrigger || guestComposer.textOnly) return []; + if (!composerTrigger) return []; if (composerTrigger.kind === "agent") return agentPicker.items; if (composerTrigger.kind === "slash-playbook") return playbookMenuItems(playbookQuery.data?.playbooks ?? [], composerTrigger, prompt); @@ -2860,7 +2860,6 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) } return []; }, [ - guestComposer.textOnly, activeThreadId, agentPicker.items, playbookQuery.data, diff --git a/apps/web/src/j5/sharing/guestComposer.logic.test.ts b/apps/web/src/j5/sharing/guestComposer.logic.test.ts index ea44aeeec3329..99785671cb88d 100644 --- a/apps/web/src/j5/sharing/guestComposer.logic.test.ts +++ b/apps/web/src/j5/sharing/guestComposer.logic.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from "vite-plus/test"; -import { approvalOptionsFor, queuedEditFor } from "./guestComposer.logic"; +import { approvalOptionsFor } from "./guestComposer.logic"; describe("the answers an approval offers", () => { const listed = [ @@ -32,15 +32,3 @@ describe("the answers an approval offers", () => { ).toEqual(["cancel", "decline", "accept"]); }); }); - -describe("changing a queued message", () => { - const input = { runId: "run-1", text: "fixed typo", edit: { attachments: [], context: {} } }; - - it("sends a guest's as text alone", () => { - expect(queuedEditFor(true, input)).toEqual({ runId: "run-1", text: "fixed typo" }); - }); - - it("sends a member's as upstream built it", () => { - expect(queuedEditFor(false, input)).toBe(input); - }); -}); diff --git a/apps/web/src/j5/sharing/guestComposer.logic.ts b/apps/web/src/j5/sharing/guestComposer.logic.ts index c97db4eb9bd40..aeacbb847ebbe 100644 --- a/apps/web/src/j5/sharing/guestComposer.logic.ts +++ b/apps/web/src/j5/sharing/guestComposer.logic.ts @@ -1,8 +1,7 @@ import type { ProviderApprovalOption } from "@t3tools/contracts"; -/** What a guest is told when they try to send more than text. */ -export const GUEST_TEXT_ONLY = - "A guest can send text only: no attachments, mentions or other context."; +/** What a guest is told when they try to attach a file or an image. */ +export const GUEST_NO_ATTACHMENTS = "A guest cannot send attachments yet."; // The server takes these three from a guest and refuses "for this session" and "always". const GUEST_APPROVAL_OPTIONS = [ @@ -27,17 +26,3 @@ export function approvalOptionsFor( ); return listed.length === 0 ? GUEST_APPROVAL_OPTIONS : listed; } - -/** - * What a guest's command to change a queued message of their own carries: the text. The server - * refuses a guest's attachments and context, which upstream's edit always sends. A member's - * command is returned as it is. - */ -export function queuedEditFor( - isGuest: boolean, - input: Input, -): Input { - if (!isGuest || input.edit === undefined) return input; - const { edit: _edit, ...textOnly } = input; - return textOnly as Input; -} diff --git a/apps/web/src/j5/sharing/guestComposer.ts b/apps/web/src/j5/sharing/guestComposer.ts index e9ce168e637f1..709b2b74a4c32 100644 --- a/apps/web/src/j5/sharing/guestComposer.ts +++ b/apps/web/src/j5/sharing/guestComposer.ts @@ -1,27 +1,24 @@ import type { EnvironmentId, ProviderApprovalOption } from "@t3tools/contracts"; -import { useCallback, useMemo } from "react"; +import { useMemo } from "react"; import { toastManager } from "../../components/ui/toast"; -import { appAtomRegistry } from "../../rpc/atomRegistry"; -import { j5Sharing, useIsGuest } from "./guestAccess"; -import { approvalOptionsFor, GUEST_TEXT_ONLY, queuedEditFor } from "./guestComposer.logic"; +import { useIsGuest } from "./guestAccess"; +import { approvalOptionsFor, GUEST_NO_ATTACHMENTS } from "./guestComposer.logic"; /** * What a guest's composer leaves out (Shared conversations AC14 to AC16). A guest who may write - * to a thread sends text: the server rebuilds their message from it and refuses attachments and - * context. Their message queues behind running work and never steers it, and they do not stop a - * run. For a member every answer here is upstream's own. + * to a thread sends what a member does, mentions and other context included, except attachments, + * which the server refuses from a guest for now. Their message queues behind running work and + * never steers it, and they do not stop a run. For a member every answer here is upstream's own. */ export function useGuestComposer(environmentId: EnvironmentId | null) { const isGuest = useIsGuest(environmentId); return useMemo( () => ({ - /** No attach control, and no @, $ or / menu, since each adds what the server refuses. */ - textOnly: isGuest, /** Says why and returns true when a guest tries to add files, by paste or drop. */ refusesFiles: () => { if (!isGuest) return false; - toastManager.add({ type: "error", title: GUEST_TEXT_ONLY }); + toastManager.add({ type: "error", title: GUEST_NO_ATTACHMENTS }); return true; }, /** A guest's follow-up always queues, whatever this person's own setting is elsewhere. */ @@ -41,27 +38,3 @@ export function useMayInterruptThread( ): boolean { return useIsGuest(environmentId) ? false : canOperateThread; } - -/** - * Wraps upstream's command that changes a queued message so that a guest's carries its text - * alone; see `queuedEditFor`. Whose connection it is is read when the command runs. - */ -export function useGuestEditsAsText< - Target extends { - readonly environmentId: EnvironmentId; - readonly input: { readonly edit?: unknown }; - }, - Result, ->(command: (target: Target) => Result): (target: Target) => Result { - return useCallback( - (target: Target) => - command({ - ...target, - input: queuedEditFor( - appAtomRegistry.get(j5Sharing.isGuest(target.environmentId)), - target.input, - ), - }), - [command], - ); -} From f3b5cf5e35da6f184a34a957a1295cc0bc5b7a54 Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Tue, 13 Oct 2026 21:44:16 -0400 Subject: [PATCH 17/17] docs: FORK case 76 as approved, without the menu and queued-edit edits Co-Authored-By: Claude Opus 5.5 --- FORK.md | 2 +- docs/j5/product/upstream.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/FORK.md b/FORK.md index 9fef623c6c949..89ad8d6453c76 100644 --- a/FORK.md +++ b/FORK.md @@ -429,7 +429,7 @@ migrations after upstream migrations. 73. A shared thread says who is on it, and a guest's client fits what a guest can do ([#535](https://github.com/Jacksondr5/j5code/issues/535), [#541](https://github.com/Jacksondr5/j5code/issues/541), register D33, Jackson's 2026-10-12 design and approval of one mount or item in each of these files). All of it is J5-owned code under `apps/web/src/j5/sharing/`, mounted once in each upstream file. `apps/web/src/components/chat/ChatHeader.tsx`: one import and `` after the breadcrumb, for a server thread; it draws nothing unless a guest holds a grant on the thread or its project. `apps/web/src/components/chat/ThreadDetailsPanel.tsx`: one import and `` after `ThreadRelationshipsPanel`, under the same `density === "full" && !props.draftId` condition as its neighbours; it uses upstream's exported `ThreadDetailsSection`. `apps/web/src/components/chat/ChatComposer.tsx`: one import, one hook call after the props are read (`useViewOnlyComposerProps(environmentId, canOperateThread)`), and one spread, `{...viewOnlyComposerProps}`, placed after upstream's `placeholder={…}` prop so that it replaces the placeholder for a guest whose level on the thread is View and is empty for everyone else; a first branch in upstream's nested ternary would have re-indented all of it. The composer collapsed to one line on a narrow window has its own fallback text, `"Ask anything..."`, a few hundred lines above; that literal becomes `(viewOnlyComposerProps.placeholder ?? "Ask anything...")` (one line and a comment). A guest's thread menu needs no further upstream line: case 71's two calls in `useThreadActionMenu.ts` and `Sidebar.tsx` now drop Archive, Delete, "Project settings" and "Share thread…" for a guest and put "Leave thread" where Archive was (`j5/sharing/sharingMenu.ts`, told who is a guest by `guestAccess.ts` so that it still imports nothing of the connection runtime). The chip and the section ask the server who reaches the thread (`j5.sharing.listThreadPeople`) and ask again when its counter moves (`j5.sharing.subscribeThreadPeopleChanges`); that stream joins `EnvironmentSubscriptionRpcTag` in `packages/client-runtime/src/rpc/client.ts`, one more line beside case 69's `subscribeThreadAccess`. Two route files carry the guest's way in (Jackson's 2026-10-13 approval). `apps/web/src/routes/pair.tsx`: the import of upstream's `PairingRouteSurface` becomes an import of J5's `GuestAwarePairingSurface`, and the JSX tag changes with it (three lines; the props are the same and upstream's `components/auth/PairingRouteSurface.tsx` is not edited). J5's surface asks `POST /api/j5/sharing/describe` what the link opens, without spending it, only for a link that carries J5's mark, and waits up to five seconds for the answer. Everything else gets upstream's surface with the props it was given: no token, and any link without the mark, at once and with no request made about it (an ordinary pairing token is sent nowhere but upstream's own exchange); a marked link when the server cannot be asked or does not answer in time. Case 71's link step puts that mark, `j5share=1`, in the fragment beside upstream's `token`; upstream reads the fragment as parameters and takes only `token`, in the direct and the hosted form. `apps/web/src/routes/_chat.index.tsx`: one import, and `` is wrapped in ``. For a member the wrapper renders its child at once, with the sharing answer pending or failed; it holds the frame only for a browser that remembers being paired through a share link (one `localStorage` key, written by the pairing surface and overwritten by the server's answer), and for a guest it shows their thread, a list, or that nothing is shared with them. Upstream's hosted pairing surface is left alone, so a named link opened through the hosted app pairs as upstream has it, and a join link is never offered in the hosted form. Two edits quiet what a guest could only see fail (the build lead under Jackson's 2026-10-13 standing permission for one import and one or two lines). `ThreadDetailsPanel.tsx`, beside the People mount: one more import, `const isGuest = useIsGuest(props.environmentId)` at the top of the component, and `&& !isGuest` on the condition that mounts upstream's `ThreadAutomationsPanel`, which asks for the server's scheduled tasks. `apps/web/src/components/settings/SettingsSidebarNav.tsx`: case 72's nav-filter condition becomes one call into J5, `shownForConnection(item.to)` from `useSettingsNavShown()` (the file gains two lines over case 72), which also leaves Scheduled Tasks, Source Control and Archive, and J5's own Personas and Skills, out of the Settings sidebar of a person who is a guest on every connected server (someone who is also a member of another keeps them; People follows the primary server's own answer); those pages still show upstream's own error to a guest who types their address. `apps/web/src/routes/__root.tsx` (Jackson approved it on 2026-10-13 with one rule: a client is changed only for a person who is a guest on every server they are connected to, never because one of several is a guest one): one import, one hook call beside `primaryEnvironmentAuthenticated`, `useFirstRunSetupOffered(primaryEnvironmentAuthenticated)`, and `FirstRunGate`'s `enabled` reads its answer. For a browser never paired through a share link the answer is upstream's own; a browser that remembers being paired through one is not sent to the setup wizard, which asks a guest to connect computers and import projects, and is offered it again when the server's answer says member and the key clears, or as soon as any other connected server says this person is a member of it (the hook lives in J5's `j5/sharing/firstRunSetup.ts`). `apps/web/src/components/Sidebar.tsx` (approved the same day, under the same rule): one import, `const isGuest = useIsGuestEverywhere()` beside the primary environment's id, and `&& !isGuest` on the empty list's `projects.length === 0` condition, so a guest with nothing shared reads upstream's own "No threads yet" in place of "No projects yet" over an "Add project" button that could only fail. `apps/web/src/j5/artifacts/ArtifactsPage.tsx` is J5's own file. On a pin advance: if upstream moves the composer's `placeholder` prop, keep the spread after it, or a View guest reads upstream's "Ask anything…" over a composer that cannot send; if upstream renames the menu's `archive` or `delete` items, a guest sees them again, disabled, and `sharingMenu.test.ts` still passes, so check a guest's menu in a browser; if upstream reorders the details panel, keep People after Lineage and the guest condition on the Automations mount; if upstream adds a Settings page that asks a guest for what it is not given, add its path to `HIDDEN_FROM_A_GUEST` in `j5/sharing/peopleAccess.ts`; 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` (the web client and the live-test rig's `guest` both mark a link there), whose test in `apps/web/src/j5/sharing/shareLink.logic.test.ts` reads a marked address with upstream's own `getPairingTokenFromUrl`; 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, or a guest's first screen is a draft they cannot send; if upstream renames `FirstRunGate`'s `enabled` or gates first run elsewhere, a guest with nothing shared lands on the setup wizard again. 74. An agent's browser tab is private unless it names a profile (register D34, Jackson's 2026-10-13 decision). Upstream's `resolveOpenProfile` in `apps/server/src/preview/ServerBrowser.ts` gives a `preview_open` call without a `profileId` the person's default profile, whose stored state every agent tab on the server shares. J5 changes that one return to `INCOGNITO_BROWSER_PROFILE_ID`, which the file already imports, so the tab gets its own throwaway storage through upstream's existing incognito path. A named profile resolves as upstream's does. The `preview_open` description in `apps/server/src/mcp/toolkits/preview/tools.ts` changes one clause to say what omitting `profileId` now means. `ServerBrowser.test.ts` changes two expectations and their test titles. On a pin advance, keep the return and the description clause; if upstream makes agent tabs private by default, take upstream's and retire this case and D34. 75. A guest who holds Collaborate writes to the agent, and the agent is told who is speaking ([#533](https://github.com/Jacksondr5/j5code/issues/533), register D33, Jackson's 2026-10-09 and 2026-10-11 rulings; both `ws.ts` edits approved by Jackson, 2026-10-13). All of it is J5-owned code under `apps/server/src/j5/sharing/` (`GuestCommands.ts`, `SharedConversation.ts`, `sharedConversationNotes.ts`) and `apps/server/src/j5/a2a/`, reached from one upstream file. In `apps/server/src/ws.ts`, `layerWsRpc` reads `sharedConversation` once and returns upstream's handler record with `orchestration.dispatchCommand` wrapped: `admit(currentSession, command)` runs before upstream's own handler and hands it the command to dispatch, and `orchestration.launchThread` is wrapped the same way with `admitLaunch(currentSession, input)`, because a new thread's first message comes in the launch request and not as a command (approved by Jackson, 2026-10-13; one import, one type import, one read, and the wrapped return; nothing inside upstream's handlers changes, and nothing runs after them). These two are the only requests by which a client puts a person's message on a thread; if upstream adds a third, it must be wrapped too. For a member's connection in a thread no guest holds Collaborate on, `admit` returns the very command it was given. What that costs a member: with no Collaborate grant anywhere on the server, two point reads for a message or for a launch with a first message, two for an approval, three for an answer to a question, two for a queued edit and none for any other command; with a Collaborate grant somewhere on the server, one walk up the thread's parents more for each of those reads that asks whether the thread is shared. In a shared conversation it puts the author's line first in a person's message text. For a guest's connection it refuses every command type but the five in `GUEST_COMMAND_TYPES` and rebuilds each from the fields a guest may set, so a guest's message always uses upstream's `queue_after_active`, and sends each on under `guestCommandId`, a command id inside a space that is that one person's (upstream replays any id it holds a receipt for on the thread as success, so no guest may name an id anyone else uses; a guest's own retry still finds its receipt). The guest gate's rule for `orchestration.dispatchCommand` reads the thread from the command itself and needs Collaborate on it. A platform note to the agent is never a message of its own: it goes at the top of the message a person sends next, in the same stored text, so J5 sends nothing through upstream for it. J5's one command of its own is `queued-run.cancel`, through `ThreadManagementService.dispatch`, to withdraw a queued message, under an id with a random part; it then reads the run again and logs an error if it is still queued. Nothing in `Orchestrator.ts`, the adapters or upstream's contracts is edited; who wrote a message and who answered a prompt are J5's own tables (migrations 39 to 41). **At each advance:** J5 reads upstream's records by SQL in four places. (1) `orchestration_v2_projection_runs`: a run's `run_id`, `thread_id`, `status` (`queued`, `cancelled`, `failed`, `interrupted` and `rolled_back` are the values it tests for, typed against upstream's union where they are named in code) and the `userMessageId` and `startedAt` in its `payload_json`, to know whose queued message a run is, to withdraw one, and to know whether a message ever reached the agent. (2) `orchestration_v2_projection_messages`: a message by `message_id`, and its `run_id`, for the same question and to refuse a guest's send that names an existing message. (3) `orchestration_events`, upstream's event log: `command_id`, `aggregate_kind = 'thread'`, `stream_id` as the thread, `event_type = 'runtime-request.updated'` and the `id` in `payload_json`, to know which command settled a prompt. That read is by `command_id` on every read of who answered, so it depends on upstream's index `idx_orch_events_command_id`; if upstream drops it, add one in a J5 migration. (4) `orchestration_v2_projection_runtime_requests`: a request's `kind` and `status` by `runtime_request_id` and `thread_id` (`user_input` and `pending` are the values it tests for), so a guest answers only a prompt that is waiting, a question in words and any other prompt by a decision. Check also that upstream still replays a command id it holds a receipt for, and still makes its recovery ids from the thread and a time: `guestCommandId` exists because of both. `apps/server/src/j5/sharing/SharedConversation.integration.test.ts` runs a shared conversation over upstream's real orchestrator and fails if the runs, the messages or the log's columns are reshaped; run it. It cannot raise a prompt without a provider, so it pins the log on a message's event: the event type is held instead by `PROMPT_SETTLED_EVENT` in `SharedConversation.ts`, typed against upstream's event union, which fails to compile on a rename. Check by hand that upstream still logs that event with the answering command's id when a prompt is answered or dismissed, that the log's compaction (`ProjectionMaintenance.ts`) still keeps it, and that a rewind still marks runs `rolled_back` and keeps their messages. Re-read `GUEST_COMMAND_TYPES` against upstream's command union for new types. -76. A guest who holds Collaborate uses the web client ([#533](https://github.com/Jacksondr5/j5code/issues/533), register D33; **draft: every upstream edit here awaits Jackson's approval, each its own commit so it can be dropped alone**). The level controls, the "Let … collaborate?" dialog and every decision are J5-owned files under `apps/web/src/j5/sharing/` (`PromoteDialog.tsx`, `guestComposer.ts`, `sharedConversation.ts` and their `.logic.ts`). The Share dialog's Collaborate line says "Also send messages to the agent and answer its prompts."; the design's line also promised the in-app browser, which is not open to a guest. Upstream's files gain calls into those. `apps/web/src/components/ChatView.tsx`: one more import; the condition that draws Stop reads `useMayInterruptThread(environmentId, canOperateThread)` in place of `canOperateThread` (false for a guest, upstream's answer otherwise); and the command that saves an edited queued message is wrapped, `useGuestEditsAsText(editQueuedRunAsBuilt)`, so a guest's carries its text alone (upstream's always carries attachments and context, which the server refuses from a guest). `apps/web/src/components/chat/ChatComposer.tsx`: one import and one hook call, `useGuestComposer(environmentId)`, beside case 73's; its answers on four lines: `if (guestComposer.refusesFiles()) return false;` at the top of `addComposerAttachments` (paste and drop; the attach control itself is already absent for a guest, whose server reports no file uploads, but upstream accepts a pasted image whatever the server says), `|| guestComposer.textOnly` on the first line of the @ / $ / slash menu's list with its dependency, `guestComposer.followUpBehavior(settings.followUpBehavior)` where the send button is told how a follow-up goes, and `guestComposer.approvalOptions(activePendingApproval.options)` where an approval is given its answers (a guest gets accept, decline and cancel). `apps/web/src/components/chat/QueuedRunsControl.tsx`: one import, the built list renamed `queuedItems` and passed through `useSharedQueue(…)`, which returns each item with `text` as the words its author typed (what the editor is handed and what is sent back), `preview` as what the line shows (a name first on someone else's), and `mayChange` / `maySteer`; the line that builds the preview reads `item.preview`, and those two and `mayReorder` join four conditions (reorder, Edit, Steer, Remove). `apps/web/src/components/chat/ComposerPendingUserInputPanel.tsx`: Dismiss's `disabled={isResponding}` becomes `disabled={isResponding || disabled}` and its click and key handlers call `onDismiss` only `if (!disabled)` (three lines), since it ignored the panel's own `disabled` and is drawn as a `span`, which a `disabled` attribute does not stop (it reads as a small upstream bug: a connection that cannot answer was offered a Dismiss the server refuses). `apps/web/src/components/chat/MessagesTimeline.tsx`: one import and two lines at the top of `RevertUserMessageButton` (`if (useIsGuest(ctx.threadRef?.environmentId ?? null)) return null;`), so a guest's own message does not offer "Edit from here", which rewinds the thread and which the server refuses from a guest (the build lead, under Jackson's 2026-10-13 standing permission). Not edited, and so still offered to a guest and dropped or refused by the server: the model, effort and access pickers, dragging a thread or file onto the composer as context, the queue's two keyboard shortcuts, and Stop for background work. A guest's client still sends upstream's `thread.visit` when a message arrives and is refused; nothing shows. On a pin advance: if upstream moves any of these conditions, re-apply the J5 answer beside it and check a guest's composer and queue in a browser, since nothing fails to compile when a call is lost except the two renamed constants (`editQueuedRunAsBuilt`, `queuedItems`); if upstream starts sending anything else with `message.dispatch` or `queued-run.edit`, reread the server's `GuestCommands.ts`. +76. A guest who holds Collaborate uses the web client ([#533](https://github.com/Jacksondr5/j5code/issues/533), register D33; Jackson approved every upstream edit here, 2026-10-13). The level controls, the "Let … collaborate?" dialog and every decision are J5-owned files under `apps/web/src/j5/sharing/` (`PromoteDialog.tsx`, `guestComposer.ts`, `sharedConversation.ts` and their `.logic.ts`). The Share dialog's Collaborate line says "Also send messages to the agent and answer its prompts."; the design's line also promised the in-app browser, which is not open to a guest. Upstream's files gain calls into those. `apps/web/src/components/ChatView.tsx`: one more import, and the condition that draws Stop reads `useMayInterruptThread(environmentId, canOperateThread)` in place of `canOperateThread` (false for a guest, upstream's answer otherwise). A guest's edit of a queued message goes as upstream builds it, context included: the server takes composer context from a guest and refuses only attachments. `apps/web/src/components/chat/ChatComposer.tsx`: one import and one hook call, `useGuestComposer(environmentId)`, beside case 73's; its answers on three lines: `if (guestComposer.refusesFiles()) return false;` at the top of `addComposerAttachments` (paste and drop; the attach control itself is already absent for a guest, whose server reports no file uploads, but upstream accepts a pasted image whatever the server says), `guestComposer.followUpBehavior(settings.followUpBehavior)` where the send button is told how a follow-up goes, and `guestComposer.approvalOptions(activePendingApproval.options)` where an approval is given its answers (a guest gets accept, decline and cancel). `apps/web/src/components/chat/QueuedRunsControl.tsx`: one import, the built list renamed `queuedItems` and passed through `useSharedQueue(…)`, which returns each item with `text` as the words its author typed (what the editor is handed and what is sent back), `preview` as what the line shows (a name first on someone else's), and `mayChange` / `maySteer`; the line that builds the preview reads `item.preview`, and those two and `mayReorder` join four conditions (reorder, Edit, Steer, Remove). `apps/web/src/components/chat/ComposerPendingUserInputPanel.tsx`: Dismiss's `disabled={isResponding}` becomes `disabled={isResponding || disabled}` and its click and key handlers call `onDismiss` only `if (!disabled)` (three lines), since it ignored the panel's own `disabled` and is drawn as a `span`, which a `disabled` attribute does not stop (it reads as a small upstream bug: a connection that cannot answer was offered a Dismiss the server refuses). `apps/web/src/components/chat/MessagesTimeline.tsx`: one import and two lines at the top of `RevertUserMessageButton` (`if (useIsGuest(ctx.threadRef?.environmentId ?? null)) return null;`), so a guest's own message does not offer "Edit from here", which rewinds the thread and which the server refuses from a guest (the build lead, under Jackson's 2026-10-13 standing permission). The @ / $ / slash menu is upstream's for a guest too; what it lists is what a guest's connection can read (other threads shared with them; no files and no skills). Not edited, and so still offered to a guest and dropped or refused by the server: the model, effort and access pickers, dragging a file onto the composer, the queue's two keyboard shortcuts, and Stop for background work. A guest's client still sends upstream's `thread.visit` when a message arrives and is refused; nothing shows. On a pin advance: if upstream moves any of these conditions, re-apply the J5 answer beside it and check a guest's composer and queue in a browser, since nothing fails to compile when a call is lost except the renamed constant (`queuedItems`); if upstream starts sending anything else with `message.dispatch` or `queued-run.edit`, reread the server's `GuestCommands.ts`. ## Pin and upstream advance runbook diff --git a/docs/j5/product/upstream.md b/docs/j5/product/upstream.md index ee519786003cb..2cb2a76f6d431 100644 --- a/docs/j5/product/upstream.md +++ b/docs/j5/product/upstream.md @@ -536,4 +536,4 @@ J5 kept a run from resuming after a usage-limit reset when the person had presse - 2026-10-13 — D33: a guest's message carries composer context, with no attachments yet ([#597](https://github.com/Jacksondr5/j5code/issues/597)); the agent is not told who answered an approval; a thread grant writes to the one agent it names and reads those beneath it ([#534](https://github.com/Jacksondr5/j5code/issues/534)); both `ws.ts` wraps approved (Jackson; [#533](https://github.com/Jacksondr5/j5code/issues/533)). - 2026-10-13 — D33: a person's reply from the inbox names them, and says where they stand in a shared conversation (Jackson; [#533](https://github.com/Jacksondr5/j5code/issues/533)). - 2026-10-13 — D33: upstream's launch request is taken in as a message is, so a thread started in a shared project is a shared conversation from its first message; the second `ws.ts` wrap approved (Jackson; [#533](https://github.com/Jacksondr5/j5code/issues/533)). -- 2026-10-13 — D33: a Collaborate guest's composer, queue and approval answers in the web client; draft, each upstream edit awaiting approval (the build lead for Jackson; [#533](https://github.com/Jacksondr5/j5code/issues/533)). +- 2026-10-13 — D33: a Collaborate guest's composer, queue and approval answers in the web client; the upstream edits approved (Jackson; [#533](https://github.com/Jacksondr5/j5code/issues/533)).