diff --git a/apps/mobile/src/Stack.tsx b/apps/mobile/src/Stack.tsx index 7a9a806f54f19..b9281945f11f6 100644 --- a/apps/mobile/src/Stack.tsx +++ b/apps/mobile/src/Stack.tsx @@ -69,6 +69,7 @@ import { GitConfirmSheet } from "./features/threads/git/GitConfirmSheet"; import { GitOverviewSheet } from "./features/threads/git/GitOverviewSheet"; import { ThreadPullRequestsSheet } from "./features/threads/ThreadPullRequestsSheet"; import { ThreadAgentsSheet } from "./features/threads/ThreadAgentsSheet"; +import { LinkedThreadSheet } from "./features/threads/LinkedThreadSheet"; import { ThreadGuestShareSheet } from "./features/threads/ThreadGuestShareSheet"; import { ThreadBackgroundWorkSheet } from "./features/threads/ThreadBackgroundWorkSheet"; import { ThreadQueueSheet } from "./features/threads/ThreadQueueControl"; @@ -784,6 +785,10 @@ const RootStackConfig = createWorkspaceStackNavigator({ screen: ThreadAgentsSheet, options: sheetRoute({ detent: 0.5, androidMaxDetent: 0.9 }), }), + LinkedThread: createNativeStackScreen({ + screen: LinkedThreadSheet, + options: sheetRoute({ detent: 0.9, android: "fullScreen" }), + }), ThreadGuestShare: createNativeStackScreen({ screen: ThreadGuestShareSheet, options: sheetRoute({ detent: 0.5 }), diff --git a/apps/mobile/src/components/ComposerEditor.ios.test.tsx b/apps/mobile/src/components/ComposerEditor.ios.test.tsx index aa391b3c03bf3..0a8f515787fce 100644 --- a/apps/mobile/src/components/ComposerEditor.ios.test.tsx +++ b/apps/mobile/src/components/ComposerEditor.ios.test.tsx @@ -117,7 +117,7 @@ vi.mock("./ui/Dialog", () => ({ alert: vi.fn() })); vi.mock("./ui/AppText", () => ({ AppText: ({ children }: { children?: ReactNode }) => children })); vi.mock("./ComposerContextSheet", () => ({ ComposerContextSheet: () => null })); vi.mock("./AssistantCitationSheet", () => ({ AssistantCitationSheet: () => null })); -vi.mock("../features/threads/useOpenLinkedThread", () => ({ useOpenLinkedThread: () => vi.fn() })); +vi.mock("../features/threads/useOpenThreadLink", () => ({ useOpenThreadLink: () => vi.fn() })); vi.mock("../state/peerLinks", () => ({ useLinkedEnvironments: () => [] })); vi.mock("../state/model-mentions", () => ({ useModelMentions: () => [] })); vi.mock("../state/preferences", async () => { diff --git a/apps/mobile/src/components/ComposerEditor.tsx b/apps/mobile/src/components/ComposerEditor.tsx index 8d3805234696b..39e12816cdf61 100644 --- a/apps/mobile/src/components/ComposerEditor.tsx +++ b/apps/mobile/src/components/ComposerEditor.tsx @@ -37,7 +37,7 @@ import { appAtomRegistry } from "../state/atom-registry"; import { enrichedModelDetails, enrichedModelReference } from "../lib/enrichedLinkPresentation"; import { useModelMentions } from "../state/model-mentions"; import { mobilePreferencesAtom } from "../state/preferences"; -import { useOpenLinkedThread } from "../features/threads/useOpenLinkedThread"; +import { useOpenThreadLink } from "../features/threads/useOpenThreadLink"; import { useLinkedEnvironments } from "../state/peerLinks"; import { ComposerContextSheet } from "./ComposerContextSheet"; import { AppText as Text } from "./ui/AppText"; @@ -186,7 +186,7 @@ export function ComposerEditor({ }), }) : ""; - const openLinkedThread = useOpenLinkedThread(); + const openThreadLink = useOpenThreadLink(environmentId ?? null); const selectedReference = selected ? collectComposerContextReferences(selected.source)[0] : undefined; @@ -338,10 +338,7 @@ export function ComposerEditor({ : {})} onOpenThread={(thread) => { setSelected(null); - openLinkedThread({ - environmentId: String(thread.environmentId), - threadId: String(thread.threadId), - }); + openThreadLink(thread); }} environmentId={environmentId ?? draft.project?.environmentId} projectId={draft.project?.projectId} diff --git a/apps/mobile/src/features/threads/LinkedThreadSheet.tsx b/apps/mobile/src/features/threads/LinkedThreadSheet.tsx new file mode 100644 index 0000000000000..9cbc930548464 --- /dev/null +++ b/apps/mobile/src/features/threads/LinkedThreadSheet.tsx @@ -0,0 +1,383 @@ +import { useIsFocused, useNavigation, type StaticScreenProps } from "@react-navigation/native"; +import { + isLinkedThreadWorking, + linkedThreadFailure, + type LinkedThreadFailure, + type LinkedThreadTarget, +} from "@t3tools/client-runtime/linked-thread"; +import { + toolCallLines, + turnItemDetailRevision, + turnItemOutputText, +} from "@t3tools/client-runtime/work-log/item-detail"; +import { EnvironmentId, ThreadId } from "@t3tools/contracts"; +import { T, useGT, useLocale, useMessages } from "gt-react-native"; +import { useRef, useState, useSyncExternalStore } from "react"; +import type * as React from "react"; +import { AppState, Pressable, ScrollView, View } from "react-native"; +import { useSafeAreaInsets } from "react-native-safe-area-context"; + +import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator"; +import { AppText as Text } from "../../components/ui/AppText"; +import { Button } from "../../components/ui/Button"; +import { ScreenContent } from "../../components/ui/ScreenContent"; +import { SheetHeader } from "../../components/ui/SheetHeader"; +import { SelectableMarkdownText } from "../../native/SelectableMarkdownText"; +import { useEnvironments } from "../../state/environments"; +import { + buildThreadFeed, + createThreadFeedCache, + formatItemFullDetail, + type ThreadFeedActivity, + type ThreadFeedEntry, +} from "../../lib/threadActivity"; +import { useLinkedThreadView } from "../../state/linkedThread"; +import { peerLinkEnvironment } from "../../state/peerLinks"; +import { useEnvironmentQuery } from "../../state/query"; +import { useMarkdownPreviewStyles } from "../files/FileMarkdownPreview"; +import { ReadOnlyComposerBar } from "./ReadOnlyComposerBar"; + +type LinkedThreadRouteParams = { + readonly viaEnvironmentId: string; + readonly environmentId: string; + readonly threadId: string; + readonly label: string; + readonly title?: string; +}; + +/** The route params that open a linked environment's thread read-only. */ +export const linkedThreadRouteParams = ( + thread: { readonly environmentId: EnvironmentId; readonly threadId: ThreadId }, + linked: { readonly viaEnvironmentId: EnvironmentId; readonly label: string }, + title: string | null, +): LinkedThreadRouteParams => ({ + viaEnvironmentId: linked.viaEnvironmentId, + environmentId: thread.environmentId, + threadId: thread.threadId, + label: linked.label, + ...(title === null ? {} : { title }), +}); + +function ActivityRow(props: { + readonly activity: ThreadFeedActivity; + readonly target: LinkedThreadTarget; +}) { + const { activity, target } = props; + const gt = useGT(); + const [open, setOpen] = useState(false); + const row = activity.projectedItem; + // The stream leaves long output out; an open row reads its item in full through the link. + const fetched = useEnvironmentQuery( + open && activity.fetchesDetail + ? peerLinkEnvironment.threadItem({ + environmentId: target.viaEnvironmentId, + input: { + environmentId: target.environmentId, + threadId: row.sourceThreadId, + itemId: row.sourceItemId, + revision: turnItemDetailRevision(row.item), + }, + }) + : null, + ); + const fetchedItem = fetched.data?.item ?? null; + const shownItem = fetchedItem ?? row.item; + // A command or tool call reads as what was called, as on the thread screen; only an item with + // no call to show falls back to its full detail. + const call = !open + ? null + : shownItem.type === "command_execution" + ? toolCallLines({ command: shownItem.input }) + : shownItem.type === "dynamic_tool" + ? toolCallLines({ args: shownItem.input }) + : null; + const callText = call + ? (call.command ?? + call.args?.map(([key, value]) => `${key}: ${value}`).join("\n") ?? + call.argsText) + : null; + const body = !open + ? null + : call + ? callText + : fetchedItem + ? formatItemFullDetail(row, fetchedItem) + : (activity.getFullDetail() ?? activity.detail); + const output = !open + ? null + : !activity.fetchesDetail + ? turnItemOutputText(row.item) + : fetchedItem + ? (turnItemOutputText(fetchedItem) ?? gt("No output.")) + : fetched.error + ? gt("Couldn't load output: {error}", { error: fetched.error }) + : fetched.data + ? gt("Output is no longer available.") + : gt("Loading output…"); + return ( + setOpen(!open)} + className="active:opacity-70" + > + + {activity.summary} + + {body ? ( + + + {body} + + + ) : null} + {output ? ( + + + {output} + + + ) : null} + {open && fetched.error ? ( + + + + ) : null; + // A file or visual lives on the linked environment, which this client has no way to ask. + const renderHtmlRender = useStableCallback(() => ( +

+ {gt("Open this thread on {label} to see this visual.", { label })} +

+ )); + const working = projection !== null && isLinkedThreadWorking(projection); + const historyControls: MessagesTimelineHistoryControls | undefined = + view === null || view.thread.historyCursor === null + ? undefined + : { + hasMoreHistory: true, + loading: view.history.loading, + error: view.history.failed ? gt("Could not load earlier turns. Try again.") : null, + onLoadEarlier: view.loadEarlier, + }; + return ( +
+

+ {linkedThreadTitle( + { title: projection?.thread.title || surface.title }, + gt("Thread on {label}", { label }), + )} +

+ {projection === null ? ( + <> +
+ {failure === null ? ( +
+ + + Reading from {label}… + +
+ ) : ( + + {failure.title} + {failure.detail} + {retryAction} + + )} +
+ + + ) : ( + + {() => ( + <> + {failure === null ? null : ( +
+ + {failure.title} + + {failure.detail} Showing what was read before. + + {retryAction} + +
+ )} + + + )} +
+ )} +
+ ); +} diff --git a/apps/web/src/components/chat/MarkdownThreadLink.browser.test.tsx b/apps/web/src/components/chat/MarkdownThreadLink.browser.test.tsx index 80e8cdf0dbd76..4455c29c7ea1e 100644 --- a/apps/web/src/components/chat/MarkdownThreadLink.browser.test.tsx +++ b/apps/web/src/components/chat/MarkdownThreadLink.browser.test.tsx @@ -1,19 +1,32 @@ import { RegistryContext } from "@effect/atom-react"; +import { scopeThreadRef } from "@t3tools/client-runtime/environment"; import { EnvironmentId, ProjectId, ThreadId } from "@t3tools/contracts"; import * as Cause from "effect/Cause"; import { AsyncResult, Atom, AtomRegistry } from "effect/reactivity"; import { expect, it, vi } from "vite-plus/test"; import { act, render } from "../../../test/render"; +import { linkedThreadSurface } from "../../linkedThreadSurface"; +import { selectThreadRightPanelState, useRightPanelStore } from "../../rightPanelStore"; import { MarkdownThreadLink } from "./MarkdownThreadLink"; +const HERE = scopeThreadRef(EnvironmentId.make("environment"), ThreadId.make("here")); +const panel = () => selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, HERE); + const state = vi.hoisted(() => ({ reply: null as unknown, remote: null as unknown, + cached: null as unknown, + linked: new Map(), + connected: [] as Array, })); vi.mock(import("../../state/entities"), () => ({ useThreadShell: ((ref: { environmentId: string } | null) => - ref?.environmentId === "remote" ? state.remote : null) as never, + ref?.environmentId === "remote" + ? state.remote + : ref?.environmentId === "saved-vm" + ? state.cached + : null) as never, useThreadRefs: (enabled = true) => enabled ? [{ environmentId: EnvironmentId.make("remote"), threadId: ThreadId.make("older-thread") }] @@ -25,7 +38,13 @@ vi.mock(import("../../state/environments"), () => ({ useEnvironmentIdentities: () => [ { environmentId: EnvironmentId.make("environment"), label: "Here" }, { environmentId: EnvironmentId.make("remote"), label: "Remote" }, + { environmentId: EnvironmentId.make("saved-vm"), label: "Saved VM" }, ], + useConnectedEnvironmentIds: () => state.connected as never, +})); +vi.mock(import("../../state/peerLinks"), () => ({ + useLinkedEnvironments: ((environmentId: string | null) => + environmentId === null ? new Map() : state.linked) as never, })); vi.mock(import("../ProjectFavicon"), () => ({ ProjectFavicon: () => ( @@ -46,6 +65,10 @@ function setup() { AsyncResult.AsyncResult, string> >(AsyncResult.initial()); state.reply = reply; + state.linked = new Map(); + state.cached = null; + state.connected = ["environment", "remote"]; + useRightPanelStore.setState({ byThreadKey: {} }); state.remote = { environmentId: EnvironmentId.make("remote"), id: ThreadId.make("older-thread"), @@ -161,3 +184,74 @@ it("names a thread on a machine this client has no connection to, without waitin .toBeVisible(); await expect.element(screen.getByRole("link")).not.toBeInTheDocument(); }); + +it.for([ + { name: "a machine only this environment links to", linkedId: "linked-vm" }, + { name: "a saved machine this client is not connected to", linkedId: "saved-vm" }, +])("opens a thread on $name as a read through the link", async ({ linkedId }) => { + const { registry } = setup(); + using _registry = { [Symbol.dispose]: () => registry.dispose() }; + state.linked = new Map([[linkedId, "fs-17"]]); + const environmentId = EnvironmentId.make("environment"); + const link = { environmentId: EnvironmentId.make(linkedId), threadId: ThreadId.make("there") }; + await using screen = await render( + + + , + ); + const chip = screen.getByRole("button", { name: "Thread, Thread on fs-17" }); + await chip.click(); + const surface = linkedThreadSurface({ + viaEnvironmentId: environmentId, + ...link, + label: "fs-17", + title: null, + }); + expect(panel()).toMatchObject({ isOpen: true, activeSurfaceId: surface.id, surfaces: [surface] }); + await chip.click(); + expect(panel().surfaces).toHaveLength(1); + expect(screen.router?.state.location.pathname).toBe("/"); +}); + +it("reads through the link when a disconnected machine's thread is only cached here", async () => { + const { registry } = setup(); + using _registry = { [Symbol.dispose]: () => registry.dispose() }; + state.linked = new Map([["saved-vm", "fs-17"]]); + state.cached = { id: ThreadId.make("there"), title: "Cached title", projectId: null }; + const environmentId = EnvironmentId.make("environment"); + const link = { environmentId: EnvironmentId.make("saved-vm"), threadId: ThreadId.make("there") }; + await using screen = await render( + + + , + ); + await screen.getByRole("button", { name: "Thread, Cached title" }).click(); + expect(panel().surfaces).toEqual([ + linkedThreadSurface({ + viaEnvironmentId: environmentId, + ...link, + label: "fs-17", + title: "Cached title", + }), + ]); +}); + +it("opens a linked machine's thread directly once this client is connected to it", async () => { + const { registry, reply } = setup(); + using _registry = { [Symbol.dispose]: () => registry.dispose() }; + state.linked = new Map([["saved-vm", "fs-17"]]); + state.connected = ["environment", "saved-vm"]; + registry.set(reply, AsyncResult.success({ there: { title: "Fix the build", projectId: null } })); + await using screen = await render( + + + , + ); + await expect.element(screen.getByText("Fix the build")).toBeVisible(); + await expect.element(screen.getByRole("button")).not.toBeInTheDocument(); +}); diff --git a/apps/web/src/components/chat/MarkdownThreadLink.tsx b/apps/web/src/components/chat/MarkdownThreadLink.tsx index 1a0df30fe0518..1e4c823b458b4 100644 --- a/apps/web/src/components/chat/MarkdownThreadLink.tsx +++ b/apps/web/src/components/chat/MarkdownThreadLink.tsx @@ -1,5 +1,6 @@ -import type { EnvironmentId } from "@t3tools/contracts"; +import type { EnvironmentId, ScopedThreadRef } from "@t3tools/contracts"; import { useGT, useMessages } from "gt-react"; +import { MessagesSquareIcon } from "lucide-react"; import { formatHostedThreadLink, guessThreadLinkRef, @@ -7,30 +8,53 @@ import { type ThreadLink, } from "@t3tools/shared/threadLinks"; import { unknownThreadLinkLabel } from "@t3tools/shared/threadLinksCopy"; +import { resolveLinkedThreadOpen } from "@t3tools/client-runtime/linked-thread"; import { configuredHostedAppUrl } from "../../hostedPairing"; import { useThreadRefs, useThreadShell } from "../../state/entities"; -import { useEnvironmentIdentities } from "../../state/environments"; +import { useConnectedEnvironmentIds, useEnvironmentIdentities } from "../../state/environments"; +import { useRightPanelStore } from "../../rightPanelStore"; +import { useLinkedEnvironments } from "../../state/peerLinks"; import { orchestrationEnvironment } from "../../state/orchestration"; import { useEnvironmentQuery } from "../../state/query"; +import { ContextChip, ContextChipLabel } from "../ContextChip"; import { UnresolvedChip } from "../contextChipParts"; import { ThreadContextChip } from "../ThreadContextChip"; +import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip"; /** `label` is the link's written text; an autolink has none. */ export function MarkdownThreadLink(props: { readonly environmentId: EnvironmentId; + /** The thread the link is written in; a linked environment's thread opens in its right panel. */ + readonly threadRef?: ScopedThreadRef | undefined; readonly link: ThreadLink; readonly label: string | null; }) { const gt = useGT(); const messages = useMessages(); + const panelRef = props.threadRef; const candidates = threadLinkCandidates(props.link, props.environmentId); const writtenRef = candidates[0]!; const written = useThreadShell(writtenRef); - // A linked machine's threads are reachable only through its server, not from this client. - const reachable = useEnvironmentIdentities().some( + const saved = useEnvironmentIdentities().some( (environment) => environment.environmentId === writtenRef.environmentId, ); + const connected = useConnectedEnvironmentIds().includes(writtenRef.environmentId); + // A thread on a machine this client is not connected to still reads through the one that links to it. + const linkedLabel = useLinkedEnvironments( + connected || writtenRef.environmentId === props.environmentId ? null : props.environmentId, + ).get(writtenRef.environmentId); + // A shell cached from an earlier connection does not make the thread open there now. Outside a + // thread there is no panel to read it in, so the link behaves as it does without one. + const linked = + panelRef !== undefined && + resolveLinkedThreadOpen({ + environmentId: writtenRef.environmentId, + viaEnvironmentId: props.environmentId, + own: saved ? { connected } : undefined, + linked: linkedLabel !== undefined, + }) === "linked"; + const reachable = saved && !linked; const lookup = useEnvironmentQuery( written === null && reachable ? orchestrationEnvironment.threadLinkMetadata({ @@ -58,6 +82,41 @@ export function MarkdownThreadLink(props: { : null; const remote = useThreadShell(remoteRef); const resolved = target ?? (remoteRef && remote ? { ref: remoteRef, metadata: remote } : null); + if (linked && linkedLabel !== undefined) { + const knownTitle = props.label ?? written?.title ?? null; + const title = knownTitle ?? gt("Thread on {label}", { label: linkedLabel }); + return ( + + + useRightPanelStore.getState().openLinkedThread(panelRef, { + viaEnvironmentId: props.environmentId, + ...writtenRef, + label: linkedLabel, + title: knownTitle, + }) + } + /> + } + aria-label={gt("Thread, {title}", { title })} + > + + {title} + + } + /> + + {gt("Read the thread on {label}", { label: linkedLabel })} + + + ); + } if (missing && resolved === null) { const unknown = unknownThreadLinkLabel(props.link, props.environmentId, messages); return ; diff --git a/apps/web/src/components/chat/ProviderSubagentBar.tsx b/apps/web/src/components/chat/ProviderSubagentBar.tsx index 39c3c7cd2dc0f..315461296bade 100644 --- a/apps/web/src/components/chat/ProviderSubagentBar.tsx +++ b/apps/web/src/components/chat/ProviderSubagentBar.tsx @@ -11,6 +11,11 @@ import { tickTextContent } from "~/lib/tickTextContent"; import type { ProviderInstanceEntry } from "../../providerInstances"; import { Button } from "../ui/button"; import { ProviderInstanceIcon } from "./ProviderInstanceIcon"; +import { + ReadOnlyComposerBar, + ReadOnlyComposerLead, + ReadOnlyComposerStatus, +} from "./ReadOnlyComposerBar"; export function ProviderSubagentBar(props: { readonly provider: ProviderInstanceEntry | null; @@ -33,55 +38,54 @@ export function ProviderSubagentBar(props: { messages, ); - // Sized by the composer, not the viewport: a docked side panel narrows the - // chat column on a wide window, and one row there squeezes out the model - // and status, so the status drops to its own line instead. return ( -
-
- - {props.provider ? ( - - ) : null} - {props.modelLabel} - {props.effortLabel === null ? null : ( - {props.effortLabel} - )} - - formatProviderSubagentStatus(status, nowMs, messages), - live, - )} - aria-hidden - className="min-w-0 max-w-full truncate text-muted-foreground tabular-nums @max-[560px]/composer-surface:text-xs" - /> -
- - {gt("{model} subagent: {status}", { model: modelDescription, status: announcement })} - - - Runs on its own - - {props.actions} - {props.onOpenParent ? ( - - ) : null} -
+ + Runs on its own + + {props.actions} + {props.onOpenParent ? ( + + ) : null} + + } + > + + {props.provider ? ( + + ) : null} + {props.modelLabel} + {props.effortLabel === null ? null : ( + {props.effortLabel} + )} + + formatProviderSubagentStatus(status, nowMs, messages), + live, + )} + aria-hidden + /> + ); } diff --git a/apps/web/src/components/chat/ReadOnlyComposerBar.tsx b/apps/web/src/components/chat/ReadOnlyComposerBar.tsx new file mode 100644 index 0000000000000..d2df437ae98c4 --- /dev/null +++ b/apps/web/src/components/chat/ReadOnlyComposerBar.tsx @@ -0,0 +1,37 @@ +import type { ComponentProps, ReactNode } from "react"; + +/** + * What stands where the composer would for a thread that takes no messages. `children` say what + * the thread is and how it is doing; `actions` sit at the trailing edge. + */ +export function ReadOnlyComposerBar(props: { + readonly children: ReactNode; + readonly actions?: ReactNode; +}) { + // Sized by the composer, not the viewport: a docked side panel narrows the + // chat column on a wide window, and one row there squeezes out the lead + // and status, so the status drops to its own line instead. + return ( +
+
+ {props.children} +
+ {props.actions} +
+ ); +} + +/** The bar's first line: an icon and what the thread is. */ +export function ReadOnlyComposerLead(props: { readonly children: ReactNode }) { + return {props.children}; +} + +/** The bar's second line, which drops under the lead in a narrow composer. */ +export function ReadOnlyComposerStatus(props: Omit, "className">) { + return ( + + ); +} diff --git a/apps/web/src/components/chat/ReadOnlyThreadTimeline.tsx b/apps/web/src/components/chat/ReadOnlyThreadTimeline.tsx new file mode 100644 index 0000000000000..1cb825e13461d --- /dev/null +++ b/apps/web/src/components/chat/ReadOnlyThreadTimeline.tsx @@ -0,0 +1,143 @@ +import type { LegendListRef } from "@legendapp/list/react"; +import { + deriveRunlessWorkStartedAt, + deriveThreadActivityRun, + deriveThreadStructureRuntime, +} from "@t3tools/client-runtime/state/thread-execution"; +import { createQuestionHistoryProjector } from "@t3tools/client-runtime/state/thread-requests"; +import { + EnvironmentId, + type OrchestrationV2ProjectedTurnItem, + type OrchestrationV2ThreadProjection, +} from "@t3tools/contracts"; +import { useRef, useState, type ReactNode } from "react"; + +import { useIncrementalTimelineEntries } from "~/hooks/useIncrementalTimelineEntries"; +import { useTheme } from "~/hooks/useTheme"; +import { deriveActiveWorkStartedAt, derivePhase } from "~/session-logic"; +import type { ChatFileAttachment } from "~/types"; + +import type { ExpandedImagePreview } from "./ExpandedImagePreview"; +import { MessagesTimeline, type MessagesTimelineHistoryControls } from "./MessagesTimeline"; +import { ScrollToEndButton } from "./TimelineOverlays"; +import type { TimelineRow, TurnItemSource } from "./timelineRowContext"; +import { useTimelineFollow } from "./useTimelineFollow"; + +// The timeline needs an environment id to key its rows. No environment answers to this one, so a +// row that would ask the thread's environment for something gets nothing. +const NO_ENVIRONMENT_ID = EnvironmentId.make("guest"); +const NO_TURN_DIFFS: ReadonlyArray = []; +const NO_OPTIMISTIC_MESSAGES: ReadonlyArray = []; +const ignore = () => {}; + +/** + * A thread's own timeline, built from its projection alone and read-only: every action that would + * reach the thread's environment (fork, revert, reply, diffs, files, other threads, shell, + * approvals) is left out, so its control does not render. The guest page and a linked + * environment's thread both show a thread this way. + */ +export function ReadOnlyThreadTimeline(props: { + /** Keys the list. It holds no ":" so the timeline finds no environment thread behind it. */ + readonly threadKey: string; + readonly projection: OrchestrationV2ThreadProjection; + readonly historyControls: MessagesTimelineHistoryControls | undefined; + /** Where expanded rows read an item's detail. */ + readonly turnItemSource: TurnItemSource; + /** Preview URLs for the messages' attachments, keyed by attachment id. */ + readonly attachmentUrls: ( + items: ReadonlyArray, + ) => ReadonlyMap; + readonly onImageExpand: (preview: ExpandedImagePreview) => void; + readonly onFileOpen: (file: ChatFileAttachment) => void; + readonly renderHtmlRender: (row: Extract) => ReactNode; + readonly renderFooter?: (items: ReadonlyArray) => ReactNode; + /** What stands below the timeline, where the composer would. */ + readonly children: (controls: { readonly scrollToEnd: () => void }) => ReactNode; +}) { + const { threadKey, projection } = props; + const listRef = useRef(null); + const { resolvedTheme } = useTheme(); + // The rest is what ChatView derives from the same projection. + const [projectQuestionHistory] = useState(() => createQuestionHistoryProjector()); + const items = projectQuestionHistory(projection); + const entries = useIncrementalTimelineEntries(threadKey, { + visibleTurnItems: items, + optimisticMessages: NO_OPTIMISTIC_MESSAGES, + attachmentUrlById: props.attachmentUrls(items), + attempts: projection.attempts, + nodes: projection.nodes, + plans: projection.plans, + }); + const activityRun = deriveThreadActivityRun(projection); + const runtime = deriveThreadStructureRuntime(projection); + const runlessWorkStartedAt = deriveRunlessWorkStartedAt(projection); + const isWorking = derivePhase(runtime) === "running" || runlessWorkStartedAt !== null; + const workStartedAt = + deriveActiveWorkStartedAt(activityRun, runtime, null) ?? runlessWorkStartedAt; + const runningRunId = runtime?.activeRunId ?? null; + const follow = useTimelineFollow({ + legendListRef: listRef, + composerTimelineInset: 0, + routeThreadKey: threadKey, + activeThreadKey: threadKey, + // Not a server thread: new turns follow the end instead of anchoring near the top. + isServerThread: false, + serverProjection: null, + threadStatus: "live", + activeActivityRun: activityRun, + activeRunningTurnId: runningRunId, + timelineEntries: entries, + timelineAnchorMessageId: null, + setTimelineAnchor: ignore, + }); + return ( + <> +
+ + {follow.showScrollToBottom ? ( + follow.scrollToEnd(true)} + /> + ) : null} +
+ {props.children({ scrollToEnd: () => follow.scrollToEnd(true) })} + + ); +} diff --git a/apps/web/src/components/chat/RightPanelSurfaceContent.tsx b/apps/web/src/components/chat/RightPanelSurfaceContent.tsx index 80f27c8dce568..31d8b77826d97 100644 --- a/apps/web/src/components/chat/RightPanelSurfaceContent.tsx +++ b/apps/web/src/components/chat/RightPanelSurfaceContent.tsx @@ -12,6 +12,7 @@ import type { } from "@t3tools/contracts"; import { scopedThreadKey } from "@t3tools/client-runtime/environment"; import { lazy, Suspense } from "react"; +import { LinkedThreadPane } from "./LinkedThreadPane"; import SideChatPane from "./SideChatPane"; import type { ComposerImageAttachment, DraftId } from "../../composerDraftStore"; import type { ShortcutMatchContext } from "../../keybindings"; @@ -223,6 +224,15 @@ export function RightPanelSurfaceContent(props: { onClose={() => onCloseSurface(surface)} /> ); + case "linked-thread": + return ( + + ); case "device": return ( diff --git a/apps/web/src/components/chat/ThreadRelationshipsControl.browser.test.tsx b/apps/web/src/components/chat/ThreadRelationshipsControl.browser.test.tsx index 1a0fb5bd406f8..914adf19777ad 100644 --- a/apps/web/src/components/chat/ThreadRelationshipsControl.browser.test.tsx +++ b/apps/web/src/components/chat/ThreadRelationshipsControl.browser.test.tsx @@ -45,6 +45,10 @@ vi.mock(import("../../state/environments"), () => ({ useEnvironment: (() => null) as never, useEnvironmentProviders: (() => new Map()) as never, })); +vi.mock(import("../../state/peerLinks"), () => ({ + peerLinkEnvironment: { readThread: {} } as never, + useLinkedEnvironments: (() => new Map()) as never, +})); vi.mock(import("../../lib/archivedThreadsState"), () => ({ useArchivedThreadSnapshots: (() => ({ snapshots: [{ environmentId: "environment", snapshot: { threads: state.archivedThreads } }], @@ -330,8 +334,9 @@ it("shows a remote subagent's full title in its tooltip even when its environmen await vi.waitFor(() => expect(document.querySelector('[data-slot="tooltip-popup"]')?.textContent).toContain(longTitle), ); + // This client is not connected there, so the row reads the thread through this environment. expect(document.querySelector('[data-slot="tooltip-popup"]')?.textContent).toContain( - "Runs on Remote VM with a long machine name in the office. Connect to it to open the thread there.", + "Read the thread on Remote VM with a long machine name in the office", ); await row.click({ force: true }); diff --git a/apps/web/src/components/chat/ThreadRelationshipsControl.tsx b/apps/web/src/components/chat/ThreadRelationshipsControl.tsx index e8a5fc1fe60a0..1c29eb147fce4 100644 --- a/apps/web/src/components/chat/ThreadRelationshipsControl.tsx +++ b/apps/web/src/components/chat/ThreadRelationshipsControl.tsx @@ -37,6 +37,7 @@ import { type OrchestrationV2RemoteTaskChild, type OrchestrationV2Subagent, type OrchestrationV2ThreadShell, + type ScopedThreadRef, type ServerProvider, type ThreadId, } from "@t3tools/contracts"; @@ -62,6 +63,7 @@ import type { MessageResolver } from "~/i18n/messages"; import { useArchivedThreadSnapshots } from "../../lib/archivedThreadsState"; import { buildThreadRouteParams } from "../../threadRoutes"; +import { useLinkedThreadOpener } from "../../state/linkedThreadView"; import { useProjects, useQuietThreadProjection, @@ -279,18 +281,18 @@ function currentSubagent( } /** - * A task delegated to a linked environment. It has no thread here, so it opens - * the thread there, when this client is connected to that environment. + * A task delegated to a linked environment. It has no thread here, so it opens the thread there: + * in place when this client is connected to that environment, else read-only through this one. */ function RemoteSubagentRow(props: { readonly agent: RemoteSubagent; + /** The thread that delegated the task; its environment holds the link and its panel shows the read. */ + readonly parentRef: ScopedThreadRef; readonly provider: ServerProvider | undefined; readonly anyInstanceBadge: boolean; }) { const gt = useGT(); const m = useMessages(); - const navigate = useNavigate(); - const environment = useEnvironment(props.agent.remoteChild.environmentId); const { remoteChild } = props.agent; const status = props.agent.status; const failed = status === "failed"; @@ -298,27 +300,14 @@ function RemoteSubagentRow(props: { title: props.agent.title ?? gt("Subagent"), isSubagent: true, }); + const opener = useLinkedThreadOpener(props.parentRef, remoteChild, title); return (
  • { - if (environment === null) return; - void navigate({ - to: "/$environmentId/$threadId", - params: buildThreadRouteParams( - scopeThreadRef(remoteChild.environmentId, remoteChild.threadId), - ), - }); - }} - /> + } > @@ -1086,6 +1073,7 @@ export function ThreadRelationshipsPanel(props: { thread?.projection.subagents.find((agent) => agent.id === props.subagentId) ?? null, ); const remote = props.remote ?? agent?.remoteChild; - const remoteEnvironment = useEnvironment(remote?.environmentId ?? null); const gt = useGT(); const m = useMessages(); - const navigate = useNavigate(); const threadId = props.threadId; - // A task in a linked environment opens there, if this client is connected to it. + // A task in a linked environment opens there, or read-only through this one. + const remoteOpener = useLinkedThreadOpener(props.parentRef, remote, props.title); const open = - threadId !== null - ? () => props.onOpenThread(threadId) - : remote !== undefined && remoteEnvironment !== null - ? () => - void navigate({ - to: "/$environmentId/$threadId", - params: buildThreadRouteParams(scopeThreadRef(remote.environmentId, remote.threadId)), - }) - : null; + threadId !== null ? () => props.onOpenThread(threadId) : (remoteOpener?.open ?? null); const liveStatus = agent?.status ?? props.status; const status = props.event ? props.event.status : liveStatus; const statusLabel = props.event?.label ?? m(subagentStatusVisual(liveStatus).label); diff --git a/apps/web/src/components/chat/timelineRowContext.ts b/apps/web/src/components/chat/timelineRowContext.ts index 6a298fd6de049..2373193588f06 100644 --- a/apps/web/src/components/chat/timelineRowContext.ts +++ b/apps/web/src/components/chat/timelineRowContext.ts @@ -37,7 +37,8 @@ import { type HandoffTimelineRun } from "./V2LifecycleRow"; */ export interface TurnItemSource { readonly detail: TurnItemDetailSource; - readonly commandOutput: (target: { + /** Unset where output does not stream: a command row then shows the output its detail holds. */ + readonly commandOutput?: (target: { readonly threadId: ThreadId; readonly itemId: TurnItemId; }) => Atom.Atom>; diff --git a/apps/web/src/components/guest/GuestPage.tsx b/apps/web/src/components/guest/GuestPage.tsx index bf870dcb4b59c..fe045af73ac2c 100644 --- a/apps/web/src/components/guest/GuestPage.tsx +++ b/apps/web/src/components/guest/GuestPage.tsx @@ -1,5 +1,4 @@ import { - EnvironmentId, GUEST_MESSAGE_MAX_LENGTH, GUEST_HISTORY_ROUTE, GUEST_NAME_MAX_LENGTH, @@ -14,16 +13,9 @@ import { type ThreadGuestMessage, type ThreadGuestMessageStatus, } from "@t3tools/contracts"; -import type { LegendListRef } from "@legendapp/list/react"; import * as Option from "effect/Option"; import * as Schema from "effect/Schema"; import { formatAttachmentSize } from "@t3tools/client-runtime/state/attachments"; -import { - deriveRunlessWorkStartedAt, - deriveThreadActivityRun, - deriveThreadStructureRuntime, -} from "@t3tools/client-runtime/state/thread-execution"; -import { createQuestionHistoryProjector } from "@t3tools/client-runtime/state/thread-requests"; import { ArrowUpIcon, PaperclipIcon, XIcon } from "lucide-react"; import { useEffect, @@ -38,24 +30,21 @@ import { msg, T, useGT, useMessages } from "gt-react"; import { m } from "~/i18n/messages"; -import { useIncrementalTimelineEntries } from "~/hooks/useIncrementalTimelineEntries"; import { useNowMinute } from "~/hooks/useNowMinute"; import { useStableCallback } from "~/hooks/useStableCallback"; import { useTheme } from "~/hooks/useTheme"; import { cn } from "~/lib/utils"; -import { deriveActiveWorkStartedAt, derivePhase } from "~/session-logic"; import { ComposerControl, ComposerControlIcon } from "../chat/ComposerControl"; import type { ExpandedImagePreview } from "../chat/ExpandedImagePreview"; import { GuestMessageAttachments } from "../chat/GuestMessageAttachments"; import { HostImageUrlContext } from "../chat/hostImageUrl"; import { PierreEntryIcon } from "../chat/PierreEntryIcon"; import { GuestMessageName, guestBubbleClassName } from "../chat/guestMessageStyle"; -import { MessagesTimeline, type MessagesTimelineHistoryControls } from "../chat/MessagesTimeline"; +import type { MessagesTimelineHistoryControls } from "../chat/MessagesTimeline"; +import { ReadOnlyThreadTimeline } from "../chat/ReadOnlyThreadTimeline"; import { ProviderInstanceIcon } from "../chat/ProviderInstanceIcon"; import { getDisplayModelName, getTriggerDisplayModelName } from "../chat/providerIconUtils"; -import { ScrollToEndButton } from "../chat/TimelineOverlays"; import type { TimelineRow } from "../chat/timelineRowContext"; -import { useTimelineFollow } from "../chat/useTimelineFollow"; import { GuestHtmlRender } from "./GuestHtmlRender"; import { Button } from "../ui/button"; import { Input } from "../ui/input"; @@ -410,17 +399,7 @@ function NameForm({ ); } -// The timeline needs an environment id to key its rows. Nothing behind it loads on this page; -// see isGuestPage. -const GUEST_ENVIRONMENT_ID = EnvironmentId.make("guest"); -const NO_TURN_DIFFS: ReadonlyArray = []; -const NO_OPTIMISTIC_MESSAGES: ReadonlyArray = []; -const ignore = () => {}; - -/** - * The owner's timeline, read-only: every action that would reach the owner's machine (fork, - * revert, diffs, files, other threads, shell) is left out, so its control does not render. - */ +/** The owner's timeline, read-only, with the guest's own messages and composer below it. */ function GuestThread({ view: { shareId, title, expiresAt, messages, model }, projection, @@ -432,124 +411,56 @@ function GuestThread({ readonly awaitingRowIds: GuestStreamState["awaitingRowIds"]; readonly historyControls: MessagesTimelineHistoryControls | undefined; }) { - // No ":" so the timeline finds no environment thread behind the key. - const threadKey = `guest-${shareId}`; - const listRef = useRef(null); - const { resolvedTheme } = useTheme(); - // The rest is what ChatView derives from the same projection. - const [projectQuestionHistory] = useState(() => createQuestionHistoryProjector()); - const items = projectQuestionHistory(projection); // Files load through the guest route. const [attachmentUrls] = useState(() => createGuestAttachmentUrls(shareId)); // Expanded rows read detail and command output through the guest routes. const [turnItemSource] = useState(() => guestTurnItemSource(shareId)); - const attachmentUrlById = attachmentUrls(items); - const entries = useIncrementalTimelineEntries(threadKey, { - visibleTurnItems: items, - optimisticMessages: NO_OPTIMISTIC_MESSAGES, - attachmentUrlById, - attempts: projection.attempts, - nodes: projection.nodes, - plans: projection.plans, - }); const openFile = useStableCallback((file: { readonly id: string }) => openInNewTab(guestAttachmentUrl(shareId, file.id)), ); const hostImageUrl = useStableCallback((path: string) => guestMediaUrl(shareId, path)); - const activityRun = deriveThreadActivityRun(projection); - const runtime = deriveThreadStructureRuntime(projection); - const runlessWorkStartedAt = deriveRunlessWorkStartedAt(projection); - const isWorking = derivePhase(runtime) === "running" || runlessWorkStartedAt !== null; - const workStartedAt = - deriveActiveWorkStartedAt(activityRun, runtime, null) ?? runlessWorkStartedAt; - const runningRunId = runtime?.activeRunId ?? null; - const follow = useTimelineFollow({ - legendListRef: listRef, - composerTimelineInset: 0, - routeThreadKey: threadKey, - activeThreadKey: threadKey, - // Not a server thread: new turns follow the end instead of anchoring near the top. - isServerThread: false, - serverProjection: null, - threadStatus: "live", - activeActivityRun: activityRun, - activeRunningTurnId: runningRunId, - timelineEntries: entries, - timelineAnchorMessageId: null, - setTimelineAnchor: ignore, - }); const renderHtmlRender = useStableCallback( (row: Extract) => ( ), ); - const unplaced = unplacedGuestMessages(messages, items, awaitingRowIds); return ( <>

    {title}

    -
    - - - {unplaced.map((message) => ( -
  • - -
  • - ))} - - ) - } - /> - - {follow.showScrollToBottom ? ( - follow.scrollToEnd(true)} - /> - ) : null} - -
    - follow.scrollToEnd(true)} /> -
    + + { + const unplaced = unplacedGuestMessages(messages, items, awaitingRowIds); + return unplaced.length === 0 ? null : ( +
      + {unplaced.map((message) => ( +
    1. + +
    2. + ))} +
    + ); + }} + > + {({ scrollToEnd }) => ( +
    + +
    + )} +
    +
    ); } diff --git a/apps/web/src/components/guest/guestStream.logic.ts b/apps/web/src/components/guest/guestStream.logic.ts index 639848e6dc591..cbb9231b2ef98 100644 --- a/apps/web/src/components/guest/guestStream.logic.ts +++ b/apps/web/src/components/guest/guestStream.logic.ts @@ -10,31 +10,23 @@ import { type GuestShareView, type OrchestrationV2ProjectedTurnItem, type OrchestrationV2ThreadHistoryPage, - type OrchestrationV2ThreadProjection, type OrchestrationV2TurnItem, type ThreadGuestMessage, } from "@t3tools/contracts"; import { msg } from "gt-react"; import { m, type MessageResolver } from "~/i18n/messages"; -import { applyOrchestrationV2ProjectionEvent } from "@t3tools/client-runtime/state/orchestration-v2-projection"; import { - mergeOlderHistoryIntoProjection, - mergeOlderSubagentsIntoProjection, -} from "@t3tools/client-runtime/state/thread-history-merge"; -import { boundedSnapshotProjection } from "@t3tools/shared/orchestrationV2BoundedSnapshot"; + applyThreadHistoryPage, + applyThreadStreamItem, + initialThreadStreamState, + type ThreadStreamState, +} from "@t3tools/client-runtime/state/thread-stream"; import * as Option from "effect/Option"; import * as Schema from "effect/Schema"; -export interface GuestStreamState { +export interface GuestStreamState extends ThreadStreamState { readonly view: GuestShareView | null; - /** The thread as the owner's client holds it, built with the same reducer. */ - readonly projection: OrchestrationV2ThreadProjection | null; - readonly sequence: number; - /** Set while the snapshot is a window of a longer history, as the owner's client tracks it. */ - readonly partial: { readonly latestLocalTurnOrdinal: number | null } | null; - /** Where "Load earlier turns" continues, or null once the whole thread is loaded. */ - readonly historyCursor: string | null; readonly ended: boolean; /** * Messages this page saw waiting that have no transcript row yet. Survives reconnects, and a @@ -44,11 +36,8 @@ export interface GuestStreamState { } export const initialGuestStreamState: GuestStreamState = { + ...initialThreadStreamState, view: null, - projection: null, - sequence: 0, - partial: null, - historyCursor: null, ended: false, awaitingRowIds: new Set(), }; @@ -95,10 +84,8 @@ export type GuestHistoryPageLoaded = { }; /** - * Applies the owner's thread stream the way the owner's client does (see - * EnvironmentThreadState in client-runtime): a snapshot replaces the thread, and later events - * pass through the same projection reducer, once each. Older pages merge in front, as they do in - * the owner's view. + * Applies the share's stream: its thread items go through the reducer every stream-only view of a + * thread shares, and the share's own state is tracked beside it. */ export function applyGuestStreamEvent( state: GuestStreamState, @@ -106,19 +93,15 @@ export function applyGuestStreamEvent( ): GuestStreamState { switch (event.type) { case "history-page": { - // A snapshot since the request replaced the thread and its cursor. - if (state.projection === null || state.historyCursor !== event.cursor) return state; + const next = applyThreadHistoryPage(state, event.cursor, event.page); + if (next === state) return state; return { ...state, - projection: mergeOlderSubagentsIntoProjection( - mergeOlderHistoryIntoProjection(state.projection, event.page.items), - event.page.subagents, - ), + ...next, awaitingRowIds: withoutPlaced( state.awaitingRowIds, event.page.items.map((row) => row.item), ), - historyCursor: event.page.hasMoreHistory ? event.page.nextCursor : null, }; } case "view": @@ -132,48 +115,18 @@ export function applyGuestStreamEvent( awaitingRowIds: withPendingFrom(state.awaitingRowIds, event.view), }; case "thread": { - const item = event.item; - if (item.kind === "snapshot") { - const projection = boundedSnapshotProjection(item); - return { - ...state, - projection, - sequence: item.snapshotSequence, - partial: - item.hasMoreHistory === true || (item.historyCursor ?? null) !== null - ? { latestLocalTurnOrdinal: item.latestLocalTurnOrdinal ?? null } - : null, - historyCursor: item.hasMoreHistory === true ? (item.historyCursor ?? null) : null, - awaitingRowIds: withoutPlaced( - state.awaitingRowIds, - projection.visibleTurnItems.map((row) => row.item), - ), - }; - } - if (item.kind === "synchronized" || item.sequence <= state.sequence) return state; - if (item.kind === "unknown-event") return { ...state, sequence: item.sequence }; - const projection = - applyOrchestrationV2ProjectionEvent( - state.projection, - item.event, - state.partial === null ? undefined : { partialTimeline: true, ...state.partial }, - ) ?? state.projection; - const turnItem = item.event.type === "turn-item.updated" ? item.event.payload : null; - const watermark = state.partial?.latestLocalTurnOrdinal ?? null; + const next = applyThreadStreamItem(state, event.item); + if (next === state) return state; + const placed = + event.item.kind === "snapshot" + ? (next.projection?.visibleTurnItems.map((row) => row.item) ?? []) + : event.item.kind === "event" && event.item.event.type === "turn-item.updated" + ? [event.item.event.payload] + : []; return { ...state, - projection, - sequence: item.sequence, - partial: - state.partial !== null && - turnItem !== null && - (watermark === null || turnItem.ordinal > watermark) - ? { latestLocalTurnOrdinal: turnItem.ordinal } - : state.partial, - awaitingRowIds: - turnItem === null - ? state.awaitingRowIds - : withoutPlaced(state.awaitingRowIds, [turnItem]), + ...next, + awaitingRowIds: withoutPlaced(state.awaitingRowIds, placed), }; } case "ended": diff --git a/apps/web/src/i18n/translations/de.json b/apps/web/src/i18n/translations/de.json index 5439ee39688ea..c41e76ab3b808 100644 --- a/apps/web/src/i18n/translations/de.json +++ b/apps/web/src/i18n/translations/de.json @@ -94,6 +94,19 @@ "21be308917bd450e": "Verknüpfen fehlgeschlagen: {failure}", "acd01e781e2355cc": "Anfrage beendet", "97e4c50a99272f63": "Die Anfrage konnte nicht beantwortet werden. Versuche es erneut.", + "605a491783d18b3f": "Dieser Thread konnte nicht über {via} gelesen werden", + "50f19209548b70d9": "{via} braucht möglicherweise ein Update, bevor es verknüpfte Threads lesen kann.", + "3d624e57d675358c": "Verknüpfte Umgebungen ist auf {via} deaktiviert", + "01b2231effdb835f": "Aktiviere es in den Einstellungen → Labs von {via}, um Threads auf den damit verknüpften Rechnern zu lesen.", + "e767e8901a0a3f35": "{via} ist nicht mehr mit {label} verknüpft", + "df3cd6ccd77084b4": "Verknüpfe es erneut in den Einstellungen → Verbindungen von {via}, um seine Threads von hier aus zu lesen.", + "3920637506407ca0": "Die Verknüpfung von {via} zu {label} ist abgelaufen", + "80fec3c2b4fba678": "Verknüpfe es erneut in den Einstellungen → Verbindungen von {via} mit einem neuen Kopplungscode.", + "fec50d228dc9aa9b": "{label} hat das Lesen abgelehnt", + "cd63d78559603b12": "Dieser Thread ist nicht mehr auf {label}", + "bd29efc163476e72": "Möglicherweise wurde er dort gelöscht.", + "f7870ef3a4828ab1": "{label} braucht ein Update", + "eabbf064657519ee": "{label} antwortet {via} nicht", "f71597ae3afaef44": "{first} und {second}", "4047174839a16714": "{first} und {last}", "65ca7867c176afbf": "{first}, {rest}", @@ -2341,6 +2354,7 @@ "ac0de2a59d9c8860": "Gerät", "1354df9fb7278843": "Einen iOS-Simulator oder Android-Emulator ansehen.", "fdcd9643e2e63b15": "Stelle eine Nebenfrage, während dieser Thread weiterarbeitet.", + "1944f04b75ddf26d": "Thread auf {label}", "314cfeebf191ba0d": "Genehmigung nötig", "4e5b7363441a3831": "Eingabe nötig", "97af4e74a5f95e5e": "läuft", @@ -3602,6 +3616,22 @@ " verknüpft. Der Agent kann diese Verknüpfung so verwenden; ändere den Zugriff unter Einstellungen → Umgebungen." ], "000b0df227182d39": "Andere Adresse…", + "6bb5b1b35b2796ae": "Auf {label} über {via} · Arbeitet", + "a73b7ab25d6e9bdf": "Auf {label} über {via}", + "009e2ca841fdc1ef": "diese Umgebung", + "8cb2e5692c4f05ab": "Öffne diesen Thread auf {label}, um diese Darstellung zu sehen.", + "745a0b899008618c": "Frühere Runden konnten nicht geladen werden. Versuche es erneut.", + "0014ce0aaf1bd68a": "Schreibgeschützt", + "d0bda35aeec66684": [ + "Wird von ", + { + "i": 1, + "k": "_gt_value_1", + "v": "v" + }, + " gelesen …" + ], + "c3e8cd9bf44e2f43": "Angezeigt wird, was zuvor gelesen wurde.", "eb6e0584cf4a2a1d": "Sprache: {language}", "d76c606a3c519b78": "Zeilenumbruch deaktivieren", "2b683498cee8c8a7": "Zeilen umbrechen", @@ -3629,6 +3659,7 @@ "6d329f7d3a50c7e7": "Tabelle kopieren", "6c71d251d9917587": "Als Markdown kopieren", "d510b122f84051a0": "Als CSV kopieren", + "2912e4ac3697686b": "Thread auf {label} lesen", "ced684880c2e1961": "{server} erlauben, {tool} auszuführen?", "b66fa23b5647b62d": "Diese Nachricht von {server} senden?", "bae7f74153fa8a05": "{names} von {server} speichern?", @@ -4161,7 +4192,6 @@ "309b160785f6c473": "Fork in diesem Chat öffnen", "6676cd4b8299663f": "Übergeordneten Thread in diesem Chat öffnen", "63e8c7a0ef0513b5": "Verwandte Threads", - "68060b380fe53942": "Läuft auf {label}. Verbinde dich damit, um den Thread dort zu öffnen.", "9996d9dac573001a": "Auf {label} öffnen", "15a601a94893277f": "Der übergeordnete Thread konnte nicht geöffnet werden", "5eb43f554a5b7a58": "Der übergeordnete Thread wurde gelöscht", @@ -5686,7 +5716,6 @@ "4333d220c55ba5e4": "Abfrage des Arbeitsbereichs fehlgeschlagen.", "422c1671dfcfe474": "''{path}'' existiert nicht.", "20194b81e50497ad": "Ordner kann nicht geladen werden.", - "745a0b899008618c": "Frühere Runden konnten nicht geladen werden. Versuche es erneut.", "0061fff77e36bd4f": "Der Server ist nicht erreichbar.", "04dfdd46e3dd4a2e": "Etwas ist schiefgelaufen. Versuche es erneut.", "084bb2d8127a508d": "Gesendet", @@ -5776,19 +5805,17 @@ "56ca98b79cc9ce49": "Aktivität ({count})", "ddc5e5413923c471": "Du kannst hier nicht kommentieren.", "516def6f5a881e00": "Schließt dieses Issue", - "0014ce0aaf1bd68a": "Schreibgeschützt", "fd93f4720ff70aaf": "Keine", "b6a29fff7c7c0808": "Niemand", "54420465784bb1bd": "Ältere Kommentare laden", "9d82ebf35bfb4043": "Hier ist noch nichts passiert.", - "1cf216566c1ee064": "Projekt nicht verfügbar", "b5ddadeb0810688c": "Status", "93c1fc19d9bf1db0": "Beteiligung", "d5a8b335d88b65bc": "{hidden} ausgeblendet", "2160067266a61dd8": "Beliebig", "cd4ec4acf33c65b9": "{count, plural, one {{count} Label} other {{count} Labels}}", "bfd20acb8b7dee6b": "Beliebig", - "ad208e3e32c85029": "Alle ausblenden", + "aead644e2cf1233f": "Alle anzeigen", "77ce79d865716719": "Keine passenden Projekte.", "af7eb4f9c7f0f575": "Filter", "08247dd39b0c85ff": "Zugewiesene Person", @@ -6463,7 +6490,6 @@ "64d0189be492147c": "Check-Details können nicht geöffnet werden", "600347ca50400a54": "Checks werden geladen…", "1b381201aba745c2": "Keine Checks gemeldet", - "aead644e2cf1233f": "Alle anzeigen", "a6d75a4380173c60": "Checks öffnen: {summary}", "be3d1766bad18693": "Checks: {summary}", "425e4a3d6c5c2867": "{count, plural, one {{count} fehlgeschlagen} other {{count} fehlgeschlagen}}", @@ -9745,6 +9771,7 @@ "51497bd401292062": "Gedrückt halten", "9d6cc6ac23312071": "Doppelt drücken", "f001fa7b329c8fbf": "Erfolgreiche ausblenden", + "ad208e3e32c85029": "Alle ausblenden", "c80e4bb3201efd71": "Zen", "0cb9ffcd1fb46b0c": "Nur Status", "cf0f7fc3df26fa75": "Status und Nachrichten", @@ -9954,6 +9981,7 @@ "573ea5fdf293a9d6": "Alle Checkouts", "470ad8c54049d1e1": "Checkouts durchsuchen", "7e2dfdd9f97fc027": "Projektbereich", + "1cf216566c1ee064": "Projekt nicht verfügbar", "c1b8c351aa90f319": [ { "t": "span", diff --git a/apps/web/src/i18n/translations/en.json b/apps/web/src/i18n/translations/en.json index c378e66342505..a1ef78b60e725 100644 --- a/apps/web/src/i18n/translations/en.json +++ b/apps/web/src/i18n/translations/en.json @@ -94,6 +94,19 @@ "21be308917bd450e": "Could not link: {failure}", "acd01e781e2355cc": "Request ended", "97e4c50a99272f63": "Could not answer the request. Try again.", + "605a491783d18b3f": "Could not read this thread through {via}", + "50f19209548b70d9": "{via} may need an update before it can read linked threads.", + "3d624e57d675358c": "Linked environments is off on {via}", + "01b2231effdb835f": "Turn it on in {via}'s Settings → Labs to read threads on the machines it links to.", + "e767e8901a0a3f35": "{via} is no longer linked to {label}", + "df3cd6ccd77084b4": "Link it again in {via}'s Settings → Connections to read its threads from here.", + "3920637506407ca0": "The link from {via} to {label} expired", + "80fec3c2b4fba678": "Link it again in {via}'s Settings → Connections with a new pairing code.", + "fec50d228dc9aa9b": "{label} refused the read", + "cd63d78559603b12": "This thread is no longer on {label}", + "bd29efc163476e72": "It may have been deleted there.", + "f7870ef3a4828ab1": "{label} needs an update", + "eabbf064657519ee": "{label} is not answering {via}", "f71597ae3afaef44": "{first} and {second}", "4047174839a16714": "{first}, and {last}", "65ca7867c176afbf": "{first}, {rest}", @@ -2341,6 +2354,7 @@ "ac0de2a59d9c8860": "Device", "1354df9fb7278843": "Watch an iOS Simulator or Android Emulator.", "fdcd9643e2e63b15": "Ask a side question while this thread keeps working.", + "1944f04b75ddf26d": "Thread on {label}", "314cfeebf191ba0d": "needs approval", "4e5b7363441a3831": "needs input", "97af4e74a5f95e5e": "running", @@ -3601,6 +3615,22 @@ ". The agent can use that link as it is; change its access in Settings → Environments." ], "000b0df227182d39": "Another address…", + "6bb5b1b35b2796ae": "On {label} via {via} · Working", + "a73b7ab25d6e9bdf": "On {label} via {via}", + "009e2ca841fdc1ef": "this environment", + "8cb2e5692c4f05ab": "Open this thread on {label} to see this visual.", + "745a0b899008618c": "Could not load earlier turns. Try again.", + "0014ce0aaf1bd68a": "Read-only", + "d0bda35aeec66684": [ + "Reading from ", + { + "i": 1, + "k": "_gt_value_1", + "v": "v" + }, + "…" + ], + "c3e8cd9bf44e2f43": "Showing what was read before.", "eb6e0584cf4a2a1d": "Language: {language}", "d76c606a3c519b78": "Disable line wrap", "2b683498cee8c8a7": "Wrap lines", @@ -3628,6 +3658,7 @@ "6d329f7d3a50c7e7": "Copy table", "6c71d251d9917587": "Copy as Markdown", "d510b122f84051a0": "Copy as CSV", + "2912e4ac3697686b": "Read the thread on {label}", "ced684880c2e1961": "Allow {server} to run {tool}?", "b66fa23b5647b62d": "Send this message from {server}?", "bae7f74153fa8a05": "Save {names} from {server}?", @@ -4160,7 +4191,6 @@ "309b160785f6c473": "Open fork in this chat", "6676cd4b8299663f": "Open parent thread in this chat", "63e8c7a0ef0513b5": "Related threads", - "68060b380fe53942": "Runs on {label}. Connect to it to open the thread there.", "9996d9dac573001a": "Open on {label}", "15a601a94893277f": "Could not open the parent thread", "5eb43f554a5b7a58": "The parent thread was deleted", @@ -5687,7 +5717,6 @@ "4333d220c55ba5e4": "Workspace query failed.", "422c1671dfcfe474": "''{path}'' does not exist.", "20194b81e50497ad": "Unable to load folder.", - "745a0b899008618c": "Could not load earlier turns. Try again.", "0061fff77e36bd4f": "Could not reach the server.", "04dfdd46e3dd4a2e": "Something went wrong. Try again.", "084bb2d8127a508d": "Sent", @@ -5777,19 +5806,17 @@ "56ca98b79cc9ce49": "Activity ({count})", "ddc5e5413923c471": "You cannot comment here.", "516def6f5a881e00": "Closes this issue", - "0014ce0aaf1bd68a": "Read-only", "fd93f4720ff70aaf": "None", "b6a29fff7c7c0808": "None", "54420465784bb1bd": "Load older comments", "9d82ebf35bfb4043": "Nothing has happened here yet.", - "1cf216566c1ee064": "Unavailable project", "b5ddadeb0810688c": "State", "93c1fc19d9bf1db0": "Involvement", "d5a8b335d88b65bc": "{hidden} hidden", "2160067266a61dd8": "Any", "cd4ec4acf33c65b9": "{count, plural, one {{count} label} other {{count} labels}}", "bfd20acb8b7dee6b": "Anyone", - "ad208e3e32c85029": "Hide all", + "aead644e2cf1233f": "Show all", "77ce79d865716719": "No matching projects.", "af7eb4f9c7f0f575": "Filters", "08247dd39b0c85ff": "Assignee", @@ -6470,7 +6497,6 @@ "64d0189be492147c": "Unable to open check details", "600347ca50400a54": "Loading checks…", "1b381201aba745c2": "No checks reported", - "aead644e2cf1233f": "Show all", "a6d75a4380173c60": "Open checks: {summary}", "be3d1766bad18693": "Checks: {summary}", "425e4a3d6c5c2867": "{count, plural, one {{count} failed} other {{count} failed}}", @@ -9754,6 +9780,7 @@ "51497bd401292062": "Hold", "9d6cc6ac23312071": "Double press", "f001fa7b329c8fbf": "Hide successful", + "ad208e3e32c85029": "Hide all", "c80e4bb3201efd71": "Zen", "0cb9ffcd1fb46b0c": "Status only", "cf0f7fc3df26fa75": "Status and messages", @@ -9963,6 +9990,7 @@ "573ea5fdf293a9d6": "All checkouts", "470ad8c54049d1e1": "Search checkouts", "7e2dfdd9f97fc027": "Project scope", + "1cf216566c1ee064": "Unavailable project", "c1b8c351aa90f319": [ { "t": "span", diff --git a/apps/web/src/i18n/translations/es.json b/apps/web/src/i18n/translations/es.json index 1538850527718..06096f4d719e1 100644 --- a/apps/web/src/i18n/translations/es.json +++ b/apps/web/src/i18n/translations/es.json @@ -94,6 +94,19 @@ "21be308917bd450e": "No se pudo vincular: {failure}", "acd01e781e2355cc": "Solicitud finalizada", "97e4c50a99272f63": "No se pudo responder a la solicitud. Inténtalo de nuevo.", + "605a491783d18b3f": "No se pudo leer este hilo a través de {via}", + "50f19209548b70d9": "Puede que {via} necesite actualizarse para poder leer hilos vinculados.", + "3d624e57d675358c": "Entornos vinculados está desactivado en {via}", + "01b2231effdb835f": "Actívalo en Ajustes → Labs de {via} para leer hilos de las máquinas que vincula.", + "e767e8901a0a3f35": "{via} ya no está vinculado a {label}", + "df3cd6ccd77084b4": "Vuelve a vincularlo en Ajustes → Conexiones de {via} para leer sus hilos desde aquí.", + "3920637506407ca0": "El vínculo de {via} a {label} ha caducado", + "80fec3c2b4fba678": "Vuelve a vincularlo en Ajustes → Conexiones de {via} con un código de emparejamiento nuevo.", + "fec50d228dc9aa9b": "{label} rechazó la lectura", + "cd63d78559603b12": "Este hilo ya no está en {label}", + "bd29efc163476e72": "Puede que se haya eliminado allí.", + "f7870ef3a4828ab1": "{label} necesita una actualización", + "eabbf064657519ee": "{label} no responde a {via}", "f71597ae3afaef44": "{first} y {second}", "4047174839a16714": "{first} y {last}", "65ca7867c176afbf": "{first}, {rest}", @@ -2341,6 +2354,7 @@ "ac0de2a59d9c8860": "Dispositivo", "1354df9fb7278843": "Mira un simulador de iOS o un emulador de Android.", "fdcd9643e2e63b15": "Haz una pregunta aparte mientras este hilo sigue trabajando.", + "1944f04b75ddf26d": "Hilo en {label}", "314cfeebf191ba0d": "necesita aprobación", "4e5b7363441a3831": "necesita respuesta", "97af4e74a5f95e5e": "en curso", @@ -3601,6 +3615,22 @@ ". El agente puede usar ese vínculo tal cual; cambia su acceso en Ajustes → Entornos." ], "000b0df227182d39": "Otra dirección…", + "6bb5b1b35b2796ae": "En {label} a través de {via} · Trabajando", + "a73b7ab25d6e9bdf": "En {label} a través de {via}", + "009e2ca841fdc1ef": "este entorno", + "8cb2e5692c4f05ab": "Abre este hilo en {label} para ver este elemento visual.", + "745a0b899008618c": "No se pudieron cargar los turnos anteriores. Vuelve a intentarlo.", + "0014ce0aaf1bd68a": "Solo lectura", + "d0bda35aeec66684": [ + "Leyendo desde ", + { + "i": 1, + "k": "_gt_value_1", + "v": "v" + }, + "…" + ], + "c3e8cd9bf44e2f43": "Se muestra lo que se leyó antes.", "eb6e0584cf4a2a1d": "Lenguaje: {language}", "d76c606a3c519b78": "Desactivar ajuste de línea", "2b683498cee8c8a7": "Ajustar líneas", @@ -3628,6 +3658,7 @@ "6d329f7d3a50c7e7": "Copiar tabla", "6c71d251d9917587": "Copiar como Markdown", "d510b122f84051a0": "Copiar como CSV", + "2912e4ac3697686b": "Leer el hilo en {label}", "ced684880c2e1961": "¿Permitir que {server} ejecute {tool}?", "b66fa23b5647b62d": "¿Enviar este mensaje desde {server}?", "bae7f74153fa8a05": "¿Guardar {names} desde {server}?", @@ -4158,7 +4189,6 @@ "309b160785f6c473": "Abrir la bifurcación en este chat", "6676cd4b8299663f": "Abrir el hilo principal en este chat", "63e8c7a0ef0513b5": "Hilos relacionados", - "68060b380fe53942": "Se ejecuta en {label}. Conéctate para abrir el hilo allí.", "9996d9dac573001a": "Abrir en {label}", "15a601a94893277f": "No se pudo abrir el hilo principal", "5eb43f554a5b7a58": "El hilo principal se eliminó", @@ -5685,7 +5715,6 @@ "4333d220c55ba5e4": "Falló la consulta al espacio de trabajo.", "422c1671dfcfe474": "''{path}'' no existe.", "20194b81e50497ad": "No se puede cargar la carpeta.", - "745a0b899008618c": "No se pudieron cargar los turnos anteriores. Vuelve a intentarlo.", "0061fff77e36bd4f": "No se pudo acceder al servidor.", "04dfdd46e3dd4a2e": "Algo salió mal. Vuelve a intentarlo.", "084bb2d8127a508d": "Enviado", @@ -5775,19 +5804,17 @@ "56ca98b79cc9ce49": "Actividad ({count})", "ddc5e5413923c471": "No puedes comentar aquí.", "516def6f5a881e00": "Cierra esta issue", - "0014ce0aaf1bd68a": "Solo lectura", "fd93f4720ff70aaf": "Ninguna", "b6a29fff7c7c0808": "Nadie", "54420465784bb1bd": "Cargar comentarios anteriores", "9d82ebf35bfb4043": "Aquí no ha pasado nada todavía.", - "1cf216566c1ee064": "Proyecto no disponible", "b5ddadeb0810688c": "Estado", "93c1fc19d9bf1db0": "Participación", "d5a8b335d88b65bc": "{hidden} ocultos", "2160067266a61dd8": "Cualquiera", "cd4ec4acf33c65b9": "{count, plural, one {{count} etiqueta} other {{count} etiquetas}}", "bfd20acb8b7dee6b": "Cualquiera", - "ad208e3e32c85029": "Ocultar todo", + "aead644e2cf1233f": "Mostrar todo", "77ce79d865716719": "No hay proyectos que coincidan.", "af7eb4f9c7f0f575": "Filtros", "08247dd39b0c85ff": "Asignado", @@ -6463,7 +6490,6 @@ "64d0189be492147c": "No se pueden abrir los detalles de la comprobación", "600347ca50400a54": "Cargando comprobaciones…", "1b381201aba745c2": "No se informó de ninguna comprobación", - "aead644e2cf1233f": "Mostrar todo", "a6d75a4380173c60": "Abrir comprobaciones: {summary}", "be3d1766bad18693": "Comprobaciones: {summary}", "425e4a3d6c5c2867": "{count, plural, one {{count} con errores} other {{count} con errores}}", @@ -9742,6 +9768,7 @@ "51497bd401292062": "Mantener pulsado", "9d6cc6ac23312071": "Doble pulsación", "f001fa7b329c8fbf": "Ocultar las correctas", + "ad208e3e32c85029": "Ocultar todo", "c80e4bb3201efd71": "Zen", "0cb9ffcd1fb46b0c": "Solo el estado", "cf0f7fc3df26fa75": "Estado y mensajes", @@ -9951,6 +9978,7 @@ "573ea5fdf293a9d6": "Todos los checkouts", "470ad8c54049d1e1": "Buscar checkouts", "7e2dfdd9f97fc027": "Ámbito de proyectos", + "1cf216566c1ee064": "Proyecto no disponible", "c1b8c351aa90f319": [ { "t": "span", diff --git a/apps/web/src/i18n/translations/fr.json b/apps/web/src/i18n/translations/fr.json index b9166940ccf66..d519bf76402c2 100644 --- a/apps/web/src/i18n/translations/fr.json +++ b/apps/web/src/i18n/translations/fr.json @@ -94,6 +94,19 @@ "21be308917bd450e": "Association impossible : {failure}", "acd01e781e2355cc": "Demande terminée", "97e4c50a99272f63": "Impossible de répondre à la demande. Réessayez.", + "605a491783d18b3f": "Impossible de lire ce fil via {via}", + "50f19209548b70d9": "{via} a peut-être besoin d’une mise à jour pour lire les fils associés.", + "3d624e57d675358c": "Les environnements associés sont désactivés sur {via}", + "01b2231effdb835f": "Activez-les dans Paramètres → Labs de {via} pour lire les fils des machines qui lui sont associées.", + "e767e8901a0a3f35": "{via} n’est plus associé à {label}", + "df3cd6ccd77084b4": "Associez-le à nouveau dans Paramètres → Connexions de {via} pour lire ses fils d’ici.", + "3920637506407ca0": "L’association de {via} à {label} a expiré", + "80fec3c2b4fba678": "Associez-le à nouveau dans Paramètres → Connexions de {via} avec un nouveau code d’appairage.", + "fec50d228dc9aa9b": "{label} a refusé la lecture", + "cd63d78559603b12": "Ce fil n’est plus sur {label}", + "bd29efc163476e72": "Il a peut-être été supprimé là-bas.", + "f7870ef3a4828ab1": "{label} a besoin d’une mise à jour", + "eabbf064657519ee": "{label} ne répond pas à {via}", "f71597ae3afaef44": "{first} et {second}", "4047174839a16714": "{first} et {last}", "65ca7867c176afbf": "{first}, {rest}", @@ -2341,6 +2354,7 @@ "ac0de2a59d9c8860": "Appareil", "1354df9fb7278843": "Regardez un simulateur iOS ou un émulateur Android.", "fdcd9643e2e63b15": "Posez une question annexe pendant que ce fil continue de travailler.", + "1944f04b75ddf26d": "Fil sur {label}", "314cfeebf191ba0d": "approbation requise", "4e5b7363441a3831": "réponse requise", "97af4e74a5f95e5e": "en cours", @@ -3601,6 +3615,22 @@ ". L’agent peut utiliser cette association telle quelle ; modifiez son accès dans Paramètres → Environnements." ], "000b0df227182d39": "Autre adresse…", + "6bb5b1b35b2796ae": "Sur {label} via {via} · En cours", + "a73b7ab25d6e9bdf": "Sur {label} via {via}", + "009e2ca841fdc1ef": "cet environnement", + "8cb2e5692c4f05ab": "Ouvrez ce fil sur {label} pour voir ce visuel.", + "745a0b899008618c": "Impossible de charger les tours précédents. Réessayez.", + "0014ce0aaf1bd68a": "Lecture seule", + "d0bda35aeec66684": [ + "Lecture depuis ", + { + "i": 1, + "k": "_gt_value_1", + "v": "v" + }, + "…" + ], + "c3e8cd9bf44e2f43": "Affichage de ce qui a été lu auparavant.", "eb6e0584cf4a2a1d": "Langage : {language}", "d76c606a3c519b78": "Désactiver le retour à la ligne", "2b683498cee8c8a7": "Retour à la ligne", @@ -3628,6 +3658,7 @@ "6d329f7d3a50c7e7": "Copier le tableau", "6c71d251d9917587": "Copier en Markdown", "d510b122f84051a0": "Copier en CSV", + "2912e4ac3697686b": "Lire le fil sur {label}", "ced684880c2e1961": "Autoriser {server} à exécuter {tool} ?", "b66fa23b5647b62d": "Envoyer ce message depuis {server} ?", "bae7f74153fa8a05": "Enregistrer {names} depuis {server} ?", @@ -4159,7 +4190,6 @@ "309b160785f6c473": "Ouvrir le fork dans cette discussion", "6676cd4b8299663f": "Ouvrir le fil parent dans cette discussion", "63e8c7a0ef0513b5": "Fils liés", - "68060b380fe53942": "S’exécute sur {label}. Connectez-vous-y pour y ouvrir le fil.", "9996d9dac573001a": "Ouvrir sur {label}", "15a601a94893277f": "Impossible d’ouvrir le fil parent", "5eb43f554a5b7a58": "Le fil parent a été supprimé", @@ -5686,7 +5716,6 @@ "4333d220c55ba5e4": "Échec de la requête sur l’espace de travail.", "422c1671dfcfe474": "''{path}'' n’existe pas.", "20194b81e50497ad": "Impossible de charger le dossier.", - "745a0b899008618c": "Impossible de charger les tours précédents. Réessayez.", "0061fff77e36bd4f": "Impossible de joindre le serveur.", "04dfdd46e3dd4a2e": "Une erreur s’est produite. Réessayez.", "084bb2d8127a508d": "Envoyé", @@ -5776,19 +5805,17 @@ "56ca98b79cc9ce49": "Activité ({count})", "ddc5e5413923c471": "Vous ne pouvez pas commenter ici.", "516def6f5a881e00": "Ferme ce ticket", - "0014ce0aaf1bd68a": "Lecture seule", "fd93f4720ff70aaf": "Aucun", "b6a29fff7c7c0808": "Personne", "54420465784bb1bd": "Charger les commentaires plus anciens", "9d82ebf35bfb4043": "Rien ne s’est encore passé ici.", - "1cf216566c1ee064": "Projet indisponible", "b5ddadeb0810688c": "État", "93c1fc19d9bf1db0": "Participation", "d5a8b335d88b65bc": "{hidden} masqués", "2160067266a61dd8": "Tous", "cd4ec4acf33c65b9": "{count, plural, one {{count} libellé} other {{count} libellés}}", "bfd20acb8b7dee6b": "N’importe qui", - "ad208e3e32c85029": "Tout masquer", + "aead644e2cf1233f": "Tout afficher", "77ce79d865716719": "Aucun projet correspondant.", "af7eb4f9c7f0f575": "Filtres", "08247dd39b0c85ff": "Assigné", @@ -6464,7 +6491,6 @@ "64d0189be492147c": "Impossible d’ouvrir les détails du check", "600347ca50400a54": "Chargement des checks…", "1b381201aba745c2": "Aucun check signalé", - "aead644e2cf1233f": "Tout afficher", "a6d75a4380173c60": "Ouvrir les checks : {summary}", "be3d1766bad18693": "Checks : {summary}", "425e4a3d6c5c2867": "{count, plural, one {{count} en échec} other {{count} en échec}}", @@ -9744,6 +9770,7 @@ "51497bd401292062": "Appui long", "9d6cc6ac23312071": "Double appui", "f001fa7b329c8fbf": "Masquer les réussis", + "ad208e3e32c85029": "Tout masquer", "c80e4bb3201efd71": "Zen", "0cb9ffcd1fb46b0c": "Statut uniquement", "cf0f7fc3df26fa75": "Statut et messages", @@ -9953,6 +9980,7 @@ "573ea5fdf293a9d6": "Tous les checkouts", "470ad8c54049d1e1": "Rechercher des checkouts", "7e2dfdd9f97fc027": "Portée des projets", + "1cf216566c1ee064": "Projet indisponible", "c1b8c351aa90f319": [ { "t": "span", diff --git a/apps/web/src/i18n/translations/ja.json b/apps/web/src/i18n/translations/ja.json index da6a34749df88..7e1f2ffd3af8b 100644 --- a/apps/web/src/i18n/translations/ja.json +++ b/apps/web/src/i18n/translations/ja.json @@ -94,6 +94,19 @@ "21be308917bd450e": "リンクできませんでした: {failure}", "acd01e781e2355cc": "リクエストが終了しました", "97e4c50a99272f63": "リクエストに応答できませんでした。もう一度お試しください。", + "605a491783d18b3f": "{via} 経由でこのスレッドを読み取れませんでした", + "50f19209548b70d9": "リンクされたスレッドを読み取るには、{via} の更新が必要な可能性があります。", + "3d624e57d675358c": "{via} でリンクされた環境がオフになっています", + "01b2231effdb835f": "{via} の設定 → Labs でオンにすると、リンク先のマシンのスレッドを読み取れます。", + "e767e8901a0a3f35": "{via} は {label} にリンクされていません", + "df3cd6ccd77084b4": "ここからスレッドを読み取るには、{via} の設定 → 接続で再度リンクしてください。", + "3920637506407ca0": "{via} から {label} へのリンクは期限切れです", + "80fec3c2b4fba678": "{via} の設定 → 接続で、新しいペアリングコードを使って再度リンクしてください。", + "fec50d228dc9aa9b": "{label} が読み取りを拒否しました", + "cd63d78559603b12": "このスレッドはもう {label} にありません", + "bd29efc163476e72": "そちらで削除された可能性があります。", + "f7870ef3a4828ab1": "{label} の更新が必要です", + "eabbf064657519ee": "{label} が {via} に応答していません", "f71597ae3afaef44": "{first} と {second}", "4047174839a16714": "{first}、{last}", "65ca7867c176afbf": "{first}、{rest}", @@ -2339,6 +2352,7 @@ "ac0de2a59d9c8860": "デバイス", "1354df9fb7278843": "iOS シミュレーターまたは Android エミュレーターを表示します。", "fdcd9643e2e63b15": "このスレッドの作業を続けたまま、別の質問をします。", + "1944f04b75ddf26d": "{label} のスレッド", "314cfeebf191ba0d": "承認が必要", "4e5b7363441a3831": "入力が必要", "97af4e74a5f95e5e": "実行中", @@ -3596,6 +3610,22 @@ " にリンクされています。エージェントはそのリンクをそのまま使用できます。アクセス権は [設定] → [環境] で変更してください。" ], "000b0df227182d39": "別のアドレス…", + "6bb5b1b35b2796ae": "{label}({via} 経由) · 作業中", + "a73b7ab25d6e9bdf": "{label}({via} 経由)", + "009e2ca841fdc1ef": "この環境", + "8cb2e5692c4f05ab": "このビジュアルを見るには、{label} でこのスレッドを開いてください。", + "745a0b899008618c": "以前のターンを読み込めませんでした。もう一度お試しください。", + "0014ce0aaf1bd68a": "読み取り専用", + "d0bda35aeec66684": [ + "読み取り中: ", + { + "i": 1, + "k": "_gt_value_1", + "v": "v" + }, + "…" + ], + "c3e8cd9bf44e2f43": "以前に読み取った内容を表示しています。", "eb6e0584cf4a2a1d": "言語: {language}", "d76c606a3c519b78": "行の折り返しを無効にする", "2b683498cee8c8a7": "行を折り返す", @@ -3623,6 +3653,7 @@ "6d329f7d3a50c7e7": "表をコピー", "6c71d251d9917587": "Markdown としてコピー", "d510b122f84051a0": "CSV としてコピー", + "2912e4ac3697686b": "{label} のスレッドを読む", "ced684880c2e1961": "{server} に {tool} の実行を許可しますか?", "b66fa23b5647b62d": "{server} からこのメッセージを送信しますか?", "bae7f74153fa8a05": "{server} からの {names} を保存しますか?", @@ -4149,7 +4180,6 @@ "309b160785f6c473": "このチャットでフォークを開く", "6676cd4b8299663f": "このチャットで親スレッドを開く", "63e8c7a0ef0513b5": "関連するスレッド", - "68060b380fe53942": "{label} で実行されています。そこでスレッドを開くには接続してください。", "9996d9dac573001a": "{label} で開く", "15a601a94893277f": "親スレッドを開けませんでした", "5eb43f554a5b7a58": "親スレッドは削除されました", @@ -5668,7 +5698,6 @@ "4333d220c55ba5e4": "ワークスペースのクエリに失敗しました。", "422c1671dfcfe474": "''{path}'' は存在しません。", "20194b81e50497ad": "フォルダーを読み込めません。", - "745a0b899008618c": "以前のターンを読み込めませんでした。もう一度お試しください。", "0061fff77e36bd4f": "サーバーに接続できませんでした。", "04dfdd46e3dd4a2e": "問題が発生しました。もう一度お試しください。", "084bb2d8127a508d": "送信済み", @@ -5758,19 +5787,17 @@ "56ca98b79cc9ce49": "アクティビティ ({count})", "ddc5e5413923c471": "ここではコメントできません。", "516def6f5a881e00": "この Issue をクローズします", - "0014ce0aaf1bd68a": "読み取り専用", "fd93f4720ff70aaf": "なし", "b6a29fff7c7c0808": "なし", "54420465784bb1bd": "以前のコメントを読み込む", "9d82ebf35bfb4043": "まだアクティビティはありません。", - "1cf216566c1ee064": "利用できないプロジェクト", "b5ddadeb0810688c": "状態", "93c1fc19d9bf1db0": "関与", "d5a8b335d88b65bc": "{hidden} 件非表示", "2160067266a61dd8": "すべて", "cd4ec4acf33c65b9": "{count, plural, other {{count} 個のラベル}}", "bfd20acb8b7dee6b": "すべてのユーザー", - "ad208e3e32c85029": "すべて非表示", + "aead644e2cf1233f": "すべて表示", "77ce79d865716719": "一致するプロジェクトはありません。", "af7eb4f9c7f0f575": "フィルター", "08247dd39b0c85ff": "担当者", @@ -6433,7 +6460,6 @@ "64d0189be492147c": "チェックの詳細を開けません", "600347ca50400a54": "チェックを読み込んでいます…", "1b381201aba745c2": "報告されたチェックはありません", - "aead644e2cf1233f": "すべて表示", "a6d75a4380173c60": "チェックを開く: {summary}", "be3d1766bad18693": "チェック: {summary}", "425e4a3d6c5c2867": "{count, plural, other {{count} 件失敗}}", @@ -9696,6 +9722,7 @@ "51497bd401292062": "長押し", "9d6cc6ac23312071": "2 回押し", "f001fa7b329c8fbf": "成功したものを非表示", + "ad208e3e32c85029": "すべて非表示", "c80e4bb3201efd71": "Zen", "0cb9ffcd1fb46b0c": "ステータスのみ", "cf0f7fc3df26fa75": "ステータスとメッセージ", @@ -9905,6 +9932,7 @@ "573ea5fdf293a9d6": "すべてのチェックアウト", "470ad8c54049d1e1": "チェックアウトを検索", "7e2dfdd9f97fc027": "プロジェクトの範囲", + "1cf216566c1ee064": "利用できないプロジェクト", "c1b8c351aa90f319": [ { "t": "span", diff --git a/apps/web/src/i18n/translations/ko.json b/apps/web/src/i18n/translations/ko.json index f38e81a9b9398..91d52b3521c62 100644 --- a/apps/web/src/i18n/translations/ko.json +++ b/apps/web/src/i18n/translations/ko.json @@ -94,6 +94,19 @@ "21be308917bd450e": "연결할 수 없음: {failure}", "acd01e781e2355cc": "요청 종료됨", "97e4c50a99272f63": "요청에 응답할 수 없습니다. 다시 시도하세요.", + "605a491783d18b3f": "{via}을(를) 통해 이 스레드를 읽지 못했습니다", + "50f19209548b70d9": "연결된 스레드를 읽으려면 {via}을(를) 업데이트해야 할 수 있습니다.", + "3d624e57d675358c": "{via}에서 연결된 환경이 꺼져 있습니다", + "01b2231effdb835f": "{via}의 설정 → Labs에서 켜면 연결된 기기의 스레드를 읽을 수 있습니다.", + "e767e8901a0a3f35": "{via}이(가) 더 이상 {label}에 연결되어 있지 않습니다", + "df3cd6ccd77084b4": "여기에서 스레드를 읽으려면 {via}의 설정 → 연결에서 다시 연결하세요.", + "3920637506407ca0": "{via}에서 {label}(으)로의 연결이 만료되었습니다", + "80fec3c2b4fba678": "{via}의 설정 → 연결에서 새 페어링 코드로 다시 연결하세요.", + "fec50d228dc9aa9b": "{label}이(가) 읽기를 거부했습니다", + "cd63d78559603b12": "이 스레드는 더 이상 {label}에 없습니다", + "bd29efc163476e72": "그곳에서 삭제되었을 수 있습니다.", + "f7870ef3a4828ab1": "{label}을(를) 업데이트해야 합니다", + "eabbf064657519ee": "{label}이(가) {via}에 응답하지 않습니다", "f71597ae3afaef44": "{first} 및 {second}", "4047174839a16714": "{first} 및 {last}", "65ca7867c176afbf": "{first}, {rest}", @@ -2340,6 +2353,7 @@ "ac0de2a59d9c8860": "기기", "1354df9fb7278843": "iOS 시뮬레이터나 Android 에뮬레이터를 봅니다.", "fdcd9643e2e63b15": "이 스레드가 계속 작업하는 동안 곁가지 질문을 하세요.", + "1944f04b75ddf26d": "{label}의 스레드", "314cfeebf191ba0d": "승인 필요", "4e5b7363441a3831": "입력 필요", "97af4e74a5f95e5e": "실행 중", @@ -3596,6 +3610,22 @@ "에 연결되어 있습니다. 에이전트는 이 연결을 그대로 사용할 수 있으며, 액세스는 설정 → 환경에서 변경하세요." ], "000b0df227182d39": "다른 주소…", + "6bb5b1b35b2796ae": "{label} ({via} 경유) · 작업 중", + "a73b7ab25d6e9bdf": "{label} ({via} 경유)", + "009e2ca841fdc1ef": "이 환경", + "8cb2e5692c4f05ab": "이 시각 자료를 보려면 {label}에서 이 스레드를 여세요.", + "745a0b899008618c": "이전 턴을 불러올 수 없습니다. 다시 시도하세요.", + "0014ce0aaf1bd68a": "읽기 전용", + "d0bda35aeec66684": [ + "읽는 중: ", + { + "i": 1, + "k": "_gt_value_1", + "v": "v" + }, + "…" + ], + "c3e8cd9bf44e2f43": "이전에 읽은 내용을 표시하고 있습니다.", "eb6e0584cf4a2a1d": "언어: {language}", "d76c606a3c519b78": "줄 바꿈 끄기", "2b683498cee8c8a7": "줄 바꿈", @@ -3623,6 +3653,7 @@ "6d329f7d3a50c7e7": "표 복사", "6c71d251d9917587": "Markdown으로 복사", "d510b122f84051a0": "CSV로 복사", + "2912e4ac3697686b": "{label}의 스레드 읽기", "ced684880c2e1961": "{server}이(가) {tool}을(를) 실행하도록 허용할까요?", "b66fa23b5647b62d": "{server}에서 이 메시지를 보낼까요?", "bae7f74153fa8a05": "{server}에서 {names}을(를) 저장할까요?", @@ -4146,7 +4177,6 @@ "309b160785f6c473": "이 채팅에서 포크 열기", "6676cd4b8299663f": "이 채팅에서 상위 스레드 열기", "63e8c7a0ef0513b5": "관련 스레드", - "68060b380fe53942": "{label}에서 실행됩니다. 그곳에서 스레드를 열려면 연결하세요.", "9996d9dac573001a": "{label}에서 열기", "15a601a94893277f": "상위 스레드를 열 수 없습니다", "5eb43f554a5b7a58": "상위 스레드가 삭제되었습니다", @@ -5666,7 +5696,6 @@ "4333d220c55ba5e4": "작업 영역 쿼리에 실패했습니다.", "422c1671dfcfe474": "''{path}''이(가) 없습니다.", "20194b81e50497ad": "폴더를 불러올 수 없습니다.", - "745a0b899008618c": "이전 턴을 불러올 수 없습니다. 다시 시도하세요.", "0061fff77e36bd4f": "서버에 연결할 수 없습니다.", "04dfdd46e3dd4a2e": "문제가 발생했습니다. 다시 시도하세요.", "084bb2d8127a508d": "보냄", @@ -5756,19 +5785,17 @@ "56ca98b79cc9ce49": "활동({count})", "ddc5e5413923c471": "여기에는 댓글을 달 수 없습니다.", "516def6f5a881e00": "이 이슈를 닫음", - "0014ce0aaf1bd68a": "읽기 전용", "fd93f4720ff70aaf": "없음", "b6a29fff7c7c0808": "없음", "54420465784bb1bd": "이전 댓글 불러오기", "9d82ebf35bfb4043": "아직 활동이 없습니다.", - "1cf216566c1ee064": "사용할 수 없는 프로젝트", "b5ddadeb0810688c": "상태", "93c1fc19d9bf1db0": "참여", "d5a8b335d88b65bc": "{hidden}개 숨김", "2160067266a61dd8": "전체", "cd4ec4acf33c65b9": "{count, plural, other {레이블 {count}개}}", "bfd20acb8b7dee6b": "모든 사람", - "ad208e3e32c85029": "모두 숨기기", + "aead644e2cf1233f": "모두 표시", "77ce79d865716719": "일치하는 프로젝트가 없습니다.", "af7eb4f9c7f0f575": "필터", "08247dd39b0c85ff": "담당자", @@ -6435,7 +6462,6 @@ "64d0189be492147c": "검사 세부 정보를 열 수 없습니다", "600347ca50400a54": "검사를 불러오는 중…", "1b381201aba745c2": "보고된 검사 없음", - "aead644e2cf1233f": "모두 표시", "a6d75a4380173c60": "검사 열기: {summary}", "be3d1766bad18693": "검사: {summary}", "425e4a3d6c5c2867": "{count, plural, other {{count}개 실패}}", @@ -9699,6 +9725,7 @@ "51497bd401292062": "길게 누르기", "9d6cc6ac23312071": "두 번 누르기", "f001fa7b329c8fbf": "성공한 항목 숨기기", + "ad208e3e32c85029": "모두 숨기기", "c80e4bb3201efd71": "Zen", "0cb9ffcd1fb46b0c": "상태만", "cf0f7fc3df26fa75": "상태 및 메시지", @@ -9908,6 +9935,7 @@ "573ea5fdf293a9d6": "모든 체크아웃", "470ad8c54049d1e1": "체크아웃 검색", "7e2dfdd9f97fc027": "프로젝트 범위", + "1cf216566c1ee064": "사용할 수 없는 프로젝트", "c1b8c351aa90f319": [ { "t": "span", diff --git a/apps/web/src/i18n/translations/pt-BR.json b/apps/web/src/i18n/translations/pt-BR.json index 24ce6764ab312..446315b7af36e 100644 --- a/apps/web/src/i18n/translations/pt-BR.json +++ b/apps/web/src/i18n/translations/pt-BR.json @@ -94,6 +94,19 @@ "21be308917bd450e": "Não foi possível vincular: {failure}", "acd01e781e2355cc": "Solicitação encerrada", "97e4c50a99272f63": "Não foi possível responder à solicitação. Tente novamente.", + "605a491783d18b3f": "Não foi possível ler esta thread por {via}", + "50f19209548b70d9": "Talvez {via} precise de uma atualização para ler threads vinculadas.", + "3d624e57d675358c": "Ambientes vinculados está desativado em {via}", + "01b2231effdb835f": "Ative em Configurações → Labs de {via} para ler threads das máquinas vinculadas a ele.", + "e767e8901a0a3f35": "{via} não está mais vinculado a {label}", + "df3cd6ccd77084b4": "Vincule novamente em Configurações → Conexões de {via} para ler as threads dele daqui.", + "3920637506407ca0": "O vínculo de {via} com {label} expirou", + "80fec3c2b4fba678": "Vincule novamente em Configurações → Conexões de {via} com um novo código de pareamento.", + "fec50d228dc9aa9b": "{label} recusou a leitura", + "cd63d78559603b12": "Esta thread não está mais em {label}", + "bd29efc163476e72": "Talvez tenha sido excluída lá.", + "f7870ef3a4828ab1": "{label} precisa de uma atualização", + "eabbf064657519ee": "{label} não está respondendo a {via}", "f71597ae3afaef44": "{first} e {second}", "4047174839a16714": "{first} e {last}", "65ca7867c176afbf": "{first}, {rest}", @@ -2341,6 +2354,7 @@ "ac0de2a59d9c8860": "Dispositivo", "1354df9fb7278843": "Acompanhe um iOS Simulator ou Android Emulator.", "fdcd9643e2e63b15": "Faça uma pergunta paralela enquanto esta thread continua trabalhando.", + "1944f04b75ddf26d": "Thread em {label}", "314cfeebf191ba0d": "precisa de aprovação", "4e5b7363441a3831": "precisa de resposta", "97af4e74a5f95e5e": "em execução", @@ -3601,6 +3615,22 @@ ". O agente pode usar esse vínculo como está; altere o acesso em Configurações → Ambientes." ], "000b0df227182d39": "Outro endereço…", + "6bb5b1b35b2796ae": "Em {label} via {via} · Trabalhando", + "a73b7ab25d6e9bdf": "Em {label} via {via}", + "009e2ca841fdc1ef": "este ambiente", + "8cb2e5692c4f05ab": "Abra este thread em {label} para ver este visual.", + "745a0b899008618c": "Não foi possível carregar os turnos anteriores. Tente novamente.", + "0014ce0aaf1bd68a": "Somente leitura", + "d0bda35aeec66684": [ + "Lendo de ", + { + "i": 1, + "k": "_gt_value_1", + "v": "v" + }, + "…" + ], + "c3e8cd9bf44e2f43": "Mostrando o que foi lido antes.", "eb6e0584cf4a2a1d": "Linguagem: {language}", "d76c606a3c519b78": "Desativar quebra de linha", "2b683498cee8c8a7": "Quebrar linhas", @@ -3628,6 +3658,7 @@ "6d329f7d3a50c7e7": "Copiar tabela", "6c71d251d9917587": "Copiar como Markdown", "d510b122f84051a0": "Copiar como CSV", + "2912e4ac3697686b": "Ler a thread em {label}", "ced684880c2e1961": "Permitir que {server} execute {tool}?", "b66fa23b5647b62d": "Enviar esta mensagem de {server}?", "bae7f74153fa8a05": "Salvar {names} de {server}?", @@ -4158,7 +4189,6 @@ "309b160785f6c473": "Abrir o fork neste chat", "6676cd4b8299663f": "Abrir a thread principal neste chat", "63e8c7a0ef0513b5": "Threads relacionadas", - "68060b380fe53942": "Roda em {label}. Conecte-se a ele para abrir a thread lá.", "9996d9dac573001a": "Abrir em {label}", "15a601a94893277f": "Não foi possível abrir a thread principal", "5eb43f554a5b7a58": "A thread principal foi excluída", @@ -5685,7 +5715,6 @@ "4333d220c55ba5e4": "Falha na consulta ao workspace.", "422c1671dfcfe474": "''{path}'' não existe.", "20194b81e50497ad": "Não foi possível carregar a pasta.", - "745a0b899008618c": "Não foi possível carregar os turnos anteriores. Tente novamente.", "0061fff77e36bd4f": "Não foi possível acessar o servidor.", "04dfdd46e3dd4a2e": "Algo deu errado. Tente novamente.", "084bb2d8127a508d": "Enviada", @@ -5775,19 +5804,17 @@ "56ca98b79cc9ce49": "Atividade ({count})", "ddc5e5413923c471": "Você não pode comentar aqui.", "516def6f5a881e00": "Fecha esta issue", - "0014ce0aaf1bd68a": "Somente leitura", "fd93f4720ff70aaf": "Nenhuma", "b6a29fff7c7c0808": "Ninguém", "54420465784bb1bd": "Carregar comentários mais antigos", "9d82ebf35bfb4043": "Nada aconteceu aqui ainda.", - "1cf216566c1ee064": "Projeto indisponível", "b5ddadeb0810688c": "Estado", "93c1fc19d9bf1db0": "Envolvimento", "d5a8b335d88b65bc": "{hidden} ocultos", "2160067266a61dd8": "Qualquer", "cd4ec4acf33c65b9": "{count, plural, one {{count} rótulo} other {{count} rótulos}}", "bfd20acb8b7dee6b": "Qualquer pessoa", - "ad208e3e32c85029": "Ocultar todas", + "aead644e2cf1233f": "Mostrar tudo", "77ce79d865716719": "Nenhum projeto correspondente.", "af7eb4f9c7f0f575": "Filtros", "08247dd39b0c85ff": "Responsável", @@ -6463,7 +6490,6 @@ "64d0189be492147c": "Não foi possível abrir os detalhes da verificação", "600347ca50400a54": "Carregando as verificações…", "1b381201aba745c2": "Nenhuma verificação informada", - "aead644e2cf1233f": "Mostrar tudo", "a6d75a4380173c60": "Abrir verificações: {summary}", "be3d1766bad18693": "Verificações: {summary}", "425e4a3d6c5c2867": "{count, plural, one {{count} com falha} other {{count} com falha}}", @@ -9743,6 +9769,7 @@ "51497bd401292062": "Manter pressionado", "9d6cc6ac23312071": "Pressionar duas vezes", "f001fa7b329c8fbf": "Ocultar bem-sucedidas", + "ad208e3e32c85029": "Ocultar todas", "c80e4bb3201efd71": "Zen", "0cb9ffcd1fb46b0c": "Só status", "cf0f7fc3df26fa75": "Status e mensagens", @@ -9952,6 +9979,7 @@ "573ea5fdf293a9d6": "Todos os checkouts", "470ad8c54049d1e1": "Pesquisar checkouts", "7e2dfdd9f97fc027": "Escopo de projeto", + "1cf216566c1ee064": "Projeto indisponível", "c1b8c351aa90f319": [ { "t": "span", diff --git a/apps/web/src/i18n/translations/ru.json b/apps/web/src/i18n/translations/ru.json index a5f0c249e2ffc..189746a06c277 100644 --- a/apps/web/src/i18n/translations/ru.json +++ b/apps/web/src/i18n/translations/ru.json @@ -94,6 +94,19 @@ "21be308917bd450e": "Не удалось привязать: {failure}", "acd01e781e2355cc": "Запрос завершён", "97e4c50a99272f63": "Не удалось ответить на запрос. Повторите попытку.", + "605a491783d18b3f": "Не удалось прочитать этот тред через {via}", + "50f19209548b70d9": "Возможно, {via} нужно обновить, чтобы читать привязанные треды.", + "3d624e57d675358c": "Привязанные окружения отключены на {via}", + "01b2231effdb835f": "Включите их в разделе «Настройки → Labs» на {via}, чтобы читать треды на привязанных к нему машинах.", + "e767e8901a0a3f35": "{via} больше не связан с {label}", + "df3cd6ccd77084b4": "Свяжите заново в разделе «Настройки → Подключения» на {via}, чтобы читать его треды отсюда.", + "3920637506407ca0": "Срок связи {via} с {label} истёк", + "80fec3c2b4fba678": "Свяжите заново в разделе «Настройки → Подключения» на {via} с новым кодом сопряжения.", + "fec50d228dc9aa9b": "{label} отклонил чтение", + "cd63d78559603b12": "Этого треда больше нет на {label}", + "bd29efc163476e72": "Возможно, его там удалили.", + "f7870ef3a4828ab1": "{label} нужно обновить", + "eabbf064657519ee": "{label} не отвечает {via}", "f71597ae3afaef44": "{first} и {second}", "4047174839a16714": "{first} и {last}", "65ca7867c176afbf": "{first}, {rest}", @@ -2341,6 +2354,7 @@ "ac0de2a59d9c8860": "Устройство", "1354df9fb7278843": "Смотрите на iOS Simulator или Android Emulator.", "fdcd9643e2e63b15": "Задайте побочный вопрос, пока тред продолжает работу.", + "1944f04b75ddf26d": "Тред на {label}", "314cfeebf191ba0d": "нужно подтверждение", "4e5b7363441a3831": "нужен ввод", "97af4e74a5f95e5e": "выполняется", @@ -3601,6 +3615,22 @@ ". Агент может использовать эту привязку как есть; изменить её доступ можно в «Настройки → Окружения»." ], "000b0df227182d39": "Другой адрес…", + "6bb5b1b35b2796ae": "На {label} через {via} · Работает", + "a73b7ab25d6e9bdf": "На {label} через {via}", + "009e2ca841fdc1ef": "это окружение", + "8cb2e5692c4f05ab": "Откройте этот тред на {label}, чтобы увидеть это визуальное представление.", + "745a0b899008618c": "Не удалось загрузить более ранние ходы. Повторите попытку.", + "0014ce0aaf1bd68a": "Только чтение", + "d0bda35aeec66684": [ + "Чтение с ", + { + "i": 1, + "k": "_gt_value_1", + "v": "v" + }, + "…" + ], + "c3e8cd9bf44e2f43": "Показано то, что было прочитано раньше.", "eb6e0584cf4a2a1d": "Язык: {language}", "d76c606a3c519b78": "Отключить перенос строк", "2b683498cee8c8a7": "Переносить строки", @@ -3628,6 +3658,7 @@ "6d329f7d3a50c7e7": "Копировать таблицу", "6c71d251d9917587": "Копировать как Markdown", "d510b122f84051a0": "Копировать как CSV", + "2912e4ac3697686b": "Читать тред на {label}", "ced684880c2e1961": "Разрешить {server} запустить {tool}?", "b66fa23b5647b62d": "Отправить это сообщение от {server}?", "bae7f74153fa8a05": "Сохранить {names} от {server}?", @@ -4158,7 +4189,6 @@ "309b160785f6c473": "Открыть ответвление в этом чате", "6676cd4b8299663f": "Открыть родительский тред в этом чате", "63e8c7a0ef0513b5": "Связанные треды", - "68060b380fe53942": "Работает на {label}. Подключитесь к нему, чтобы открыть тред там.", "9996d9dac573001a": "Открыть на {label}", "15a601a94893277f": "Не удалось открыть родительский тред", "5eb43f554a5b7a58": "Родительский тред удалён", @@ -5685,7 +5715,6 @@ "4333d220c55ba5e4": "Ошибка запроса к рабочей области.", "422c1671dfcfe474": "''{path}'' не существует.", "20194b81e50497ad": "Не удалось загрузить папку.", - "745a0b899008618c": "Не удалось загрузить более ранние ходы. Повторите попытку.", "0061fff77e36bd4f": "Не удалось связаться с сервером.", "04dfdd46e3dd4a2e": "Что-то пошло не так. Повторите попытку.", "084bb2d8127a508d": "Отправлено", @@ -5775,19 +5804,17 @@ "56ca98b79cc9ce49": "Активность ({count})", "ddc5e5413923c471": "Здесь нельзя комментировать.", "516def6f5a881e00": "Закроет этот issue", - "0014ce0aaf1bd68a": "Только чтение", "fd93f4720ff70aaf": "Нет", "b6a29fff7c7c0808": "Нет", "54420465784bb1bd": "Загрузить старые комментарии", "9d82ebf35bfb4043": "Здесь пока ничего не происходило.", - "1cf216566c1ee064": "Проект недоступен", "b5ddadeb0810688c": "Состояние", "93c1fc19d9bf1db0": "Участие", "d5a8b335d88b65bc": "Скрыто: {hidden}", "2160067266a61dd8": "Любая", "cd4ec4acf33c65b9": "{count, plural, one {{count} метка} few {{count} метки} many {{count} меток} other {{count} метки}}", "bfd20acb8b7dee6b": "Любой", - "ad208e3e32c85029": "Скрывать все", + "aead644e2cf1233f": "Показать все", "77ce79d865716719": "Нет подходящих проектов.", "af7eb4f9c7f0f575": "Фильтры", "08247dd39b0c85ff": "Исполнитель", @@ -6463,7 +6490,6 @@ "64d0189be492147c": "Не удалось открыть подробности проверки", "600347ca50400a54": "Загрузка проверок…", "1b381201aba745c2": "Нет проверок", - "aead644e2cf1233f": "Показать все", "a6d75a4380173c60": "Открыть проверки: {summary}", "be3d1766bad18693": "Проверки: {summary}", "425e4a3d6c5c2867": "{count, plural, one {Ошибок: {count}} few {Ошибок: {count}} many {Ошибок: {count}} other {Ошибок: {count}}}", @@ -9746,6 +9772,7 @@ "51497bd401292062": "Удержание", "9d6cc6ac23312071": "Двойное нажатие", "f001fa7b329c8fbf": "Скрывать успешные", + "ad208e3e32c85029": "Скрывать все", "c80e4bb3201efd71": "Дзен", "0cb9ffcd1fb46b0c": "Только статус", "cf0f7fc3df26fa75": "Статус и сообщения", @@ -9955,6 +9982,7 @@ "573ea5fdf293a9d6": "Все копии", "470ad8c54049d1e1": "Поиск копий", "7e2dfdd9f97fc027": "Область проектов", + "1cf216566c1ee064": "Проект недоступен", "c1b8c351aa90f319": [ { "t": "span", diff --git a/apps/web/src/i18n/translations/sv.json b/apps/web/src/i18n/translations/sv.json index 353df28a8a9aa..5c0252912fdc8 100644 --- a/apps/web/src/i18n/translations/sv.json +++ b/apps/web/src/i18n/translations/sv.json @@ -94,6 +94,19 @@ "21be308917bd450e": "Kunde inte länka: {failure}", "acd01e781e2355cc": "Begäran avslutades", "97e4c50a99272f63": "Kunde inte svara på begäran. Försök igen.", + "605a491783d18b3f": "Det gick inte att läsa den här tråden via {via}", + "50f19209548b70d9": "{via} kan behöva uppdateras innan den kan läsa länkade trådar.", + "3d624e57d675358c": "Länkade miljöer är avstängt på {via}", + "01b2231effdb835f": "Slå på det i Inställningar → Labs på {via} för att läsa trådar på maskinerna den länkar till.", + "e767e8901a0a3f35": "{via} är inte längre länkad till {label}", + "df3cd6ccd77084b4": "Länka den igen i Inställningar → Anslutningar på {via} för att läsa dess trådar härifrån.", + "3920637506407ca0": "Länken från {via} till {label} har gått ut", + "80fec3c2b4fba678": "Länka den igen i Inställningar → Anslutningar på {via} med en ny parkopplingskod.", + "fec50d228dc9aa9b": "{label} nekade läsningen", + "cd63d78559603b12": "Den här tråden finns inte längre på {label}", + "bd29efc163476e72": "Den kan ha raderats där.", + "f7870ef3a4828ab1": "{label} behöver uppdateras", + "eabbf064657519ee": "{label} svarar inte {via}", "f71597ae3afaef44": "{first} och {second}", "4047174839a16714": "{first} och {last}", "65ca7867c176afbf": "{first}, {rest}", @@ -2341,6 +2354,7 @@ "ac0de2a59d9c8860": "Enhet", "1354df9fb7278843": "Titta på en iOS-simulator eller Android-emulator.", "fdcd9643e2e63b15": "Ställ en sidofråga medan tråden fortsätter arbeta.", + "1944f04b75ddf26d": "Tråd på {label}", "314cfeebf191ba0d": "behöver godkännande", "4e5b7363441a3831": "behöver input", "97af4e74a5f95e5e": "körs", @@ -3601,6 +3615,22 @@ ". Agenten kan använda den länken som den är; ändra dess åtkomst under Inställningar → Miljöer." ], "000b0df227182d39": "En annan adress…", + "6bb5b1b35b2796ae": "På {label} via {via} · Arbetar", + "a73b7ab25d6e9bdf": "På {label} via {via}", + "009e2ca841fdc1ef": "den här miljön", + "8cb2e5692c4f05ab": "Öppna den här tråden på {label} för att se den här visualiseringen.", + "745a0b899008618c": "Kunde inte läsa in tidigare omgångar. Försök igen.", + "0014ce0aaf1bd68a": "Skrivskyddad", + "d0bda35aeec66684": [ + "Läser från ", + { + "i": 1, + "k": "_gt_value_1", + "v": "v" + }, + "…" + ], + "c3e8cd9bf44e2f43": "Visar det som lästes tidigare.", "eb6e0584cf4a2a1d": "Språk: {language}", "d76c606a3c519b78": "Inaktivera radbrytning", "2b683498cee8c8a7": "Bryt rader", @@ -3628,6 +3658,7 @@ "6d329f7d3a50c7e7": "Kopiera tabell", "6c71d251d9917587": "Kopiera som Markdown", "d510b122f84051a0": "Kopiera som CSV", + "2912e4ac3697686b": "Läs tråden på {label}", "ced684880c2e1961": "Tillåta {server} att köra {tool}?", "b66fa23b5647b62d": "Skicka det här meddelandet från {server}?", "bae7f74153fa8a05": "Spara {names} från {server}?", @@ -4159,7 +4190,6 @@ "309b160785f6c473": "Öppna forken i den här chatten", "6676cd4b8299663f": "Öppna den överordnade tråden i den här chatten", "63e8c7a0ef0513b5": "Relaterade trådar", - "68060b380fe53942": "Körs på {label}. Anslut till den för att öppna tråden där.", "9996d9dac573001a": "Öppna på {label}", "15a601a94893277f": "Kunde inte öppna den överordnade tråden", "5eb43f554a5b7a58": "Den överordnade tråden togs bort", @@ -5686,7 +5716,6 @@ "4333d220c55ba5e4": "Frågan mot arbetsytan misslyckades.", "422c1671dfcfe474": "''{path}'' finns inte.", "20194b81e50497ad": "Det gick inte att läsa in mappen.", - "745a0b899008618c": "Kunde inte läsa in tidigare omgångar. Försök igen.", "0061fff77e36bd4f": "Kunde inte nå servern.", "04dfdd46e3dd4a2e": "Något gick fel. Försök igen.", "084bb2d8127a508d": "Skickat", @@ -5776,19 +5805,17 @@ "56ca98b79cc9ce49": "Aktivitet ({count})", "ddc5e5413923c471": "Du kan inte kommentera här.", "516def6f5a881e00": "Stänger det här ärendet", - "0014ce0aaf1bd68a": "Skrivskyddad", "fd93f4720ff70aaf": "Inga", "b6a29fff7c7c0808": "Ingen", "54420465784bb1bd": "Läs in äldre kommentarer", "9d82ebf35bfb4043": "Inget har hänt här än.", - "1cf216566c1ee064": "Projektet är inte tillgängligt", "b5ddadeb0810688c": "Status", "93c1fc19d9bf1db0": "Inblandning", "d5a8b335d88b65bc": "{hidden} dolda", "2160067266a61dd8": "Alla", "cd4ec4acf33c65b9": "{count, plural, one {{count} etikett} other {{count} etiketter}}", "bfd20acb8b7dee6b": "Vem som helst", - "ad208e3e32c85029": "Dölj alla", + "aead644e2cf1233f": "Visa alla", "77ce79d865716719": "Inga matchande projekt.", "af7eb4f9c7f0f575": "Filter", "08247dd39b0c85ff": "Tilldelad", @@ -6469,7 +6496,6 @@ "64d0189be492147c": "Det gick inte att öppna kontrolldetaljer", "600347ca50400a54": "Läser in kontroller…", "1b381201aba745c2": "Inga kontroller rapporterade", - "aead644e2cf1233f": "Visa alla", "a6d75a4380173c60": "Öppna kontroller: {summary}", "be3d1766bad18693": "Kontroller: {summary}", "425e4a3d6c5c2867": "{count, plural, one {{count} misslyckades} other {{count} misslyckades}}", @@ -9752,6 +9778,7 @@ "51497bd401292062": "Håll ned", "9d6cc6ac23312071": "Dubbeltryck", "f001fa7b329c8fbf": "Dölj lyckade", + "ad208e3e32c85029": "Dölj alla", "c80e4bb3201efd71": "Zen", "0cb9ffcd1fb46b0c": "Endast status", "cf0f7fc3df26fa75": "Status och meddelanden", @@ -9961,6 +9988,7 @@ "573ea5fdf293a9d6": "Alla utcheckningar", "470ad8c54049d1e1": "Sök utcheckningar", "7e2dfdd9f97fc027": "Projektomfång", + "1cf216566c1ee064": "Projektet är inte tillgängligt", "c1b8c351aa90f319": [ { "t": "span", diff --git a/apps/web/src/i18n/translations/zh.json b/apps/web/src/i18n/translations/zh.json index 4acdfc14e2cb4..33c979c0cd911 100644 --- a/apps/web/src/i18n/translations/zh.json +++ b/apps/web/src/i18n/translations/zh.json @@ -94,6 +94,19 @@ "21be308917bd450e": "无法关联:{failure}", "acd01e781e2355cc": "请求已结束", "97e4c50a99272f63": "无法回复此请求。请重试。", + "605a491783d18b3f": "无法通过 {via} 读取此会话", + "50f19209548b70d9": "{via} 可能需要更新后才能读取关联的会话。", + "3d624e57d675358c": "{via} 上的关联环境已关闭", + "01b2231effdb835f": "在 {via} 的设置 → Labs 中开启,即可读取其关联机器上的会话。", + "e767e8901a0a3f35": "{via} 已不再关联 {label}", + "df3cd6ccd77084b4": "在 {via} 的设置 → 连接中重新关联,即可从这里读取其会话。", + "3920637506407ca0": "{via} 到 {label} 的关联已过期", + "80fec3c2b4fba678": "在 {via} 的设置 → 连接中使用新的配对码重新关联。", + "fec50d228dc9aa9b": "{label} 拒绝了读取", + "cd63d78559603b12": "此会话已不在 {label} 上", + "bd29efc163476e72": "它可能已在那里被删除。", + "f7870ef3a4828ab1": "{label} 需要更新", + "eabbf064657519ee": "{label} 没有响应 {via}", "f71597ae3afaef44": "{first} 和 {second}", "4047174839a16714": "{first} 和 {last}", "65ca7867c176afbf": "{first}、{rest}", @@ -2345,6 +2358,7 @@ "ac0de2a59d9c8860": "设备", "1354df9fb7278843": "查看 iOS 模拟器或 Android 模拟器。", "fdcd9643e2e63b15": "在会话继续运行的同时追问一个旁支问题。", + "1944f04b75ddf26d": "{label} 上的会话", "314cfeebf191ba0d": "待批准", "4e5b7363441a3831": "待输入", "97af4e74a5f95e5e": "运行中", @@ -3606,6 +3620,22 @@ "。智能体可以直接使用该关联;请在“设置 → 环境”中更改其访问权限。" ], "000b0df227182d39": "其他地址…", + "6bb5b1b35b2796ae": "位于 {label},经由 {via} · 运行中", + "a73b7ab25d6e9bdf": "位于 {label},经由 {via}", + "009e2ca841fdc1ef": "此环境", + "8cb2e5692c4f05ab": "在 {label} 上打开此会话即可查看此可视内容。", + "745a0b899008618c": "无法加载更早的对话。请重试。", + "0014ce0aaf1bd68a": "只读", + "d0bda35aeec66684": [ + "正在从 ", + { + "i": 1, + "k": "_gt_value_1", + "v": "v" + }, + " 读取…" + ], + "c3e8cd9bf44e2f43": "正在显示之前读取的内容。", "eb6e0584cf4a2a1d": "语言:{language}", "d76c606a3c519b78": "取消自动换行", "2b683498cee8c8a7": "自动换行", @@ -3633,6 +3663,7 @@ "6d329f7d3a50c7e7": "复制表格", "6c71d251d9917587": "复制为 Markdown", "d510b122f84051a0": "复制为 CSV", + "2912e4ac3697686b": "读取 {label} 上的会话", "ced684880c2e1961": "允许 {server} 运行 {tool} 吗?", "b66fa23b5647b62d": "要发送这条来自 {server} 的消息吗?", "bae7f74153fa8a05": "要保存来自 {server} 的 {names} 吗?", @@ -4165,7 +4196,6 @@ "309b160785f6c473": "在此对话中打开分叉", "6676cd4b8299663f": "在此对话中打开父会话", "63e8c7a0ef0513b5": "相关会话", - "68060b380fe53942": "运行于 {label}。连接到它以在那里打开会话。", "9996d9dac573001a": "在 {label} 上打开", "15a601a94893277f": "无法打开父会话", "5eb43f554a5b7a58": "父会话已被删除", @@ -5692,7 +5722,6 @@ "4333d220c55ba5e4": "工作区查询失败。", "422c1671dfcfe474": "''{path}'' 不存在。", "20194b81e50497ad": "无法加载文件夹。", - "745a0b899008618c": "无法加载更早的对话。请重试。", "0061fff77e36bd4f": "无法连接到服务器。", "04dfdd46e3dd4a2e": "出了点问题。请重试。", "084bb2d8127a508d": "已发送", @@ -5782,19 +5811,17 @@ "56ca98b79cc9ce49": "活动({count})", "ddc5e5413923c471": "你无法在此评论。", "516def6f5a881e00": "将关闭此 issue", - "0014ce0aaf1bd68a": "只读", "fd93f4720ff70aaf": "无", "b6a29fff7c7c0808": "无", "54420465784bb1bd": "加载较早的评论", "9d82ebf35bfb4043": "这里还没有任何动态。", - "1cf216566c1ee064": "不可用的项目", "b5ddadeb0810688c": "状态", "93c1fc19d9bf1db0": "参与方式", "d5a8b335d88b65bc": "已隐藏 {hidden} 个", "2160067266a61dd8": "任意", "cd4ec4acf33c65b9": "{count, plural, other {{count} 个标签}}", "bfd20acb8b7dee6b": "任何人", - "ad208e3e32c85029": "全部隐藏", + "aead644e2cf1233f": "全部显示", "77ce79d865716719": "没有匹配的项目。", "af7eb4f9c7f0f575": "筛选条件", "08247dd39b0c85ff": "受理人", @@ -6475,7 +6502,6 @@ "64d0189be492147c": "无法打开检查详情", "600347ca50400a54": "正在加载检查…", "1b381201aba745c2": "未报告任何检查", - "aead644e2cf1233f": "全部显示", "a6d75a4380173c60": "打开检查:{summary}", "be3d1766bad18693": "检查:{summary}", "425e4a3d6c5c2867": "{count, plural, other {{count} 个失败}}", @@ -9759,6 +9785,7 @@ "51497bd401292062": "长按", "9d6cc6ac23312071": "连按两次", "f001fa7b329c8fbf": "隐藏成功的调用", + "ad208e3e32c85029": "全部隐藏", "c80e4bb3201efd71": "专注模式", "0cb9ffcd1fb46b0c": "仅状态", "cf0f7fc3df26fa75": "状态和消息", @@ -9968,6 +9995,7 @@ "573ea5fdf293a9d6": "所有工作副本", "470ad8c54049d1e1": "搜索工作副本", "7e2dfdd9f97fc027": "项目范围", + "1cf216566c1ee064": "不可用的项目", "c1b8c351aa90f319": [ { "t": "span", diff --git a/apps/web/src/linkedThreadSurface.ts b/apps/web/src/linkedThreadSurface.ts new file mode 100644 index 0000000000000..344efffe8d472 --- /dev/null +++ b/apps/web/src/linkedThreadSurface.ts @@ -0,0 +1,55 @@ +import type { LinkedThreadTarget } from "@t3tools/client-runtime/linked-thread"; +import { EnvironmentId, ThreadId } from "@t3tools/contracts"; + +/** A linked environment's thread as a right panel tab, read through `viaEnvironmentId`. */ +export type LinkedThreadSurface = { + id: `linked-thread:${string}`; + kind: "linked-thread"; +} & LinkedThreadTarget; + +/** One tab per thread and the environment it is read through, so opening it again focuses it. */ +export function linkedThreadSurface(target: LinkedThreadTarget): LinkedThreadSurface { + return { + id: `linked-thread:${encodeURIComponent(target.viaEnvironmentId)}:${encodeURIComponent(target.environmentId)}:${encodeURIComponent(target.threadId)}`, + kind: "linked-thread", + viaEnvironmentId: target.viaEnvironmentId, + environmentId: target.environmentId, + threadId: target.threadId, + label: target.label, + title: target.title, + }; +} + +/** A saved linked-thread surface with its id rebuilt, or null when its fields are not usable. */ +export function decodeLinkedThreadSurface(surface: object): LinkedThreadSurface | null { + const { viaEnvironmentId, environmentId, threadId, label, title } = surface as Record< + string, + unknown + >; + if ( + typeof viaEnvironmentId !== "string" || + typeof environmentId !== "string" || + typeof threadId !== "string" || + typeof label !== "string" || + viaEnvironmentId === "" || + environmentId === "" || + threadId === "" + ) { + return null; + } + return linkedThreadSurface({ + viaEnvironmentId: EnvironmentId.make(viaEnvironmentId), + environmentId: EnvironmentId.make(environmentId), + threadId: ThreadId.make(threadId), + label, + title: typeof title === "string" && title !== "" ? title : null, + }); +} + +/** A tab's title: the thread's own once known, else where the thread is. */ +export function linkedThreadTitle( + surface: Pick, + fallback: string, +): string { + return surface.title?.trim() || fallback; +} diff --git a/apps/web/src/reopenClosedView.ts b/apps/web/src/reopenClosedView.ts index 2a4d8a3199f21..f226b5f1efd1e 100644 --- a/apps/web/src/reopenClosedView.ts +++ b/apps/web/src/reopenClosedView.ts @@ -164,6 +164,9 @@ export async function reopenClosedView( case "side-chat": panels.openSideChat(ref, surface.threadId); break; + case "linked-thread": + panels.openLinkedThread(ref, surface); + break; default: panels.open(ref, surface.kind); } diff --git a/apps/web/src/rightPanelStore.test.ts b/apps/web/src/rightPanelStore.test.ts index 3a6bd304863b0..39ac8336ce38c 100644 --- a/apps/web/src/rightPanelStore.test.ts +++ b/apps/web/src/rightPanelStore.test.ts @@ -1,8 +1,9 @@ import { scopeThreadRef } from "@t3tools/client-runtime/environment"; -import { type EnvironmentId, RunId, ThreadId } from "@t3tools/contracts"; +import { EnvironmentId, RunId, ThreadId } from "@t3tools/contracts"; import { beforeEach, describe, expect, it } from "vite-plus/test"; import { useClosedViewStore } from "./closedViewStore"; +import { linkedThreadTitle } from "./linkedThreadSurface"; import { reopenClosedView } from "./reopenClosedView"; import { hostRightPanel, @@ -517,6 +518,83 @@ describe("rightPanelStore", () => { expect(selectThreadRightPanelState(migrated.byThreadKey, refA).maximized).toBe(true); }); + it("opens a linked thread once per thread and environment it is read through", () => { + const store = useRightPanelStore.getState(); + const target = { + viaEnvironmentId: EnvironmentId.make("env-1"), + environmentId: EnvironmentId.make("env:b"), + threadId: ThreadId.make("there"), + label: "fs-17", + title: null, + }; + store.openLinkedThread(refA, target); + store.open(refA, "diff"); + store.openLinkedThread(refA, { ...target, label: "renamed", title: "Fix the build" }); + store.openLinkedThread(refA, { ...target, title: null }); + store.openLinkedThread(refA, { ...target, viaEnvironmentId: EnvironmentId.make("env-2") }); + const panel = selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, refA); + expect(panel.surfaces.map((surface) => surface.id)).toEqual([ + "linked-thread:env-1:env%3Ab:there", + "diff", + "linked-thread:env-2:env%3Ab:there", + ]); + // A click that knows no title keeps the one an earlier click or read gave. + expect(panel.surfaces[0]).toMatchObject({ label: "fs-17", title: "Fix the build" }); + store.setLinkedThreadTitle(refA, "linked-thread:env-1:env%3Ab:there", "Fix flaky test"); + expect( + selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, refA).surfaces[0], + ).toMatchObject({ title: "Fix flaky test" }); + // The tab is named for the thread once its title is known, else for where it is. + expect(linkedThreadTitle({ title: "Fix flaky test" }, "Thread on fs-17")).toBe( + "Fix flaky test", + ); + expect(linkedThreadTitle({ title: " " }, "Thread on fs-17")).toBe("Thread on fs-17"); + expect(linkedThreadTitle({ title: null }, "Thread on fs-17")).toBe("Thread on fs-17"); + }); + + it("keeps saved linked threads it can show and drops surfaces it cannot", () => { + const linked = { + id: "linked-thread:stale-id", + kind: "linked-thread", + viaEnvironmentId: "env-1", + environmentId: "env-b", + threadId: "there", + label: "fs-17", + }; + const migrated = migratePersistedRightPanelState({ + byThreadKey: { + "env-1:thread-A": { + isOpen: true, + activeSurfaceId: "linked-thread:stale-id", + surfaces: [ + linked, + { ...linked, id: "linked-thread:no-thread", threadId: undefined }, + { id: "hologram:1", kind: "hologram" }, + null, + { id: "diff", kind: "diff" }, + ], + }, + }, + }); + expect(selectThreadRightPanelState(migrated.byThreadKey, refA)).toEqual({ + isOpen: true, + // The saved id no longer names a surface, so the first one left is shown. + activeSurfaceId: "linked-thread:env-1:env-b:there", + surfaces: [ + { + id: "linked-thread:env-1:env-b:there", + kind: "linked-thread", + viaEnvironmentId: "env-1", + environmentId: "env-b", + threadId: "there", + label: "fs-17", + title: null, + }, + { id: "diff", kind: "diff" }, + ], + }); + }); + it("drops the legacy singleton terminal surface during migration", () => { expect( migratePersistedRightPanelState({ diff --git a/apps/web/src/rightPanelStore.ts b/apps/web/src/rightPanelStore.ts index da7ca64e01ce6..6b932ed4a46cf 100644 --- a/apps/web/src/rightPanelStore.ts +++ b/apps/web/src/rightPanelStore.ts @@ -11,6 +11,12 @@ import { createJSONStorage, persist } from "zustand/middleware"; import { useClosedViewStore } from "./closedViewStore"; import { m } from "./i18n/messages"; import { resolveStorage } from "./lib/storage"; +import type { LinkedThreadTarget } from "@t3tools/client-runtime/linked-thread"; +import { + decodeLinkedThreadSurface, + linkedThreadSurface, + type LinkedThreadSurface, +} from "./linkedThreadSurface"; import type { ThreadPanelPresentation } from "./rightPanelLayout"; import type { ChatFileAttachment } from "./types"; @@ -25,6 +31,7 @@ const RIGHT_PANEL_KINDS = [ "pull-requests", "issue", "side-chat", + "linked-thread", ] as const; export type RightPanelKind = (typeof RIGHT_PANEL_KINDS)[number]; @@ -96,7 +103,9 @@ export type RightPanelSurface = key: string; url?: string; } - | { id: `side-chat:${string}`; kind: "side-chat"; threadId: ThreadId }; + | { id: `side-chat:${string}`; kind: "side-chat"; threadId: ThreadId } + /** A linked environment's thread, read through `viaEnvironmentId`; it has no thread here. */ + | LinkedThreadSurface; const RIGHT_PANEL_STORAGE_KEY = "t3code:right-panel-state:v2"; const RIGHT_PANEL_STORAGE_VERSION = 15; @@ -154,9 +163,15 @@ interface RightPanelStoreState { ) => boolean; open: ( ref: ScopedThreadRef, - kind: Exclude, + kind: Exclude< + RightPanelKind, + "file" | "terminal" | "pull-request" | "issue" | "side-chat" | "linked-thread" + >, ) => void; openSideChat: (ref: ScopedThreadRef, threadId: ThreadId) => void; + openLinkedThread: (ref: ScopedThreadRef, target: LinkedThreadTarget) => void; + /** Records the title the linked environment gave, so the tab and a reopened one show it. */ + setLinkedThreadTitle: (ref: ScopedThreadRef, surfaceId: string, title: string) => void; openDevice: (ref: ScopedThreadRef, target: DeviceTabTarget, automatic?: boolean) => void; renameDevice: (ref: ScopedThreadRef, surfaceId: string, title: string) => void; openBrowser: (ref: ScopedThreadRef, tabId: string | null) => void; @@ -221,7 +236,10 @@ interface RightPanelStoreState { toggleVisibility: (ref: ScopedThreadRef) => void; toggle: ( ref: ScopedThreadRef, - kind: Exclude, + kind: Exclude< + RightPanelKind, + "file" | "terminal" | "pull-request" | "issue" | "side-chat" | "linked-thread" + >, ) => void; setThreadPanelOpen: ( ref: ScopedThreadRef, @@ -246,7 +264,7 @@ const DEFAULT_THREAD_PANEL_VISIBILITY: ThreadPanelVisibility = { const singletonSurface = ( kind: Exclude< RightPanelKind, - "file" | "preview" | "terminal" | "pull-request" | "issue" | "side-chat" + "file" | "preview" | "terminal" | "pull-request" | "issue" | "side-chat" | "linked-thread" >, ): RightPanelSurface => { switch (kind) { @@ -567,8 +585,14 @@ export function migratePersistedRightPanelState(persistedState: unknown): { threadState && typeof threadState === "object" ? threadState : null; const surfaces = Array.isArray(validThreadState?.surfaces) ? validThreadState.surfaces.flatMap((surface) => { + if (!surface || typeof surface !== "object") return []; const kind = (surface as { kind?: string }).kind; - if (kind === "plan" || kind === "agents") return []; + // Also drops kinds this build does not know, such as one a newer build saved. + if (!(RIGHT_PANEL_KINDS as ReadonlyArray).includes(kind)) return []; + if (surface.kind === "linked-thread") { + const decoded = decodeLinkedThreadSurface(surface); + return decoded === null ? [] : [decoded]; + } if ( (surface.kind === "file" || surface.kind === "files") && "folderTrail" in surface && @@ -822,6 +846,38 @@ export const useRightPanelStore = create()( upsertSurface(current, { id: `side-chat:${threadId}`, kind: "side-chat", threadId }), ), ), + openLinkedThread: (ref, target) => + set((state) => + userAction(state, scopedThreadKey(ref), (current) => { + const surface = linkedThreadSurface(target); + const next = upsertSurface(current, surface); + return { + ...next, + // A later click may know the title or label an earlier one did not. + surfaces: next.surfaces.map((entry) => + entry.id === surface.id && entry.kind === "linked-thread" + ? { ...surface, title: surface.title ?? entry.title } + : entry, + ), + }; + }), + ), + setLinkedThreadTitle: (ref, surfaceId, title) => + set((state) => { + const threadKey = scopedThreadKey(rightPanelHostRef(ref)); + const existing = state.byThreadKey[threadKey]?.surfaces.find( + (surface) => surface.id === surfaceId, + ); + if (existing?.kind !== "linked-thread" || existing.title === title) return state; + return automaticUpdate(state, threadKey, (current) => ({ + ...current, + surfaces: current.surfaces.map((surface) => + surface.id === surfaceId && surface.kind === "linked-thread" + ? { ...surface, title } + : surface, + ), + })); + }), renameDevice: (ref, surfaceId, title) => set((state) => userAction(state, scopedThreadKey(ref), (current) => ({ diff --git a/apps/web/src/state/linkedThreadView.ts b/apps/web/src/state/linkedThreadView.ts new file mode 100644 index 0000000000000..63145c73119d6 --- /dev/null +++ b/apps/web/src/state/linkedThreadView.ts @@ -0,0 +1,139 @@ +import { useAtomValue } from "@effect/atom-react"; +import { scopeThreadRef } from "@t3tools/client-runtime/environment"; +import { + type LinkedThreadOpen, + resolveLinkedThreadOpen, +} from "@t3tools/client-runtime/linked-thread"; +import type { EnvironmentId, ScopedThreadRef, ThreadId } from "@t3tools/contracts"; +import { useNavigate } from "@tanstack/react-router"; +import { AsyncResult, Atom } from "effect/reactivity"; + +import type { TurnItemSource } from "../components/chat/timelineRowContext"; +import { useRightPanelStore } from "../rightPanelStore"; +import type { LinkedThreadSurface } from "../linkedThreadSurface"; +import { buildThreadRouteParams } from "../threadRoutes"; +import { useEnvironment } from "./environments"; +import { peerLinkEnvironment, useLinkedEnvironments } from "./peerLinks"; +import { useEnvironmentQuery } from "./query"; + +/** + * How a click opens a thread that the thread `panelRef` says is on a linked environment: in place + * when this client is connected there itself, else as a read-only tab in that thread's right + * panel, read through its environment. Once the link is gone a saved environment opens in place, + * where the client can reconnect to it; with neither, the tab says what to link again. + */ +export function useLinkedThreadOpener( + panelRef: ScopedThreadRef, + thread: + | { + readonly environmentId: EnvironmentId; + readonly threadId: ThreadId; + readonly label: string; + } + | undefined, + title: string | null, +): { readonly mode: Exclude; readonly open: () => void } | null { + const navigate = useNavigate(); + const viaEnvironmentId = panelRef.environmentId; + const own = useEnvironment(thread?.environmentId ?? null); + const connected = own?.connection.phase === "connected"; + const links = useLinkedEnvironments(thread === undefined || connected ? null : viaEnvironmentId); + if (thread === undefined) return null; + const resolved = resolveLinkedThreadOpen({ + environmentId: thread.environmentId, + viaEnvironmentId, + own: own === null ? undefined : { connected }, + linked: links.has(thread.environmentId), + }); + const mode = resolved === "direct" ? "direct" : "linked"; + return { + mode, + open: () => { + if (mode === "linked") { + useRightPanelStore.getState().openLinkedThread(panelRef, { + viaEnvironmentId, + environmentId: thread.environmentId, + threadId: thread.threadId, + label: own?.label ?? thread.label, + title, + }); + return; + } + void navigate({ + to: "/$environmentId/$threadId", + params: buildThreadRouteParams(scopeThreadRef(thread.environmentId, thread.threadId)), + }); + }, + }; +} + +type TabKey = readonly [ + panelEnvironmentId: EnvironmentId, + panelThreadId: ThreadId, + surfaceId: string, + viaEnvironmentId: EnvironmentId, + environmentId: EnvironmentId, + threadId: ThreadId, +]; + +const targetOf = ( + surface: Pick, +) => ({ + environmentId: surface.viaEnvironmentId, + input: { environmentId: surface.environmentId, threadId: surface.threadId }, +}); + +/** One tab's subscription, which also keeps the tab's title to the thread's own. */ +const tabViewAtom = Atom.family((key: string) => { + const [panelEnvironmentId, panelThreadId, surfaceId, viaEnvironmentId, environmentId, threadId] = + JSON.parse(key) as TabKey; + const panelRef = scopeThreadRef(panelEnvironmentId, panelThreadId); + const view = peerLinkEnvironment.threadView( + targetOf({ viaEnvironmentId, environmentId, threadId }), + ); + return Atom.make((get) => { + const live = get(view); + const title = AsyncResult.getOrElse(live, () => null)?.thread.projection?.thread.title; + if (title) useRightPanelStore.getState().setLinkedThreadTitle(panelRef, surfaceId, title); + return live; + }).pipe(Atom.setIdleTTL(0), Atom.withLabel(`linked-thread-tab-view:${key}`)); +}); + +/** + * The thread of `surface`, streamed through the environment that links to it for the tab in + * `panelRef`'s panel. The stream runs only while `visible`; what it last showed stays. + */ +export function useLinkedThreadView( + panelRef: ScopedThreadRef, + surface: Pick, + visible: boolean, +) { + const key: TabKey = [ + panelRef.environmentId, + panelRef.threadId, + surface.id, + surface.viaEnvironmentId, + surface.environmentId, + surface.threadId, + ]; + const live = useEnvironmentQuery(visible ? tabViewAtom(JSON.stringify(key)) : null); + const view = useAtomValue(peerLinkEnvironment.lastThreadView(targetOf(surface))); + return { + view, + /** Why the stream is not running: it ended, or it waits to ask again. */ + error: live.failure ?? view?.error ?? null, + /** Asks again now. */ + retry: live.refresh, + }; +} + +/** Where a linked thread's expanded rows read an item in full: through the linking environment. */ +export const linkedThreadItemSource = ( + target: Pick, +): TurnItemSource => ({ + detail: (input) => + peerLinkEnvironment.threadItem({ + environmentId: target.viaEnvironmentId, + input: { environmentId: target.environmentId, ...input }, + }), +}); diff --git a/apps/web/src/state/peerLinks.ts b/apps/web/src/state/peerLinks.ts index b19276c6f88b5..624da1618672a 100644 --- a/apps/web/src/state/peerLinks.ts +++ b/apps/web/src/state/peerLinks.ts @@ -30,8 +30,7 @@ const offersNoLinksAtom = Atom.make(false).pipe(Atom.withLabel("peer-links:offer /** * The machines `environmentId` links to, by name, while it offers links, and none otherwise. - * Its agents can read threads there. Listing asks each linked machine whether it answers, so - * every caller shares one briefly cached list. + * Its agents can read threads there, and so can a client allowed to read threads on it. */ export function useLinkedEnvironments( environmentId: EnvironmentId | null, @@ -42,7 +41,7 @@ export function useLinkedEnvironments( const identities = useEnvironmentIdentities(); const links = useEnvironmentQuery( offered && environmentId !== null - ? peerLinkEnvironment.list({ environmentId, input: {} }) + ? peerLinkEnvironment.names({ environmentId, input: {} }) : null, ); return linkedEnvironmentNames({ diff --git a/docs/internals/environment-auth.md b/docs/internals/environment-auth.md index fac296343d37f..9d0ebabb48158 100644 --- a/docs/internals/environment-auth.md +++ b/docs/internals/environment-auth.md @@ -77,7 +77,9 @@ The result is an ordinary session with subject `mcp-client`. A read-only grant holds `orchestration:read` alone. On `/mcp` it passes only tools declared as reads in [McpToolAccess](../../apps/server/src/mcp/McpToolAccess.ts), where every tool must declare who may call it to compile. Any other grant adds -`orchestration:operate` and a signed ceiling. Only `/mcp` accepts these sessions. Every other HTTP and WebSocket +`orchestration:operate` and a signed ceiling. Only `/mcp` accepts these sessions, and for a +[peer link](remote.md#peer-links)'s session alone the thread routes in +[linkThreadHttp](../../apps/server/src/peer/linkThreadHttp.ts), which only read. Every other HTTP and WebSocket path rejects that subject, because the RPC surface would let the agent act above its ceiling. Inside MCP the credential sets the limits and tool parameters only pick targets; see diff --git a/docs/internals/remote.md b/docs/internals/remote.md index 5bb875f137eef..c4d52681cb606 100644 --- a/docs/internals/remote.md +++ b/docs/internals/remote.md @@ -115,6 +115,18 @@ Unlinking on the linking side only forgets the token. receiving `/mcp` sends nothing while a wait is open and T3 Connect's edge drops idle requests after about 100 s. +**A client reads a linked thread as the thread's own stream.** A client connected +only to the linking environment subscribes to `peerLinks.subscribeThread`; +[`PeerThreadRelay`](../../apps/server/src/peer/PeerThreadRelay.ts) opens the +receiving environment's +[link thread routes](../../apps/server/src/peer/linkThreadHttp.ts) with the +link's token and passes on the same stream items, history pages and item detail +the owner's client gets. Clients reduce and draw it like any thread, read-only, +so there is no second transcript format to keep in step. The relay holds one +upstream per subscription and nothing once the client stops listening. The +routes accept only a peer link's session, refuse browser origins as `/mcp` does, +and serve any access level, since each already reads threads through `/mcp`. + **Work a link paired below full access starts stays within that link.** The receiving environment knows a session is a peer link because the linking side registers its OAuth client with the `t3code-peer-link` software id, and the diff --git a/docs/user/remote-access.md b/docs/user/remote-access.md index 80fc00427c5de..1f6e221b3ebe5 100644 --- a/docs/user/remote-access.md +++ b/docs/user/remote-access.md @@ -477,6 +477,25 @@ ends, as for any delegated task. It keeps following the task across restarts. If the other machine revokes the link, or the link is removed here, the task fails with that reason. +### Read a linked machine's threads + +You can read a thread on a linked machine without connecting this app to it. Open +a task that was delegated there from the thread's agents, or a thread link that +points there, and the thread opens read-only, streamed through the machine you +are connected to over its link. It follows the thread live. On web and desktop +it opens as a tab in the right panel, beside the thread you are in, and shows +the same timeline as any other thread. + +- The view is marked **Read-only** with both machines' names. To reply, approve + or stop the thread, connect this app to that machine. +- Files, images and published visuals stay on that machine and do not load + here. A command's output shows as of when you open its row. +- If this app is already connected to that machine, the thread opens there as + usual instead. +- You need permission to read threads on the machine you are connected to, and + Linked environments must be on there. Both machines need a version of T3 Code + that has this view. + ## Manage or revoke access On the host, **Settings → Sharing & access** lets authorized administrators create diff --git a/packages/client-runtime/package.json b/packages/client-runtime/package.json index 182c28a319120..0663ee293e2e8 100644 --- a/packages/client-runtime/package.json +++ b/packages/client-runtime/package.json @@ -111,6 +111,10 @@ "types": "./src/linkRequest.ts", "default": "./src/linkRequest.ts" }, + "./linked-thread": { + "types": "./src/linkedThread.ts", + "default": "./src/linkedThread.ts" + }, "./scheduled-task-webhook": { "types": "./src/scheduledTaskWebhook.ts", "default": "./src/scheduledTaskWebhook.ts" @@ -263,6 +267,10 @@ "types": "./src/state/orchestration.ts", "default": "./src/state/orchestration.ts" }, + "./state/thread-stream": { + "types": "./src/state/threadStream.ts", + "default": "./src/state/threadStream.ts" + }, "./state/thread-history-merge": { "types": "./src/state/threadHistoryMerge.ts", "default": "./src/state/threadHistoryMerge.ts" diff --git a/packages/client-runtime/src/linkRequest.test.ts b/packages/client-runtime/src/linkRequest.test.ts index 6eef6f48679ec..70d33176a6873 100644 --- a/packages/client-runtime/src/linkRequest.test.ts +++ b/packages/client-runtime/src/linkRequest.test.ts @@ -339,16 +339,15 @@ describe("linkableMachines", () => { }); describe("linkedEnvironmentNames", () => { - it("names the unexpired links as this client does, else as the link does", () => { + it("names the links as this client does, else as the link does", () => { const vps = EnvironmentId.make("environment-vps"); const mini = EnvironmentId.make("environment-mini"); const unsaved = EnvironmentId.make("environment-unsaved"); expect( linkedEnvironmentNames({ links: [ - { environmentId: vps, label: "vps-01", status: "unreachable" }, - { environmentId: mini, label: "mini", status: "expired" }, - { environmentId: unsaved, label: "Office box", status: "reachable" }, + { environmentId: vps, label: "vps-01" }, + { environmentId: unsaved, label: "Office box" }, ], environments: [ { environmentId: vps, label: "Hetzner VPS" }, diff --git a/packages/client-runtime/src/linkRequest.ts b/packages/client-runtime/src/linkRequest.ts index 6b8322e0ebee8..93665fce42cbc 100644 --- a/packages/client-runtime/src/linkRequest.ts +++ b/packages/client-runtime/src/linkRequest.ts @@ -5,6 +5,7 @@ import { type EnvironmentMachineKind, type OrchestrationV2TurnItem, type PeerLinkRequestAnswerInput, + type PeerLinkName, type PeerLinkSummary, resolveEnvironmentMachineKind, type ServerConfig, @@ -27,11 +28,11 @@ export const offersLinkedEnvironments = ( config?.environment.capabilities.peerLinks === true && config.settings.linkedEnvironmentsEnabled; /** - * The machines an environment's agents can work on, by name: its links that have not - * expired, named as this client names them, else as the link does. + * The machines an environment's agents can work on, by name: its unexpired links (the server + * leaves out expired ones), named as this client names them, else as the link does. */ export function linkedEnvironmentNames(input: { - readonly links: ReadonlyArray>; + readonly links: ReadonlyArray; readonly environments: ReadonlyArray<{ readonly environmentId: EnvironmentId; readonly label: string; @@ -41,10 +42,8 @@ export function linkedEnvironmentNames(input: { input.environments.map((environment) => [environment.environmentId, environment.label]), ); return new Map( - input.links.flatMap((link) => - link.status === "expired" - ? [] - : [[link.environmentId, names.get(link.environmentId) ?? link.label] as const], + input.links.map( + (link) => [link.environmentId, names.get(link.environmentId) ?? link.label] as const, ), ); } diff --git a/packages/client-runtime/src/linkedThread.test.ts b/packages/client-runtime/src/linkedThread.test.ts new file mode 100644 index 0000000000000..694363d5c135a --- /dev/null +++ b/packages/client-runtime/src/linkedThread.test.ts @@ -0,0 +1,160 @@ +import { + EventId, + type OrchestrationV2ThreadHistoryPage, + type OrchestrationV2ThreadStreamItem, +} from "@t3tools/contracts"; +import { expect, it } from "@effect/vitest"; +import * as Effect from "effect/Effect"; +import * as Fiber from "effect/Fiber"; +import * as Queue from "effect/Queue"; +import * as Stream from "effect/Stream"; +import { TestClock } from "effect/testing"; + +import { + followLinkedThread, + keepLinkedThreadView, + LINKED_THREAD_RETRY_MS, + type LinkedThreadView, +} from "./linkedThread.ts"; +import { v2Now, v2Projection } from "./state/orchestrationV2TestFixtures.ts"; + +const snapshot = ( + snapshotSequence: number, + historyCursor: string | null = null, +): OrchestrationV2ThreadStreamItem => ({ + kind: "snapshot", + snapshotSequence, + projection: v2Projection, + historyCursor, + hasMoreHistory: historyCursor !== null, +}); + +const retitled = (sequence: number, title: string): OrchestrationV2ThreadStreamItem => ({ + kind: "event", + sequence, + event: { + id: EventId.make(`event:${sequence}`), + type: "thread.metadata-updated", + threadId: v2Projection.thread.id, + occurredAt: v2Now, + payload: { ...v2Projection.thread, title }, + }, +}); + +const failure = (reason: string) => ({ _tag: "PeerLinkThreadReadError", reason }); +const titleOf = (view: LinkedThreadView) => view.thread.projection?.thread.title ?? null; + +it.effect("keeps what it read while a linked environment is out of reach, and asks it again", () => + Effect.gen(function* () { + const attempts = [ + Stream.make(snapshot(1), retitled(2, "Renamed")).pipe( + Stream.concat(Stream.fail(failure("unreachable"))), + ), + Stream.make(snapshot(5)).pipe(Stream.concat(Stream.fail(failure("expired")))), + ]; + let opened = 0; + const views = yield* Queue.unbounded(); + const following = yield* followLinkedThread({ + items: Stream.suspend(() => attempts[opened++]!), + historyPage: () => Effect.die("unused"), + }).pipe( + Stream.runForEach((view) => Queue.offer(views, view)), + Effect.flip, + Effect.forkChild, + ); + + expect(titleOf(yield* Queue.take(views))).toBe(v2Projection.thread.title); + expect(titleOf(yield* Queue.take(views))).toBe("Renamed"); + // Out of reach: the thread stays as read, with the reason beside it. + const waiting = yield* Queue.take(views); + expect([titleOf(waiting), waiting.error]).toEqual(["Renamed", failure("unreachable")]); + expect(opened).toBe(1); + + yield* TestClock.adjust(LINKED_THREAD_RETRY_MS); + // It answers again: its snapshot replaces the thread and clears the reason. + const back = yield* Queue.take(views); + expect([titleOf(back), back.error, back.thread.sequence]).toEqual([ + v2Projection.thread.title, + null, + 5, + ]); + // A link that expired cannot come back by waiting, so the stream ends with it. + expect(yield* Fiber.join(following)).toEqual(failure("expired")); + expect(opened).toBe(2); + }), +); + +it.effect("keeps the thread a view showed while its reopened stream has read nothing", () => + Effect.gen(function* () { + const attempts = [ + Stream.make(snapshot(1, "cursor-1"), retitled(2, "Renamed")), + // The view closed and opened again while the linked environment was out of reach. + Stream.fail(failure("unreachable")), + Stream.make(snapshot(5)).pipe(Stream.concat(Stream.never)), + ]; + let opened = 0; + const follow = () => + followLinkedThread({ + items: Stream.suspend(() => attempts[opened++]!), + historyPage: () => Effect.die("unused"), + }); + let kept: LinkedThreadView | null = null; + yield* follow().pipe( + Stream.runForEach((view) => Effect.sync(() => (kept = keepLinkedThreadView(kept, view)))), + ); + + const views = yield* Queue.unbounded(); + yield* follow().pipe( + Stream.runForEach((view) => Queue.offer(views, keepLinkedThreadView(kept, view))), + Effect.forkScoped, + ); + const waiting = yield* Queue.take(views); + expect([titleOf(waiting), waiting.error]).toEqual(["Renamed", failure("unreachable")]); + // Earlier turns belong to a stream that is gone, so none are offered until one is back. + expect(waiting.thread.historyCursor).toBeNull(); + + yield* TestClock.adjust(LINKED_THREAD_RETRY_MS); + const back = yield* Queue.take(views); + expect([titleOf(back), back.error, back.thread.sequence]).toEqual([ + v2Projection.thread.title, + null, + 5, + ]); + }).pipe(Effect.scoped), +); + +it.effect("loads the turns before a snapshot's window once per request", () => + Effect.gen(function* () { + const asked: string[] = []; + const page: OrchestrationV2ThreadHistoryPage = { + snapshotSequence: 1, + items: [], + nextCursor: null, + hasMoreHistory: false, + }; + const views = yield* Queue.unbounded(); + yield* followLinkedThread({ + items: Stream.make(snapshot(1, "cursor-1")).pipe(Stream.concat(Stream.never)), + historyPage: (cursor) => + Effect.sync(() => { + asked.push(cursor); + return page; + }), + }).pipe( + Stream.runForEach((view) => Queue.offer(views, view)), + Effect.forkScoped, + ); + + const shown = yield* Queue.take(views); + expect(shown.thread.historyCursor).toBe("cursor-1"); + shown.loadEarlier(); + // A second tap while the page loads asks for nothing more. + shown.loadEarlier(); + expect((yield* Queue.take(views)).history).toEqual({ loading: true, failed: false }); + const loaded = yield* Queue.take(views); + expect([loaded.history.loading, loaded.thread.historyCursor]).toEqual([false, null]); + // Nothing is left to load. + loaded.loadEarlier(); + expect(asked).toEqual(["cursor-1"]); + }).pipe(Effect.scoped), +); diff --git a/packages/client-runtime/src/linkedThread.ts b/packages/client-runtime/src/linkedThread.ts new file mode 100644 index 0000000000000..a5316a99008b7 --- /dev/null +++ b/packages/client-runtime/src/linkedThread.ts @@ -0,0 +1,275 @@ +import type { + EnvironmentId, + OrchestrationV2ThreadHistoryPage, + OrchestrationV2ThreadProjection, + OrchestrationV2ThreadStreamItem, + ThreadId, +} from "@t3tools/contracts"; +import * as Effect from "effect/Effect"; +import * as Queue from "effect/Queue"; +import * as Stream from "effect/Stream"; +import { mFallback, msg } from "gt-i18n"; +import type { MFunctionType } from "gt-i18n/types"; + +import { + deriveRunlessWorkStartedAt, + deriveThreadStructureRuntime, +} from "./state/threadExecution.ts"; +import { + applyThreadHistoryPage, + applyThreadStreamItem, + initialThreadStreamState, + type ThreadStreamState, +} from "./state/threadStream.ts"; + +/** A thread on a linked environment, read through the environment that holds the link. */ +export interface LinkedThreadTarget { + /** The environment this client is connected to, which reads the thread over its link. */ + readonly viaEnvironmentId: EnvironmentId; + /** The linked environment the thread lives in. */ + readonly environmentId: EnvironmentId; + readonly threadId: ThreadId; + /** What to call the linked environment and the thread until the first page names them. */ + readonly label: string; + readonly title: string | null; +} + +export type LinkedThreadOpen = "direct" | "linked" | "unavailable"; + +/** + * How a client opens a thread on `environmentId` that a thread or link in `viaEnvironmentId` + * points at. A connection of the client's own always wins, since it can do more than read. Without + * one, the environment holding the link reads it. A saved environment that neither answers nor is + * linked still opens directly, where the client says it is offline. + */ +export function resolveLinkedThreadOpen(input: { + readonly environmentId: EnvironmentId; + readonly viaEnvironmentId: EnvironmentId; + /** The client's own saved connection to `environmentId`, when it has one. */ + readonly own: { readonly connected: boolean } | undefined; + /** Whether `viaEnvironmentId` holds a link to `environmentId`. */ + readonly linked: boolean; +}): LinkedThreadOpen { + if (input.environmentId === input.viaEnvironmentId) return "direct"; + if (input.own?.connected === true) return "direct"; + if (input.linked) return "linked"; + return input.own === undefined ? "unavailable" : "direct"; +} + +const hasStringField = (value: unknown, key: K): value is Record => + typeof value === "object" && + value !== null && + typeof (value as Record)[key] === "string"; + +/** Whether a failed read can succeed later with nothing changed: the linked environment was only out of reach. */ +const isLinkedThreadUnreachable = (error: unknown): boolean => + hasStringField(error, "_tag") && + error._tag === "PeerLinkThreadReadError" && + hasStringField(error, "reason") && + error.reason === "unreachable"; + +export interface LinkedThreadFailure { + readonly title: string; + readonly detail: string; + /** Whether reading again can succeed without the user changing something first. */ + readonly retryable: boolean; +} + +/** + * A failed read in the user's words. `via` and `label` name the two environments as the client + * knows them; the server's own label wins once it has answered with one. + */ +export function linkedThreadFailure( + error: unknown, + names: { readonly via: string; readonly label: string }, + resolve: MFunctionType = mFallback, +): LinkedThreadFailure { + const via = names.via; + const serverMessage = hasStringField(error, "message") ? error.message : ""; + if (!hasStringField(error, "_tag") || error._tag !== "PeerLinkThreadReadError") { + // An environment from before this read answers with an unknown method. + return { + title: resolve(msg("Could not read this thread through {via}", { via })), + detail: + serverMessage || + resolve(msg("{via} may need an update before it can read linked threads.", { via })), + retryable: true, + }; + } + const retryable = isLinkedThreadUnreachable(error); + const label = hasStringField(error, "label") ? error.label : names.label; + const reason = hasStringField(error, "reason") ? error.reason : ""; + switch (reason) { + case "disabled": + return { + title: resolve(msg("Linked environments is off on {via}", { via })), + detail: resolve( + msg( + "Turn it on in {via}'s Settings → Labs to read threads on the machines it links to.", + { + via, + }, + ), + ), + retryable, + }; + case "unknown_link": + return { + title: resolve(msg("{via} is no longer linked to {label}", { via, label })), + detail: resolve( + msg("Link it again in {via}'s Settings → Connections to read its threads from here.", { + via, + }), + ), + retryable, + }; + case "expired": + return { + title: resolve(msg("The link from {via} to {label} expired", { via, label })), + detail: resolve( + msg("Link it again in {via}'s Settings → Connections with a new pairing code.", { via }), + ), + retryable, + }; + case "rejected": + return { + title: resolve(msg("{label} refused the read", { label })), + detail: serverMessage, + retryable, + }; + case "thread_not_found": + return { + title: resolve(msg("This thread is no longer on {label}", { label })), + detail: resolve(msg("It may have been deleted there.")), + retryable, + }; + case "incompatible": + return { + title: resolve(msg("{label} needs an update", { label })), + detail: serverMessage, + retryable, + }; + default: + return { + title: resolve(msg("{label} is not answering {via}", { label, via })), + detail: serverMessage, + retryable, + }; + } +} + +const WORKING_STATUSES = new Set(["preparing", "queued", "starting", "running", "waiting"]); + +/** Whether the thread has work under way, for the note that stands where its composer would. */ +export function isLinkedThreadWorking(projection: OrchestrationV2ThreadProjection): boolean { + return ( + WORKING_STATUSES.has(deriveThreadStructureRuntime(projection)?.status ?? "") || + deriveRunlessWorkStartedAt(projection) !== null + ); +} + +/** How long a view waits before asking again for a thread whose environment did not answer. */ +export const LINKED_THREAD_RETRY_MS = 15_000; + +/** A linked thread as its view holds it: the thread's own stream, reduced as any thread's is. */ +export interface LinkedThreadView { + readonly thread: ThreadStreamState; + /** Why the stream stopped, while the view waits to ask again; the next item clears it. */ + readonly error: unknown; + readonly history: { readonly loading: boolean; readonly failed: boolean }; + /** Loads the turns before the ones shown. Does nothing while a page loads or none is left. */ + readonly loadEarlier: () => void; +} + +/** + * What a view keeps once its stream shows `next`. A stream that was opened again has read nothing + * until its snapshot arrives, so the thread read before stays, with the new stream's state beside + * it. Its earlier turns load again only once that stream has a thread of its own to add them to. + */ +export const keepLinkedThreadView = ( + kept: LinkedThreadView | null, + next: LinkedThreadView, +): LinkedThreadView => + next.thread.projection !== null || kept === null || kept.thread.projection === null + ? next + : { ...next, thread: { ...kept.thread, historyCursor: null } }; + +/** + * Follows a linked environment's thread for as long as something consumes the result. The thread + * is built from the same stream items and with the same reducer as a guest page's, and older + * turns load through the same cursor. A linked environment that stops answering is asked again + * after a wait, with what was read kept; any other failure ends the stream. + */ +export const followLinkedThread = (source: { + readonly items: Stream.Stream; + readonly historyPage: (cursor: string) => Effect.Effect; +}): Stream.Stream => + Stream.unwrap( + Effect.gen(function* () { + const requests = yield* Queue.unbounded(); + let requested = false; + // Both halves below run one step at a time, so each reads the view the other left. + let view: LinkedThreadView = { + thread: initialThreadStreamState, + error: null, + history: { loading: false, failed: false }, + loadEarlier: () => { + if (requested || view.thread.historyCursor === null) return; + requested = true; + Queue.offerUnsafe(requests, undefined); + }, + }; + const show = (patch: Partial) => { + view = { ...view, ...patch }; + return view; + }; + const attempt = (): Stream.Stream => + source.items.pipe( + Stream.map((item) => + show({ thread: applyThreadStreamItem(view.thread, item), error: null }), + ), + Stream.catch((error) => + isLinkedThreadUnreachable(error) + ? Stream.make(show({ error })).pipe( + Stream.concat( + Stream.unwrap(Effect.sleep(LINKED_THREAD_RETRY_MS).pipe(Effect.map(attempt))), + ), + ) + : Stream.fail(error), + ), + ); + const earlier = Stream.fromQueue(requests).pipe( + Stream.flatMap(() => + Stream.suspend(() => { + const cursor = view.thread.historyCursor; + if (cursor === null) { + requested = false; + return Stream.empty; + } + return Stream.make(show({ history: { loading: true, failed: false } })).pipe( + Stream.concat( + Stream.fromEffect( + source.historyPage(cursor).pipe( + Effect.match({ + onSuccess: (page) => + show({ + thread: applyThreadHistoryPage(view.thread, cursor, page), + history: { loading: false, failed: false }, + }), + onFailure: () => show({ history: { loading: false, failed: true } }), + }), + Effect.ensuring( + Effect.sync(() => { + requested = false; + }), + ), + ), + ), + ), + ); + }), + ), + ); + return Stream.merge(attempt(), earlier, { haltStrategy: "left" }); + }), + ); diff --git a/packages/client-runtime/src/rpc/client.ts b/packages/client-runtime/src/rpc/client.ts index 7c8f06cb1f083..11588aa329ee0 100644 --- a/packages/client-runtime/src/rpc/client.ts +++ b/packages/client-runtime/src/rpc/client.ts @@ -63,6 +63,7 @@ export type EnvironmentSubscriptionRpcTag = | typeof WS_METHODS.providerInstallSubscribe | typeof ORCHESTRATION_V2_WS_METHODS.subscribeShell | typeof ORCHESTRATION_V2_WS_METHODS.subscribeThread + | typeof WS_METHODS.peerLinksSubscribeThread | typeof ORCHESTRATION_V2_WS_METHODS.subscribeCommandOutput | typeof ORCHESTRATION_V2_WS_METHODS.subscribePromptSuggestion | typeof ORCHESTRATION_V2_WS_METHODS.searchThreadStream diff --git a/packages/client-runtime/src/state/peerLinks.ts b/packages/client-runtime/src/state/peerLinks.ts index 9b355e29085ed..fe6579d9d0c75 100644 --- a/packages/client-runtime/src/state/peerLinks.ts +++ b/packages/client-runtime/src/state/peerLinks.ts @@ -1,11 +1,38 @@ -import { type PeerLinkSummary, WS_METHODS } from "@t3tools/contracts"; +import { + type EnvironmentId, + type PeerLinkSummary, + type PeerLinkThreadInput, + WS_METHODS, +} from "@t3tools/contracts"; import * as DateTime from "effect/DateTime"; import * as Duration from "effect/Duration"; import * as Effect from "effect/Effect"; -import { Atom } from "effect/reactivity"; +import { AsyncResult, Atom, type AtomRegistry } from "effect/reactivity"; import type { EnvironmentRegistry } from "../connection/registry.ts"; -import { createEnvironmentRpcCommand, createEnvironmentRpcQueryAtomFamily } from "./runtime.ts"; +import { + followLinkedThread, + keepLinkedThreadView, + type LinkedThreadView, +} from "../linkedThread.ts"; +import { request, subscribe } from "../rpc/client.ts"; +import { + createEnvironmentRpcCommand, + createEnvironmentRpcQueryAtomFamily, + createEnvironmentSubscriptionAtomFamily, +} from "./runtime.ts"; + +/** The environment a client reads through, and the linked environment's thread it reads. */ +export interface LinkedThreadViewTarget { + readonly environmentId: EnvironmentId; + readonly input: PeerLinkThreadInput; +} + +const threadViewKey = ({ environmentId, input }: LinkedThreadViewTarget) => + JSON.stringify({ + environmentId, + input: { environmentId: input.environmentId, threadId: input.threadId }, + }); export function createPeerLinkEnvironmentAtoms( runtime: Atom.AtomRuntime, @@ -16,13 +43,59 @@ export function createPeerLinkEnvironmentAtoms( // Listing probes every linked environment, so a list stays fresh briefly. staleTimeMs: 10_000, }); + // Names only, for opening linked threads with thread read access; it probes nothing. + const names = createEnvironmentRpcQueryAtomFamily(runtime, { + label: "environment-data:peer-links:names", + tag: WS_METHODS.peerLinksNames, + staleTimeMs: 10_000, + }); + const refreshLinks = (registry: AtomRegistry.AtomRegistry, environmentId: EnvironmentId) => + Effect.sync(() => { + registry.refresh(list({ environmentId, input: {} })); + registry.refresh(names({ environmentId, input: {} })); + }); + const threadStream = createEnvironmentSubscriptionAtomFamily(runtime, { + label: "environment-data:peer-links:thread-stream", + idleTtlMs: 0, + subscribe: (input: PeerLinkThreadInput) => + followLinkedThread({ + items: subscribe(WS_METHODS.peerLinksSubscribeThread, input), + historyPage: (cursor) => + request(WS_METHODS.peerLinksThreadHistoryPage, { ...input, cursor }), + }), + }); + /** + * What a view of the thread last showed. It outlives the subscription for a while, so coming + * back to the view shows the thread at once while the stream starts again. + */ + const lastThreadView = Atom.family((key: string) => + Atom.make(null).pipe( + Atom.setIdleTTL(5 * 60_000), + Atom.withLabel(`environment-data:peer-links:last-thread-view:${key}`), + ), + ); + /** + * A linked environment's thread, streamed while a view reads it. The subscription ends with its + * last reader, which closes the stream at the linked environment too. + */ + const threadView = Atom.family((key: string) => { + const stream = threadStream(JSON.parse(key) as LinkedThreadViewTarget); + return Atom.make((get) => { + const live = get(stream); + if (AsyncResult.isSuccess(live)) { + const kept = lastThreadView(key); + get.set(kept, keepLinkedThreadView(get.once(kept), live.value)); + } + return live; + }).pipe(Atom.setIdleTTL(0), Atom.withLabel(`environment-data:peer-links:thread-view:${key}`)); + }); return { list, + names, link: createEnvironmentRpcCommand(runtime, { label: "environment-data:peer-links:link", tag: WS_METHODS.peerLinksLink, - onSuccess: ({ environmentId }, registry) => - Effect.sync(() => registry.refresh(list({ environmentId, input: {} }))), + onSuccess: ({ environmentId }, registry) => refreshLinks(registry, environmentId), }), // Leaves the list alone: a batch refreshes it once, when it ends (`runLinkBatch`). linkInBatch: createEnvironmentRpcCommand(runtime, { @@ -32,8 +105,15 @@ export function createPeerLinkEnvironmentAtoms( unlink: createEnvironmentRpcCommand(runtime, { label: "environment-data:peer-links:unlink", tag: WS_METHODS.peerLinksUnlink, - onSuccess: ({ environmentId }, registry) => - Effect.sync(() => registry.refresh(list({ environmentId, input: {} }))), + onSuccess: ({ environmentId }, registry) => refreshLinks(registry, environmentId), + }), + threadView: (target: LinkedThreadViewTarget) => threadView(threadViewKey(target)), + lastThreadView: (target: LinkedThreadViewTarget) => lastThreadView(threadViewKey(target)), + /** One item of a linked environment's thread in full, for a row the reader opened. */ + threadItem: createEnvironmentRpcQueryAtomFamily(runtime, { + label: "environment-data:peer-links:thread-item", + tag: WS_METHODS.peerLinksThreadItem, + idleTtlMs: 0, }), // An agent's link card. One answer per card at a time. answerRequest: createEnvironmentRpcCommand(runtime, { @@ -44,8 +124,7 @@ export function createPeerLinkEnvironmentAtoms( key: ({ environmentId, input }) => JSON.stringify([environmentId, input.threadId, input.turnItemId]), }, - onSuccess: ({ environmentId }, registry) => - Effect.sync(() => registry.refresh(list({ environmentId, input: {} }))), + onSuccess: ({ environmentId }, registry) => refreshLinks(registry, environmentId), }), }; } diff --git a/packages/client-runtime/src/state/threadStream.ts b/packages/client-runtime/src/state/threadStream.ts new file mode 100644 index 0000000000000..b723a99885aad --- /dev/null +++ b/packages/client-runtime/src/state/threadStream.ts @@ -0,0 +1,94 @@ +import type { + OrchestrationV2ThreadHistoryPage, + OrchestrationV2ThreadProjection, + OrchestrationV2ThreadStreamItem, +} from "@t3tools/contracts"; +import { boundedSnapshotProjection } from "@t3tools/shared/orchestrationV2BoundedSnapshot"; + +import { applyOrchestrationV2ProjectionEvent } from "./orchestrationV2Projection.ts"; +import { + mergeOlderHistoryIntoProjection, + mergeOlderSubagentsIntoProjection, +} from "./threadHistoryMerge.ts"; + +/** + * A thread built from its stream alone, for a view with no environment connection of its own to + * the thread: a guest page, or a linked environment's thread read through the link. + */ +export interface ThreadStreamState { + /** The thread as the owner's client holds it, built with the same reducer. */ + readonly projection: OrchestrationV2ThreadProjection | null; + readonly sequence: number; + /** Set while the snapshot is a window of a longer history, as the owner's client tracks it. */ + readonly partial: { readonly latestLocalTurnOrdinal: number | null } | null; + /** Where "Load earlier turns" continues, or null once the whole thread is loaded. */ + readonly historyCursor: string | null; +} + +export const initialThreadStreamState: ThreadStreamState = { + projection: null, + sequence: 0, + partial: null, + historyCursor: null, +}; + +/** + * Applies the owner's thread stream the way the owner's client does (see EnvironmentThreadState): + * a snapshot replaces the thread, and later events pass through the same projection reducer, once + * each. + */ +export function applyThreadStreamItem( + state: ThreadStreamState, + item: OrchestrationV2ThreadStreamItem, +): ThreadStreamState { + if (item.kind === "snapshot") { + return { + projection: boundedSnapshotProjection(item), + sequence: item.snapshotSequence, + partial: + item.hasMoreHistory === true || (item.historyCursor ?? null) !== null + ? { latestLocalTurnOrdinal: item.latestLocalTurnOrdinal ?? null } + : null, + historyCursor: item.hasMoreHistory === true ? (item.historyCursor ?? null) : null, + }; + } + if (item.kind === "synchronized" || item.sequence <= state.sequence) return state; + if (item.kind === "unknown-event") return { ...state, sequence: item.sequence }; + const projection = + applyOrchestrationV2ProjectionEvent( + state.projection, + item.event, + state.partial === null ? undefined : { partialTimeline: true, ...state.partial }, + ) ?? state.projection; + const turnItem = item.event.type === "turn-item.updated" ? item.event.payload : null; + const watermark = state.partial?.latestLocalTurnOrdinal ?? null; + return { + ...state, + projection, + sequence: item.sequence, + partial: + state.partial !== null && + turnItem !== null && + (watermark === null || turnItem.ordinal > watermark) + ? { latestLocalTurnOrdinal: turnItem.ordinal } + : state.partial, + }; +} + +/** Merges a page of older turns, fetched from `cursor`, in front, as in the owner's view. */ +export function applyThreadHistoryPage( + state: ThreadStreamState, + cursor: string, + page: OrchestrationV2ThreadHistoryPage, +): ThreadStreamState { + // A snapshot since the request replaced the thread and its cursor. + if (state.projection === null || state.historyCursor !== cursor) return state; + return { + ...state, + projection: mergeOlderSubagentsIntoProjection( + mergeOlderHistoryIntoProjection(state.projection, page.items), + page.subagents, + ), + historyCursor: page.hasMoreHistory ? page.nextCursor : null, + }; +} diff --git a/packages/contracts/src/environment.ts b/packages/contracts/src/environment.ts index a7316a9f0482d..b1a4c9ea18fcd 100644 --- a/packages/contracts/src/environment.ts +++ b/packages/contracts/src/environment.ts @@ -188,6 +188,9 @@ export const ExecutionEnvironmentCapabilities = Schema.Struct({ (`linkOrigin`). Another environment links to this one only when it is set, since without it that work could change the user's own threads. */ linkFence: Schema.optionalKey(Schema.Boolean), + /** Serves a thread's stream, history pages and item detail to a link's session + (`PEER_LINK_THREAD_STREAM_ROUTE`), so a client of the linking environment can read it. */ + linkThreadStream: Schema.optionalKey(Schema.Boolean), /** Mints pairing codes that approve one agent sign-in at a set level (`AUTO-…`). */ mcpApprovalCodes: Schema.optionalKey(Schema.Boolean), peerLinkPairingCodes: Schema.optionalKey(Schema.Boolean), diff --git a/packages/contracts/src/peerLink.ts b/packages/contracts/src/peerLink.ts index 0d72b978e2609..bf25a34e07cf7 100644 --- a/packages/contracts/src/peerLink.ts +++ b/packages/contracts/src/peerLink.ts @@ -32,6 +32,16 @@ export const PeerLinkSummary = Schema.Struct({ }); export type PeerLinkSummary = typeof PeerLinkSummary.Type; +/** + * A link's name only, for a client that may read threads here but not manage access: enough to + * name and open a linked environment's threads, without its addresses, access or health. + */ +export const PeerLinkName = Schema.Struct({ + environmentId: EnvironmentId, + label: Schema.String, +}); +export type PeerLinkName = typeof PeerLinkName.Type; + export const PeerLinkCreateInput = Schema.Struct({ /** Where the peer answers: an https, Tailscale, LAN or loopback base URL. */ url: TrimmedNonEmptyString, @@ -89,6 +99,63 @@ export const peerLinkFailureKind = ( ? "code_refused" : "other"; +/** + * Where an environment serves one of its threads to an environment linked to it, signed in with + * the link's own session as on `/mcp`. The stream carries the same items the owner's thread + * subscription does; history pages and item detail are the owner's too. + */ +const PEER_LINK_THREAD_ROUTE_PREFIX = "/api/links/thread"; +export const PEER_LINK_THREAD_STREAM_ROUTE = `${PEER_LINK_THREAD_ROUTE_PREFIX}/stream`; +export const PEER_LINK_THREAD_HISTORY_ROUTE = `${PEER_LINK_THREAD_ROUTE_PREFIX}/history`; +export const PEER_LINK_THREAD_ITEM_ROUTE = `${PEER_LINK_THREAD_ROUTE_PREFIX}/item`; + +/** A thread on a linked environment, as a client of this environment names it. */ +export const PeerLinkThreadInput = Schema.Struct({ + /** The linked environment the thread lives in. */ + environmentId: EnvironmentId, + threadId: ThreadId, +}); +export type PeerLinkThreadInput = typeof PeerLinkThreadInput.Type; + +export const PeerLinkThreadHistoryInput = Schema.Struct({ + ...PeerLinkThreadInput.fields, + /** The `historyCursor` of the snapshot or of the page before. */ + cursor: TrimmedNonEmptyString, +}); +export type PeerLinkThreadHistoryInput = typeof PeerLinkThreadHistoryInput.Type; + +export const PeerLinkThreadItemInput = Schema.Struct({ + ...PeerLinkThreadInput.fields, + itemId: TurnItemId, + /** Unused by the server; a client keys its cache on it, as for its own threads' items. */ + revision: Schema.optional(Schema.String), +}); +export type PeerLinkThreadItemInput = typeof PeerLinkThreadItemInput.Type; + +/** Why a linked environment's thread could not be read, with the reason in words. */ +export class PeerLinkThreadReadError extends Schema.TaggedError()( + "PeerLinkThreadReadError", + { + reason: Schema.Literals([ + /** Linked environments is off here. */ + "disabled", + "unknown_link", + "expired", + /** The linked environment no longer accepts the link, or refuses the read. */ + "rejected", + "unreachable", + "thread_not_found", + /** The linked environment runs a version that does not serve its threads to a link. */ + "incompatible", + ]), + /** What this environment calls the linked one, when it still has the link. */ + label: Schema.NullOr(Schema.String), + message: Schema.String, + /** The failure underneath, when the read got as far as the link or the linked environment. */ + cause: Schema.optionalKey(Schema.Defect()), + }, +) {} + /** * The user's answer to an agent asking to link an environment. The pairing * code is used once to link and is never recorded; the thread learns only the diff --git a/packages/contracts/src/rpc.ts b/packages/contracts/src/rpc.ts index 41733dae56417..371228eed134d 100644 --- a/packages/contracts/src/rpc.ts +++ b/packages/contracts/src/rpc.ts @@ -20,11 +20,16 @@ import { PeerLink, PeerLinkCreateInput, PeerLinkError, + PeerLinkName, PeerLinkRemoveInput, PeerLinkRemoveResult, PeerLinkRequestAnswerInput, PeerLinkRequestError, PeerLinkSummary, + PeerLinkThreadHistoryInput, + PeerLinkThreadInput, + PeerLinkThreadItemInput, + PeerLinkThreadReadError, } from "./peerLink.ts"; import { ChatGptReconnectProfileInput, @@ -260,6 +265,7 @@ import { OrchestrationV2CommandOutputError, OrchestrationV2GetThreadProjectionError, OrchestrationV2RpcSchemas, + OrchestrationV2ThreadHistoryPage, OrchestrationV2ThreadLaunchError, } from "./orchestrationV2.ts"; import { @@ -546,9 +552,13 @@ export const WS_METHODS = { serverGetDatabaseStorage: "server.getDatabaseStorage", serverReclaimDatabaseSpace: "server.reclaimDatabaseSpace", peerLinksList: "peerLinks.list", + peerLinksNames: "peerLinks.names", peerLinksLink: "peerLinks.link", peerLinksUnlink: "peerLinks.unlink", peerLinksAnswerRequest: "peerLinks.answerRequest", + peerLinksSubscribeThread: "peerLinks.subscribeThread", + peerLinksThreadHistoryPage: "peerLinks.threadHistoryPage", + peerLinksThreadItem: "peerLinks.threadItem", serverGetSettings: "server.getSettings", serverUpdateSettings: "server.updateSettings", serverDiscoverSourceControl: "server.discoverSourceControl", @@ -890,6 +900,13 @@ const WsPeerLinksListRpc = Rpc.make(WS_METHODS.peerLinksList, { error: Schema.Union([PeerLinkError, EnvironmentAuthorizationError]), }); +/** The unexpired links' names, readable with thread read access. */ +const WsPeerLinksNamesRpc = Rpc.make(WS_METHODS.peerLinksNames, { + payload: Schema.Struct({}), + success: Schema.Struct({ links: Schema.Array(PeerLinkName) }), + error: Schema.Union([PeerLinkError, EnvironmentAuthorizationError]), +}); + const WsPeerLinksLinkRpc = Rpc.make(WS_METHODS.peerLinksLink, { payload: PeerLinkCreateInput, success: PeerLink, @@ -902,6 +919,26 @@ const WsPeerLinksUnlinkRpc = Rpc.make(WS_METHODS.peerLinksUnlink, { error: Schema.Union([PeerLinkError, EnvironmentAuthorizationError]), }); +/** A linked environment's thread, as its own thread subscription streams it. */ +const WsPeerLinksSubscribeThreadRpc = Rpc.make(WS_METHODS.peerLinksSubscribeThread, { + payload: PeerLinkThreadInput, + success: OrchestrationV2RpcSchemas.subscribeThread.output, + error: Schema.Union([PeerLinkThreadReadError, EnvironmentAuthorizationError]), + stream: true, +}); + +const WsPeerLinksThreadHistoryPageRpc = Rpc.make(WS_METHODS.peerLinksThreadHistoryPage, { + payload: PeerLinkThreadHistoryInput, + success: OrchestrationV2ThreadHistoryPage, + error: Schema.Union([PeerLinkThreadReadError, EnvironmentAuthorizationError]), +}); + +const WsPeerLinksThreadItemRpc = Rpc.make(WS_METHODS.peerLinksThreadItem, { + payload: PeerLinkThreadItemInput, + success: OrchestrationV2RpcSchemas.getTurnItem.output, + error: Schema.Union([PeerLinkThreadReadError, EnvironmentAuthorizationError]), +}); + const WsPeerLinksAnswerRequestRpc = Rpc.make(WS_METHODS.peerLinksAnswerRequest, { payload: PeerLinkRequestAnswerInput, error: Schema.Union([PeerLinkRequestError, EnvironmentAuthorizationError]), @@ -2302,9 +2339,13 @@ export const WsRpcGroup = RpcGroup.make( WsServerReclaimDatabaseSpaceRpc, WsServerUpdateSettingsRpc, WsPeerLinksListRpc, + WsPeerLinksNamesRpc, WsPeerLinksLinkRpc, WsPeerLinksUnlinkRpc, WsPeerLinksAnswerRequestRpc, + WsPeerLinksSubscribeThreadRpc, + WsPeerLinksThreadHistoryPageRpc, + WsPeerLinksThreadItemRpc, WsServerDiscoverSourceControlRpc, WsServerCheckSecretSourceRpc, WsServerSearchAcpRegistryRpc, diff --git a/packages/shared/src/threadLinksCopy.ts b/packages/shared/src/threadLinksCopy.ts index 3b7480992b7e4..e4e452a43ca2b 100644 --- a/packages/shared/src/threadLinksCopy.ts +++ b/packages/shared/src/threadLinksCopy.ts @@ -28,12 +28,12 @@ export function unknownThreadLinkLabel( export function relabelThreadLinks( markdown: string, messageEnvironmentId: EnvironmentId, - title: (ref: ScopedThreadRef) => string | undefined, + title: (ref: ScopedThreadRef, label: string | undefined) => string | undefined, resolve: MFunctionType = mFallback, ): string { return replaceThreadLinks(markdown, (written, label) => { for (const ref of threadLinkCandidates(written, messageEnvironmentId)) { - const current = title(ref); + const current = title(ref, label); if (current === undefined) continue; return formatThreadLink( { environmentId: written.environmentId, threadId: ref.threadId },