Skip to content

Commit 30654b3

Browse files
t3dotggclaude
andauthored
feat: tag threads and hide tagged threads while recording (#29053)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent ab8e488 commit 30654b3

47 files changed

Lines changed: 876 additions & 53 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/mobile/src/features/archive/useArchivedThreadSnapshots.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { useMemo } from "react";
99

1010
import { appAtomRegistry } from "../../state/atom-registry";
1111
import { orchestrationEnvironment } from "../../state/orchestration";
12+
import { serverEnvironment } from "../../state/server";
13+
import { environmentThreadShells } from "../../state/threads";
1214

1315
function archivedSnapshotAtom(environmentId: EnvironmentId) {
1416
return orchestrationEnvironment.archivedShellSnapshot({
@@ -19,6 +21,10 @@ function archivedSnapshotAtom(environmentId: EnvironmentId) {
1921

2022
const archivedSnapshotsAtom = createArchivedThreadSnapshotsAtomFamily({
2123
getSnapshotAtom: archivedSnapshotAtom,
24+
hiddenThreadTagsAtom: serverEnvironment.hiddenThreadTagsAtom,
25+
hiddenThreadKeysAtom: environmentThreadShells.hiddenThreadKeysAtom,
26+
liveThreadRefsAtom: environmentThreadShells.threadRefsAtom,
27+
anyEnvironmentHidingAtom: environmentThreadShells.anyEnvironmentHidingAtom,
2228
labelPrefix: "mobile:archived-thread-snapshots",
2329
});
2430

‎apps/mobile/src/features/keyboard/CommandPalette.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import {
4646
useProjects,
4747
useServerConfigs,
4848
useThreadShell,
49-
useThreadShells,
49+
useVisibleThreadShells,
5050
} from "../../state/entities";
5151
import { useThreadSearch } from "../../state/queries";
5252
import { requestThreadMessageJump } from "../threads/threadMessageJump";
@@ -226,7 +226,7 @@ export function CommandPalette(props: {
226226
const selectDetail = useSelectWorkspaceDetail();
227227
const runCommand = props.onCommand;
228228
const projects = useProjects();
229-
const threads = useThreadShells();
229+
const threads = useVisibleThreadShells();
230230
const activeThreadRef = parseActiveThreadPath(props.pathname);
231231
const activeThread = useThreadShell(activeThreadRef);
232232
const visitThread = useAtomCommand(threadEnvironment.visit, { reportFailure: false });

‎apps/mobile/src/features/pull-requests/usePullRequestThreads.ts‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { useAtomValue } from "@effect/atom-react";
2+
import { visibleLinkedThreads } from "@t3tools/client-runtime/state/threads";
13
import { AsyncResult } from "effect/reactivity";
24
import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
35
import * as Dialog from "../../components/ui/Dialog";
@@ -27,6 +29,7 @@ import { uuidv4 } from "../../lib/uuid";
2729
import { useEnvironmentServerConfig } from "../../state/entities";
2830
import { composerPullRequests } from "../../state/pull-requests";
2931
import { useEnvironmentQuery } from "../../state/query";
32+
import { environmentThreadShells } from "../../state/threads";
3033
import { useEnvironmentScope } from "../../state/session";
3134
import {
3235
createNewTaskDraft,
@@ -69,8 +72,18 @@ export function usePullRequestThreads(
6972
const [lastRelations, setLastRelations] = useState({ key, data: relations.data });
7073
if (relations.data && (lastRelations.key !== key || relations.data !== lastRelations.data))
7174
setLastRelations({ key, data: relations.data });
72-
const threads =
73-
(relations.data ?? (lastRelations.key === key ? lastRelations.data : null))?.threads ?? [];
75+
const hiddenKeys = useAtomValue(environmentThreadShells.hiddenThreadKeysAtom);
76+
const hidingAnywhere = useAtomValue(environmentThreadShells.anyEnvironmentHidingAtom);
77+
const loadedThreadRefs = useAtomValue(
78+
environmentThreadShells.environmentThreadRefsAtom(target.environmentId),
79+
);
80+
const threads = visibleLinkedThreads(
81+
(relations.data ?? (lastRelations.key === key ? lastRelations.data : null))?.threads ?? [],
82+
target.environmentId,
83+
loadedThreadRefs,
84+
hiddenKeys,
85+
hidingAnywhere,
86+
);
7487
const connected = usePullRequestConnected(params.environmentId);
7588
const canOperate = useEnvironmentScope(target.environmentId, AuthOrchestrationOperateScope);
7689
const canAsk = !connected || canOperate;

‎apps/mobile/src/features/threads/ThreadComposer.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ import {
6565
} from "../../state/use-composer-drafts";
6666
import { appAtomRegistry } from "../../state/atom-registry";
6767
import type { ComposerDocumentAttachment } from "../../lib/composerContext";
68-
import { useProject, useThreadShells } from "../../state/entities";
68+
import { useProject, useVisibleThreadShells } from "../../state/entities";
6969
import { useMentionableEnvironments } from "../../state/environments";
7070
import { useLinkedEnvironments } from "../../state/peerLinks";
7171
import { scopeProjectRef } from "@t3tools/client-runtime/environment";
@@ -539,7 +539,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
539539
draftMessage: draftMessage,
540540
ownerKey: composerDraftKey,
541541
environmentId: props.environmentId,
542-
threadShells: useThreadShells(),
542+
threadShells: useVisibleThreadShells(),
543543
environments: offersLinkedEnvironments(props.serverConfig)
544544
? mentionableEnvironments
545545
: NO_MACHINES,

‎apps/mobile/src/state/composer-attachment-uploads.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ vi.mock("./entities", () => ({
9999
useProjects: () => [],
100100
useServerConfigs: () => new Map([["environment-1", config]]),
101101
useThreadShells: () => [],
102+
useVisibleThreadShells: () => [],
102103
}));
103104
vi.mock("./projects", () => ({ environmentProjects: {} }));
104105
vi.mock("./workspace", () => ({ workspaceConnections: {} }));

‎apps/mobile/src/state/entities.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ export function useThreadShells(): ReadonlyArray<EnvironmentThreadShell> {
173173
return useAtomValue(environmentThreadShells.threadShellsAtom);
174174
}
175175

176+
/** Thread shells minus those the tag filter hides, for lists that show threads to the user. */
177+
export function useVisibleThreadShells(): ReadonlyArray<EnvironmentThreadShell> {
178+
return useAtomValue(environmentThreadShells.visibleThreadShellsAtom);
179+
}
180+
176181
export function useNavigationThreadShells(): ReadonlyArray<EnvironmentThreadShell> {
177182
return useAtomValue(environmentThreadShells.navigationThreadShellsAtom);
178183
}

‎apps/mobile/src/state/threads.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
pendingThreadCreationOutcomesAtom,
2222
selectThreadCreationDetail,
2323
} from "./pending-thread-creation";
24+
import { serverEnvironment } from "./server";
2425
import { environmentShell } from "./shell";
2526
import { threadOutboxManager } from "./thread-outbox";
2627

@@ -43,6 +44,7 @@ export const environmentThreadDetails = createEnvironmentThreadDetailAtoms(
4344
export const environmentThreadShells = createEnvironmentThreadShellAtoms({
4445
catalogValueAtom: environmentCatalog.catalogValueAtom,
4546
snapshotAtom: threadEnvironment.snapshotAtom,
47+
hiddenThreadTagsAtom: serverEnvironment.hiddenThreadTagsAtom,
4648
});
4749
export const childThreadApprovalsAtom = createChildThreadApprovalsAtom({
4850
childThreadInputsAtom: environmentThreadShells.childThreadInputsAtom,

‎apps/mobile/src/state/use-composer-drafts.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ function modelReconciliationHarness(
313313
const shells = createEnvironmentThreadShellAtoms({
314314
catalogValueAtom,
315315
snapshotAtom: () => snapshotAtom,
316+
hiddenThreadTagsAtom: () => Atom.make(null),
316317
});
317318
const selectedShell = shells.threadShellAtom({ environmentId, threadId: selectedThreadId });
318319
onTestFinished(registry.mount(selectedShell));

‎apps/mobile/src/state/use-pending-new-tasks.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { useAtomValue } from "@effect/atom-react";
2+
import { threadKey } from "@t3tools/client-runtime/state/entities";
23
import { buildPendingNewTasks, type PendingNewTask } from "./pending-new-tasks-model";
34
import { flattenQueuedThreadMessages } from "./thread-outbox-model";
5+
import { environmentThreadShells } from "./threads";
46
import { newTaskComposerDraftsAtom } from "./use-composer-drafts";
57
import { useThreadOutboxMessages } from "./use-thread-outbox";
68

@@ -13,8 +15,10 @@ export type {
1315
export function usePendingNewTasks(): ReadonlyArray<PendingNewTask> {
1416
const queuedMessagesByThreadKey = useThreadOutboxMessages();
1517
const drafts = useAtomValue(newTaskComposerDraftsAtom);
16-
return buildPendingNewTasks({
17-
queuedMessages: flattenQueuedThreadMessages(queuedMessagesByThreadKey),
18-
drafts,
19-
});
18+
const hiddenKeys = useAtomValue(environmentThreadShells.hiddenThreadKeysAtom);
19+
// A delivered creation can stay queued after its thread is live and hidden.
20+
const queuedMessages = flattenQueuedThreadMessages(queuedMessagesByThreadKey).filter(
21+
(message) => !hiddenKeys.has(threadKey(message)),
22+
);
23+
return buildPendingNewTasks({ queuedMessages, drafts });
2024
}

‎apps/server/src/orchestration-v2/FoundationPersistence.test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ it.layer(layerTest)("orchestration V2 foundation persistence", (it) => {
841841
const messageId = MessageId.make("message:foundation-compact");
842842
const threadStateEvent = (
843843
suffix: string,
844-
type: "thread.visited" | "thread.metadata-updated",
844+
type: "thread.visited" | "thread.metadata-updated" | "thread.tags-updated",
845845
): OrchestrationV2DomainEvent => ({
846846
id: EventId.make(`event:foundation-compact:${suffix}`),
847847
type,
@@ -936,10 +936,13 @@ it.layer(layerTest)("orchestration V2 foundation persistence", (it) => {
936936
...Array.from({ length: 501 }, (_, index) =>
937937
threadStateEvent(`history-${index}`, "thread.visited"),
938938
),
939+
threadStateEvent("tags-1", "thread.tags-updated"),
939940
threadStateEvent("visit-2", "thread.visited"),
940941
messageEvent("message-2", "final"),
941942
nodeEvent("node-2", "completed"),
942943
itemEvent("item-2", "final"),
944+
// Older clients skip tag events, so these must not remove the rename above.
945+
threadStateEvent("tags-2", "thread.tags-updated"),
943946
],
944947
});
945948
const beforeCompaction = yield* projections.getThreadProjection(threadId);
@@ -1002,6 +1005,7 @@ it.layer(layerTest)("orchestration V2 foundation persistence", (it) => {
10021005
"event:foundation-compact:message-2",
10031006
"event:foundation-compact:node-2",
10041007
"event:foundation-compact:item-2",
1008+
"event:foundation-compact:tags-2",
10051009
],
10061010
);
10071011

0 commit comments

Comments
 (0)