diff --git a/FORK.md b/FORK.md index fe63bbc79d4d7..46eb57d51f2c3 100644 --- a/FORK.md +++ b/FORK.md @@ -500,7 +500,7 @@ migrations after upstream migrations. 93. `vp run check:changed` compares against J5's trunk ([#701](https://github.com/Jacksondr5/j5code/issues/701)). Upstream's `scripts/check-changed.ts` defaults its base ref to `origin/main`, which a J5 clone does not have, so a bare run stopped with "no merge base". The default is `origin/j5/main` (the `ref` line and the usage comment above it); a ref passed on the command line still wins. Upstream's `docs/operations/development.md` keeps its `origin/main` wording, as J5 does not edit upstream's docs. On every rebase, keep the default when upstream rewrites the script. -94. Cmd+K names who wrote a person's message it found ([#809](https://github.com/Jacksondr5/j5code/issues/809)). Upstream labels every user-role hit "You:", which is wrong for anyone else's words in a shared conversation. Upstream's `OrchestrationThreadSearchMatch` (`packages/contracts/src/threadSearch.ts`) gains an optional `author`, J5's `ThreadSearchAuthor` (`you`, or `person` with the name they wrote under). The server fills it in J5-owned code: `connectionView` (case 69) labels each search's matches through `apps/server/src/j5/sharing/searchAuthors.ts`, by the message's `j5_a2a_message_author` record (case 80), or as the first owner's when a person typed it before the thread was shared. ws.ts is unchanged. On the web, `ThreadSearchMatchExcerpt` (`apps/web/src/components/ThreadSearchMatch.tsx`) draws `threadSearchMatchLabel` (`apps/web/src/j5/sharing/searchAuthorLabel.ts`) in place of its "You"/"Agent" choice, and the author is passed through `CommandPaletteThreadContentMatch` (`CommandPalette.logic.ts`), `CommandPaletteThreadItems.tsx` and the sidebar's `SidebarThreadRow.tsx`. A match without `author`, from an older server or any message no person typed, keeps upstream's label. Mobile's palette still says "You". On every rebase, keep the field on the match and the one-line label call. +94. Cmd+K names who wrote a person's message it found ([#809](https://github.com/Jacksondr5/j5code/issues/809)). Upstream labels every user-role hit "You:", which is wrong for anyone else's words in a shared conversation. Upstream's `OrchestrationThreadSearchMatch` (`packages/contracts/src/threadSearch.ts`) gains an optional `author`, J5's `ThreadSearchAuthor` (`you`, or `person` with the name they wrote under). The server fills it in J5-owned code: `connectionView` (case 69) labels each search's matches through `apps/server/src/j5/sharing/searchAuthors.ts`, by the message's `j5_a2a_message_author` record (case 80), or as the first owner's when a person wrote it while the first owner was the only person who could write there, typed or as an Inbox reply (`typedByFirstOwner` in `messageStamps.ts`, which case 80's `listThreadAuthors` uses too, so the timeline agrees). ws.ts is unchanged. On the web, `ThreadSearchMatchExcerpt` (`apps/web/src/components/ThreadSearchMatch.tsx`) draws `threadSearchMatchLabel` (`apps/web/src/j5/sharing/searchAuthorLabel.ts`) in place of its "You"/"Agent" choice, and the author is passed through `CommandPaletteThreadContentMatch` (`CommandPalette.logic.ts`), `CommandPaletteThreadItems.tsx` and the sidebar's `SidebarThreadRow.tsx`. A match without `author`, from an older server or any message no person typed, keeps upstream's label. Mobile's palette still says "You". On every rebase, keep the field on the match and the one-line label call. ## Pin and upstream advance runbook diff --git a/apps/server/src/j5/sharing/SharedConversation.test.ts b/apps/server/src/j5/sharing/SharedConversation.test.ts index 50aafb5224589..0e397129df084 100644 --- a/apps/server/src/j5/sharing/SharedConversation.test.ts +++ b/apps/server/src/j5/sharing/SharedConversation.test.ts @@ -10,12 +10,15 @@ import { type ThreadId, } from "@t3tools/contracts"; import type { PersonLevel, PersonScope } from "@t3tools/contracts/j5"; +import * as Clock from "effect/Clock"; +import * as DateTime from "effect/DateTime"; import * as Deferred from "effect/Deferred"; import * as Effect from "effect/Effect"; import * as Fiber from "effect/Fiber"; import * as Ref from "effect/Ref"; import * as Stream from "effect/Stream"; import * as SqlClient from "effect/sql/SqlClient"; +import * as TestClock from "effect/testing/TestClock"; import type { ParticipantId } from "../a2a/contracts.ts"; import { Access } from "./Access.ts"; @@ -35,11 +38,15 @@ const jackson = Effect.gen(function* () { return owner.personId; }); -/** A person given levels the way an Owner gives them: through the access core. */ +/** Past `AT`, when a thread is shared after the messages these tests write at `AT`. */ +const AFTER = Date.parse(AT) + 60_000; + +/** A person given levels the way an Owner gives them: through the access core, after `AT`. */ const personWith = Effect.fn("test.personWith")(function* ( name: string, levels: ReadonlyArray<{ readonly scope: PersonScope; readonly level: PersonLevel }>, ) { + if ((yield* Clock.currentTimeMillis) < AFTER) yield* TestClock.setTime(AFTER); const people = yield* PersonAccess; const access = yield* Access; const created = yield* people.createPerson({ displayName: name }); @@ -219,6 +226,8 @@ it.effect( [ { name: "Jackson", level: "owner", you: false, hasNote: true }, { name: "Priya", level: "collaborator", you: true, hasNote: false }, + // The message from before sharing, which no one is recorded for: the first owner's. + { name: "Jackson", level: "owner", you: false, hasNote: false }, ], ); // The prefix a client strips is exactly what the platform put on the stored text. @@ -338,7 +347,8 @@ it.effect("a fork names who wrote the messages it shows, and none after its fork return forked; }); const fork = yield* forkFrom("thread:fork", source, `run:${second.messageId}`); - // The fork's own message, from a thread only one person writes to, names no one. + // The fork's own message, from a thread only one person writes to, is recorded for no one: + // the first owner's, to its forks too. yield* taken(fork, "message:fork-own", "completed"); const forkOfFork = yield* forkFrom("thread:fork-of-fork", fork, "run:message:fork-own"); @@ -346,7 +356,18 @@ it.effect("a fork names who wrote the messages it shows, and none after its fork for (const threadId of [fork, forkOfFork]) { const read = yield* authors(threadId, priya); assert.isFalse(read.shared); - assert.deepStrictEqual(read.authors, sourceRead.authors.slice(0, 2)); + assert.deepStrictEqual(read.authors, [ + ...sourceRead.authors.slice(0, 2), + { + messageId: "message:fork-own", + name: "Jackson", + level: "owner", + editedBy: null, + you: false, + note: null, + storedPrefix: "", + }, + ]); } assert.deepStrictEqual( sourceRead.authors.map((entry) => entry.messageId), @@ -355,6 +376,125 @@ it.effect("a fork names who wrote the messages it shows, and none after its fork }).pipe(Effect.provide(conversationLayer)), ); +/** + * A message upstream holds with no author recorded here, as the origin says, written at + * `createdAt` (`AT` by default) with a completed run. + */ +const unrecorded = Effect.fn("test.unrecorded")(function* ( + threadId: ThreadId, + messageId: string, + origin: Record, + createdAt = AT, +) { + const sql = yield* SqlClient.SqlClient; + yield* taken(threadId, messageId, "completed"); + yield* sql` + UPDATE orchestration_v2_projection_messages + SET created_at = ${createdAt}, payload_json = ${JSON.stringify({ text: messageId, ...origin })} + WHERE message_id = ${messageId} + `; +}); + +const typed = { createdBy: "user", creationSource: "web" }; +/** What upstream writes when a person declines an approval with feedback. */ +const feedback = { createdBy: "user", creationSource: "server" }; +const asOwner = (messageId: string) => ({ + messageId, + name: "Jackson", + level: "owner" as const, + editedBy: null, + you: false, + note: null, + storedPrefix: "", +}); +const iso = (millis: number) => DateTime.formatIso(DateTime.makeUnsafe(millis)); + +it.effect("a message a person wrote before sharing is the first owner's to everyone else", () => + Effect.gen(function* () { + const owner = yield* jackson; + const threadId = yield* thread("thread:before-sharing"); + yield* unrecorded(threadId, "message:typed", typed); + yield* unrecorded(threadId, "message:j5:a2a:delivery:inbox", { + createdBy: "user", + creationSource: "mcp", + }); + // None of these was written by a person. + yield* unrecorded(threadId, "message:j5:a2a:delivery:agent", { + createdBy: "agent", + creationSource: "mcp", + }); + yield* unrecorded(threadId, "message:j5:a2a:delivery:notice", { + createdBy: "system", + creationSource: "mcp", + }); + yield* unrecorded(threadId, "message:session", { createdBy: "user", creationSource: "mcp" }); + yield* unrecorded(threadId, "message:scheduled", { + ...typed, + scheduledTaskId: "task:nightly", + }); + yield* unrecorded(threadId, "message:sent", { ...typed, senderThreadId: "thread:elsewhere" }); + const priya = yield* personWith("Priya", onThread(threadId)); + const sam = yield* personWith("Sam", onThread(threadId, "viewer")); + // Once Priya can write, every person's message is recorded: what is not, the server wrote, + // such as an approval's feedback, from the moment she could on. + yield* unrecorded(threadId, "approval-feedback:at-sharing", feedback, iso(AFTER)); + yield* unrecorded(threadId, "approval-feedback:later", feedback, iso(AFTER + 60_000)); + + for (const reader of [priya, sam]) { + assert.deepStrictEqual((yield* authors(threadId, reader)).authors, [ + asOwner("message:typed"), + asOwner("message:j5:a2a:delivery:inbox"), + ]); + } + // The first owner's own view draws them as theirs already. + assert.deepStrictEqual((yield* authors(threadId, owner)).authors, []); + }).pipe(Effect.provide(conversationLayer)), +); + +it.effect("a thread shared only with Viewers keeps the first owner's later messages theirs", () => + Effect.gen(function* () { + const threadId = yield* thread("thread:viewers-only"); + yield* jackson; + const sam = yield* personWith("Sam", onThread(threadId, "viewer")); + // Sent after Sam could read the thread: a Viewer does not make it shared, so none is recorded. + yield* unrecorded(threadId, "message:while-watched", typed, iso(AFTER + 60_000)); + + const read = yield* authors(threadId, sam); + assert.isFalse(read.shared); + assert.deepStrictEqual(read.authors, [asOwner("message:while-watched")]); + }).pipe(Effect.provide(conversationLayer)), +); + +it.effect("a fork reads each inherited message against its own thread's sharing", () => + Effect.gen(function* () { + const sql = yield* SqlClient.SqlClient; + yield* jackson; + const source = yield* thread("thread:fork-cutoff-source"); + yield* unrecorded(source, "message:source-before", typed); + const priya = yield* personWith("Priya", onThread(source)); + yield* unrecorded(source, "approval-feedback:source", feedback, iso(AFTER + 60_000)); + const fork = yield* thread("thread:fork-cutoff", PROJECT, { + parent: source, + relationship: "fork", + }); + yield* sql` + UPDATE orchestration_v2_projection_threads + SET payload_json = json_set(payload_json, '$.forkedFrom', + json_object('type', 'run', 'threadId', ${source}, 'runId', 'run:approval-feedback:source')) + WHERE thread_id = ${fork} + `; + const sam = yield* personWith("Sam", onThread(fork, "viewer")); + + // The fork is shared with no writer, but the feedback came after its source was shared. + for (const reader of [priya, sam]) { + assert.deepStrictEqual( + (yield* authors(fork, reader)).authors.map((entry) => entry.messageId), + ["message:source-before"], + ); + } + }).pipe(Effect.provide(conversationLayer)), +); + it.effect("a fork tells its reader only what they could know of who wrote before it", () => Effect.gen(function* () { const sql = yield* SqlClient.SqlClient; diff --git a/apps/server/src/j5/sharing/SharedConversation.ts b/apps/server/src/j5/sharing/SharedConversation.ts index 3562b1989edcc..caadcb607901c 100644 --- a/apps/server/src/j5/sharing/SharedConversation.ts +++ b/apps/server/src/j5/sharing/SharedConversation.ts @@ -29,6 +29,7 @@ import * as PubSub from "effect/PubSub"; import * as Schema from "effect/Schema"; import * as Stream from "effect/Stream"; import * as SqlClient from "effect/sql/SqlClient"; +import type * as Statement from "effect/sql/Statement"; import type * as SqlError from "effect/sql/SqlError"; import { ThreadManagementService } from "../../orchestration-v2/ThreadManagementService.ts"; @@ -297,8 +298,8 @@ const make = Effect.gen(function* () { const unrecordedAuthor = Effect.fn("j5.sharing.sharedConversation.unrecordedAuthor")(function* ( messageId: string, ) { - const rows = yield* sql` - SELECT ${sql.literal(messageOriginColumns("message"))} + const rows = yield* sql` + SELECT message.message_id, ${sql.literal(messageOriginColumns("message"))} FROM orchestration_v2_projection_messages AS message WHERE message_id = ${messageId} `; const row = rows[0]; @@ -542,6 +543,57 @@ const make = Effect.gen(function* () { }).pipe(Effect.catch(failClosed)); }); + /** + * A thread's messages, its own and those a fork shows, that no person is recorded for but a + * person wrote: the first owner's, as search names them (`typedByFirstOwner`). Their own view + * draws them as theirs already, so they are read only for anyone else. + */ + const firstOwnersUnrecorded = Effect.fn("j5.sharing.sharedConversation.firstOwnersUnrecorded")( + function* ( + viewer: ParticipantId | null, + threadId: ThreadId, + forkSources: Statement.Fragment, + mayKnow: (personId: string) => Effect.Effect, + ) { + const owner = yield* people.firstOwner; + if (owner.personId === viewer) return []; + const rows = yield* sql` + ${forkSources} + SELECT message.message_id, ${sql.literal(messageOriginColumns("message"))} + FROM orchestration_v2_projection_messages AS message + WHERE message.thread_id = ${threadId} AND message.role = 'user' + AND NOT EXISTS ( + SELECT 1 FROM j5_a2a_message_author AS author + WHERE author.thread_id = message.thread_id AND author.message_id = message.message_id + ) + UNION ALL + SELECT message.message_id, ${sql.literal(messageOriginColumns("message"))} + FROM source + JOIN orchestration_v2_projection_runs AS forked_at ON forked_at.run_id = source.run_id + JOIN orchestration_v2_projection_messages AS message + ON message.thread_id = source.thread_id AND message.role = 'user' + JOIN orchestration_v2_projection_runs AS run + ON run.run_id = message.run_id AND run.ordinal <= forked_at.ordinal + WHERE NOT EXISTS ( + SELECT 1 FROM j5_a2a_message_author AS author + WHERE author.thread_id = message.thread_id AND author.message_id = message.message_id + ) + `; + const written = rows.filter(typedByFirstOwner); + if (written.length === 0) return []; + const name = (yield* mayKnow(owner.personId)) ? owner.displayName : null; + return written.map((row): MessageAuthor => ({ + messageId: row.message_id, + name, + level: "owner", + editedBy: null, + you: false, + note: null, + storedPrefix: "", + })); + }, + ); + const threadAuthors: SharedConversationShape["threadAuthors"] = Effect.fn( "j5.sharing.sharedConversation.threadAuthors", )(function* (viewer, threadId) { @@ -552,9 +604,7 @@ const make = Effect.gen(function* () { // upstream's `buildVisibleTurnItems` does; those keep their authors, and nothing past the fork // point is named. A reader need not reach the source, so an inherited record applies only where // the shown text begins with its prefix, restating what they already receive. - const authors = yield* sql< - AuthorRow & { readonly created_at: string; readonly inherited: 0 | 1 } - >` + const forkSources = sql` WITH RECURSIVE source (thread_id, run_id) AS ( SELECT json_extract(payload_json, '$.forkedFrom.threadId'), json_extract(payload_json, '$.forkedFrom.runId') @@ -567,6 +617,11 @@ const make = Effect.gen(function* () { JOIN orchestration_v2_projection_threads AS thread ON thread.thread_id = source.thread_id WHERE json_extract(thread.payload_json, '$.forkedFrom.type') = 'run' ) + `; + const authors = yield* sql< + AuthorRow & { readonly created_at: string; readonly inherited: 0 | 1 } + >` + ${forkSources} SELECT message_id, person_id, display_name, level, edited_by, note, told_json, stored_prefix, created_at, 0 AS inherited FROM j5_a2a_message_author @@ -618,6 +673,7 @@ const make = Effect.gen(function* () { known.set(personId, visible); return visible; }); + const unrecorded = yield* firstOwnersUnrecorded(viewer, threadId, forkSources, mayKnow); const told = yield* Effect.forEach(authors, (row) => Effect.gen(function* () { const author: MessageAuthor = { @@ -635,7 +691,7 @@ const make = Effect.gen(function* () { ); return { shared: recorded.length > 0, - authors: told, + authors: [...told, ...unrecorded], answers: answers.map((row): PromptAnswer => ({ requestId: row.request_id, name: row.display_name, diff --git a/apps/server/src/j5/sharing/messageSearch.test.ts b/apps/server/src/j5/sharing/messageSearch.test.ts index 7b7ec07b126f1..d5e606ecff2a1 100644 --- a/apps/server/src/j5/sharing/messageSearch.test.ts +++ b/apps/server/src/j5/sharing/messageSearch.test.ts @@ -100,6 +100,7 @@ const message = ( id: string, text: string, minute = 1, + origin: Partial["payload"]> = {}, ): OrchestrationV2DomainEvent => ({ id: EventId.make(`message:${id}`), type: "message.updated", @@ -119,6 +120,7 @@ const message = ( streaming: false, createdAt: at(minute), updatedAt: at(minute), + ...origin, }, }); @@ -346,4 +348,54 @@ it.layer(layer)("Who wrote a message search hit", (it) => { assert.deepEqual(yield* authors(viewer, "before"), [{ _tag: "person", name: "Morgan" }]); }), ); + + it.effect("names an Inbox reply from before sharing as the first owner's", () => + Effect.gen(function* () { + const sql = yield* SqlClient.SqlClient; + const conversation = ThreadId.make("thread:search-inbox-reply"); + const mcp = { createdBy: "user", creationSource: "mcp" } as const; + yield* seed([ + thread(conversation, PRIVATE), + message(conversation, "message:j5:a2a:delivery:reply", "plover inbox", 1, mcp), + message(conversation, "service-send", "plover service", 4, mcp), + message(conversation, "scheduled-run", "plover scheduled", 5, { + creationSource: "server", + scheduledTaskId: "task:plover" as never, + }), + message(conversation, "thread-send", "plover thread", 6, { + senderThreadId: ThreadId.make("thread:plover-sender"), + }), + // An approval's feedback, written by the server after a second person could write. + message(conversation, "approval-feedback:plover", "plover feedback", 8, { + creationSource: "server", + }), + ]); + yield* sql` + INSERT INTO j5_a2a_shared_thread (thread_id, shared_at) + VALUES (${conversation}, ${DateTime.formatIso(at(7))}) + `; + yield* sql` + UPDATE j5_a2a_human_person SET display_name = 'Morgan' WHERE is_local_operator = 1 + `; + const collaborator = yield* deviceOf("Rowan", [ + { scope: { kind: "thread", threadId: conversation }, level: "collaborator" }, + ]); + // Search shows one hit a thread, so each message has a word of its own. + const label = Effect.fn("test.label")(function* ( + session: Parameters[0], + word: string, + ) { + const { matches } = yield* searchAs(session, { query: word }); + assert.lengthOf(matches, 1, word); + return matches[0]!.author ?? null; + }); + + assert.deepEqual(yield* label(collaborator, "inbox"), { _tag: "person", name: "Morgan" }); + assert.deepEqual(yield* label(OWNER, "inbox"), { _tag: "you" }); + // No other message search finds here was written by a person: each keeps upstream's label. + for (const word of ["service", "scheduled", "thread", "feedback"]) { + assert.strictEqual(yield* label(collaborator, word), null, word); + } + }), + ); }); diff --git a/apps/server/src/j5/sharing/messageStamps.ts b/apps/server/src/j5/sharing/messageStamps.ts index 8be66df9ac413..c6afc87c5e96d 100644 --- a/apps/server/src/j5/sharing/messageStamps.ts +++ b/apps/server/src/j5/sharing/messageStamps.ts @@ -14,6 +14,7 @@ import * as Schema from "effect/Schema"; import * as SqlClient from "effect/sql/SqlClient"; import type { ParticipantId } from "../a2a/contracts.ts"; +import { isDeliveryMessageId } from "../a2a/DeliveryTransport.ts"; import { authorLabel } from "./authorLabel.ts"; import { PersonAccess } from "./PersonAccess.ts"; import { SharedThreads, type ThreadWriter } from "./SharedThreads.ts"; @@ -39,6 +40,9 @@ export interface MessageOrigin { readonly creation_source: string | null; readonly scheduled_task_id: string | null; readonly sender_thread_id: string | null; + readonly created_at: string; + /** When a second person could first write to the message's thread; `null` while none can. */ + readonly shared_at: string | null; } /** `MessageOrigin`'s columns, read from `orchestration_v2_projection_messages` as `alias`. */ @@ -46,19 +50,24 @@ export const messageOriginColumns = (alias: string) => ` json_extract(${alias}.payload_json, '$.createdBy') AS created_by, json_extract(${alias}.payload_json, '$.creationSource') AS creation_source, json_extract(${alias}.payload_json, '$.scheduledTaskId') AS scheduled_task_id, - json_extract(${alias}.payload_json, '$.senderThreadId') AS sender_thread_id + json_extract(${alias}.payload_json, '$.senderThreadId') AS sender_thread_id, + ${alias}.created_at AS created_at, + (SELECT shared.shared_at FROM j5_a2a_shared_thread AS shared + WHERE shared.thread_id = ${alias}.thread_id) AS shared_at `; /** - * Whether a message no person is recorded for was typed by one, before its thread was shared: the - * first owner's then, the only person who could write to it (AC3). An inbox reply is a person's - * too, but comes as a delivery ("mcp") and carries its header. + * Whether a message no person is recorded for was written by one while the first owner was the + * only person who could write to its thread, so was theirs (AC3, AC16): one typed in the thread, + * or an Inbox reply, the only delivery a person sends. Any other "mcp" message is an agent's or a + * session's; one from after a second writer came is the server's, as every person's is recorded. */ -export const typedByFirstOwner = (origin: MessageOrigin) => - origin.created_by === "user" && - origin.creation_source !== "mcp" && - origin.scheduled_task_id === null && - origin.sender_thread_id === null; +export const typedByFirstOwner = (message: MessageOrigin & { readonly message_id: string }) => + message.created_by === "user" && + (message.creation_source !== "mcp" || isDeliveryMessageId(message.message_id)) && + message.scheduled_task_id === null && + message.sender_thread_id === null && + (message.shared_at === null || message.created_at < message.shared_at); /** The platform's text a stored message begins with: the note it carries, then the line naming * whose it is. */ diff --git a/apps/web/src/j5/sharing/sharedTimeline.logic.ts b/apps/web/src/j5/sharing/sharedTimeline.logic.ts index e5319fd2ae14d..a0eb571d778b7 100644 --- a/apps/web/src/j5/sharing/sharedTimeline.logic.ts +++ b/apps/web/src/j5/sharing/sharedTimeline.logic.ts @@ -37,7 +37,10 @@ export function sharedMessageView(input: { readonly author: MessageAuthor | undefined; /** A read of who wrote what has come back since this client first saw the server's copy. */ readonly answeredFor: boolean; - /** The thread can be a shared conversation: more than one person can write to it, or did. */ + /** + * A read may name who wrote a message: more than one person can write to the thread, or did, + * or the reader is not the first owner. + */ readonly mayBeShared: boolean; /** What this client's person typed, when they sent it from here. */ readonly typedHere: string | null; diff --git a/apps/web/src/j5/sharing/sharedTimeline.ts b/apps/web/src/j5/sharing/sharedTimeline.ts index de84c19242d8e..66e20285e7c46 100644 --- a/apps/web/src/j5/sharing/sharedTimeline.ts +++ b/apps/web/src/j5/sharing/sharedTimeline.ts @@ -173,12 +173,15 @@ export function useSharedConversationEntries( threadRef === null ? null : { kind: "thread" as const, threadId: threadRef.threadId }; // The header's pill already reads who reaches the thread; this is the same read. const people = useScopePeople(threadRef?.environmentId ?? null, threadScope); - const writers = (people.data?.people ?? []).filter((person) => - levelReaches(person.level, "collaborator"), - ).length; + const reaching = people.data?.people ?? []; + const writers = reaching.filter((person) => levelReaches(person.level, "collaborator")).length; + // To anyone but the first owner, a message no one is recorded for may be the first owner's, + // which the next read says; their own view draws it as theirs. + const readsOthers = reaching.length > 1 && !reaching.some((p) => p.you && p.firstOwner); // Until the first read answers or fails, any thread may be shared, so nothing is drawn plain // that may carry lines for the agent. - const mayBeShared = record?.shared === true || writers > 1 || (record === null && !failed); + const mayBeShared = + record?.shared === true || writers > 1 || readsOthers || (record === null && !failed); const [stored, setStored] = useState(noneSeen); const seen = observeMessages(stored, entries); diff --git a/docs/j5/product/features/shared-conversations.md b/docs/j5/product/features/shared-conversations.md index 907526a44664d..6fe254a6963e6 100644 --- a/docs/j5/product/features/shared-conversations.md +++ b/docs/j5/product/features/shared-conversations.md @@ -75,7 +75,7 @@ Set aside on purpose, each tracked where it is linked. An item leaves this list ### Reading -16. A person's own messages render as they do in a thread that is not shared; another person's message, a command included, renders in the same bubble on the left, with that person's name above it and initials on a coloured circle beside it, and no level. +16. A person's own messages render as they do in a thread that is not shared; another person's message, a command included, renders in the same bubble on the left, with that person's name above it and initials on a coloured circle beside it, and no level. A message a person wrote while the first Owner was the only person who could write to the thread, typed in it or sent as an Inbox reply, is the first Owner's, and renders so to everyone else. ### History @@ -94,7 +94,7 @@ Set aside on purpose, each tracked where it is linked. An item leaves this list 21. Cmd+K's message search, for a person a thread or project is shared with or a Viewer of the server, finds messages only in threads they can open, at either level. It returns no thread, snippet or count from any other thread, and other threads' matches never take the places of theirs, apart from upstream's limit of the newest 10,000 matches of a word across the server, which applies to an Owner too. 22. Opening a thread, from Cmd+K or elsewhere, changes the record that ranks threads in Cmd+K only for an Owner or a Collaborator at server scope. That record is not shown to anyone else, and does not order their results. -23. A Cmd+K match in a person's message reads "You" only in the reader's own message, and otherwise names the person who wrote it as the conversation names them, a message from before the thread was shared being the first Owner's. +23. A Cmd+K match in a person's message reads "You" only in the reader's own message, and otherwise names the person who wrote it as the conversation names them (AC16). ## Scenarios @@ -128,3 +128,4 @@ Set aside on purpose, each tracked where it is linked. An item leaves this list - 2026-10-19 — a scheduled task's run names who wrote its prompt, and fails, not sent, while they can no longer write to the thread; the task is not paused, since that would change upstream's scheduler (AC20, AC3; Jackson, in the review of [#638](https://github.com/Jacksondr5/j5code/pull/638)). - 2026-10-31 — AC21, AC22: people a thread or project is shared with search its messages, held to what they can open before the results are cut, and their opens don't rank anyone's Cmd+K (Jackson's decision on [#696](https://github.com/Jacksondr5/j5code/issues/696)). - 2026-10-31 — AC23: a Cmd+K match in another person's message names them instead of reading "You" ([#809](https://github.com/Jacksondr5/j5code/issues/809)). +- 2026-10-31 — AC16, AC23: a message from while the first Owner was the only person who could write, an Inbox reply included, is the first Owner's in the timeline and in Cmd+K alike ([#817](https://github.com/Jacksondr5/j5code/issues/817), [#818](https://github.com/Jacksondr5/j5code/issues/818)).