Skip to content

Commit 12069ee

Browse files
NoojunoYash-Singh1juliusmarmingeclaude
authored
feat(web): find messages and plans in the current thread (#10439)
Co-authored-by: Yash Singh <[email protected]> Co-authored-by: Julius Marminge <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
1 parent a4c9494 commit 12069ee

139 files changed

Lines changed: 8005 additions & 1467 deletions

File tree

Some content is hidden

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

‎apps/mobile/modules/t3-markdown-text/src/markdownLinks.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import { fileBasename } from "@t3tools/shared/path";
2+
import { formatFilePathPosition } from "@t3tools/shared/fileLinks";
13
import {
2-
fileBasename,
3-
formatFilePathPosition,
44
inlineCodeFilePathCandidate,
55
normalizeMarkdownLinkDestination,
66
parseMarkdownFileLink,
7-
} from "@t3tools/client-runtime/markdown-links";
7+
} from "@t3tools/shared/markdownLinks";
88
import { parseThreadLinkHref } from "@t3tools/shared/threadLinks";
99
import { videoMimeType } from "@t3tools/shared/video";
1010

‎apps/mobile/modules/t3-markdown-text/src/nativeMarkdownText.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { MarkdownNode } from "react-native-nitro-markdown/headless";
2-
import { isMarkdownFileLinkLabel } from "@t3tools/client-runtime/markdown-links";
2+
import { isMarkdownFileLinkLabel } from "@t3tools/shared/markdownLinks";
33
import { collectComposerInlineTokens } from "@t3tools/shared/composerInlineTokens";
44
import { imageMimeType } from "@t3tools/shared/image";
55
import { isWindowsAbsolutePath } from "@t3tools/shared/path";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import type {
2929
import {
3030
appendCodexArtifactTemplateUsePrompt,
3131
type CodexArtifactTemplate,
32-
} from "@t3tools/client-runtime/codex-artifact-templates";
32+
} from "@t3tools/shared/codexArtifactTemplates";
3333
import type { ThreadUserInputQuestion } from "@t3tools/client-runtime/state/thread-requests";
3434
import {
3535
presentPendingBackgroundWork,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ import { writeComposerContextClipboard } from "../../lib/composerContextClipboar
3636
import {
3737
codexArtifactTemplatePresentationLabel,
3838
type CodexArtifactTemplate,
39-
} from "@t3tools/client-runtime/codex-artifact-templates";
39+
} from "@t3tools/shared/codexArtifactTemplates";
4040
import { resolveAssetUrl } from "@t3tools/client-runtime/state/assets";
41-
import { isMarkdownFileLinkLabel } from "@t3tools/client-runtime/markdown-links";
41+
import { isMarkdownFileLinkLabel } from "@t3tools/shared/markdownLinks";
4242
import { getTextContent, type MarkdownNode } from "react-native-nitro-markdown/headless";
4343
import { formatAttachmentSize } from "@t3tools/client-runtime/state/attachments";
4444
import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
@@ -50,7 +50,7 @@ import { resolveViewedImageAsset } from "@t3tools/client-runtime/work-log/presen
5050
import {
5151
renderCodexFileCitationsAsMarkdown,
5252
splitCodexArtifactTemplateMarkdown,
53-
} from "@t3tools/client-runtime/codex-markdown-directives";
53+
} from "@t3tools/shared/codexMarkdownDirectives";
5454
import { CHAT_LIST_ANCHOR_OFFSET, resolveChatListAnchoredEndSpace } from "@t3tools/shared/chatList";
5555
import { imageMimeType } from "@t3tools/shared/image";
5656
import { videoMimeType } from "@t3tools/shared/video";

‎apps/mobile/src/features/threads/fileChipMenu.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { fileBasename } from "@t3tools/client-runtime/markdown-links";
1+
import { fileBasename } from "@t3tools/shared/path";
22
import type { ThreadId } from "@t3tools/contracts";
33
import { resolveMarkdownLinkPresentation } from "@t3tools/mobile-markdown-text/links";
44
import type { MarkdownFileContextMenu } from "@t3tools/mobile-markdown-text/types";

‎apps/mobile/src/features/threads/thread-search-match.tsx‎

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,9 @@
1+
import { splitThreadSearchText } from "@t3tools/shared/threadSearch";
12
import type { EnvironmentThreadSearchMatch } from "@t3tools/client-runtime/state/thread-search";
23

34
import { AppText as Text } from "../../components/AppText";
45
import { cn } from "../../lib/cn";
56

6-
function foldAsciiCase(value: string): string {
7-
return value.replace(/[A-Z]/g, (character) => character.toLowerCase());
8-
}
9-
10-
function splitHighlightParts(text: string, query: string) {
11-
const normalizedText = foldAsciiCase(text);
12-
const normalizedQuery = foldAsciiCase(query.trim());
13-
if (normalizedQuery.length === 0) {
14-
return [{ text, highlighted: false, start: 0 }];
15-
}
16-
17-
const parts: Array<{
18-
readonly text: string;
19-
readonly highlighted: boolean;
20-
readonly start: number;
21-
}> = [];
22-
let cursor = 0;
23-
while (cursor < text.length) {
24-
const matchIndex = normalizedText.indexOf(normalizedQuery, cursor);
25-
if (matchIndex === -1) {
26-
parts.push({ text: text.slice(cursor), highlighted: false, start: cursor });
27-
break;
28-
}
29-
if (matchIndex > cursor) {
30-
parts.push({
31-
text: text.slice(cursor, matchIndex),
32-
highlighted: false,
33-
start: cursor,
34-
});
35-
}
36-
parts.push({
37-
text: text.slice(matchIndex, matchIndex + normalizedQuery.length),
38-
highlighted: true,
39-
start: matchIndex,
40-
});
41-
cursor = matchIndex + normalizedQuery.length;
42-
}
43-
return parts;
44-
}
45-
467
export function ThreadSearchMatchExcerpt(props: {
478
readonly match: EnvironmentThreadSearchMatch;
489
readonly query: string;
@@ -51,7 +12,7 @@ export function ThreadSearchMatchExcerpt(props: {
5112
readonly sidebar?: boolean;
5213
}) {
5314
const isUser = props.match.source === "user";
54-
const parts = splitHighlightParts(props.match.snippet, props.query);
15+
const parts = splitThreadSearchText(props.match.snippet, props.query);
5516
return (
5617
<Text
5718
className={cn(

‎apps/server/src/auth/RpcAuthorization.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ export const RPC_REQUIRED_SCOPES = {
4747
[ORCHESTRATION_V2_WS_METHODS.getTurnDiff]: AuthOrchestrationReadScope,
4848
[ORCHESTRATION_V2_WS_METHODS.getFullThreadDiff]: AuthOrchestrationReadScope,
4949
[ORCHESTRATION_V2_WS_METHODS.searchThreads]: AuthOrchestrationReadScope,
50+
[ORCHESTRATION_V2_WS_METHODS.searchThread]: AuthOrchestrationReadScope,
51+
[ORCHESTRATION_V2_WS_METHODS.searchThreadStream]: AuthOrchestrationReadScope,
5052
[ORCHESTRATION_V2_WS_METHODS.getArchivedShellSnapshot]: AuthOrchestrationReadScope,
5153
[ORCHESTRATION_V2_WS_METHODS.getThreadProjection]: AuthOrchestrationReadScope,
5254
[ORCHESTRATION_V2_WS_METHODS.getTurnItem]: AuthOrchestrationReadScope,

‎apps/server/src/observability/RpcInstrumentation.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ const RPC_AGGREGATES = {
2121
[ORCHESTRATION_V2_WS_METHODS.getTurnDiff]: "orchestration",
2222
[ORCHESTRATION_V2_WS_METHODS.getFullThreadDiff]: "orchestration",
2323
[ORCHESTRATION_V2_WS_METHODS.searchThreads]: "orchestration",
24+
[ORCHESTRATION_V2_WS_METHODS.searchThread]: "orchestration",
25+
[ORCHESTRATION_V2_WS_METHODS.searchThreadStream]: "orchestration",
2426
[ORCHESTRATION_V2_WS_METHODS.getArchivedShellSnapshot]: "orchestration",
2527
[ORCHESTRATION_V2_WS_METHODS.getThreadProjection]: "orchestrationV2",
2628
[ORCHESTRATION_V2_WS_METHODS.launchThread]: "orchestration",

‎apps/server/src/orchestration-v2/Orchestrator.ts‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import type {
2+
OrchestrationV2SearchThreadInput,
3+
OrchestrationV2SearchThreadResult,
4+
OrchestrationV2ThreadHistoryPage,
5+
} from "@t3tools/contracts";
16
import {
27
latestExecutedRun,
38
latestRootProviderFailure,
@@ -281,6 +286,18 @@ export interface OrchestratorV2Shape {
281286
readonly dispatch: (
282287
command: OrchestrationV2ServerCommand,
283288
) => Effect.Effect<OrchestratorV2DispatchResult, OrchestratorV2Error>;
289+
readonly searchThreadStream: (
290+
input: OrchestrationV2SearchThreadInput,
291+
) => Stream.Stream<OrchestrationV2SearchThreadResult, OrchestratorV2Error>;
292+
readonly searchThread: (
293+
input: OrchestrationV2SearchThreadInput,
294+
) => Effect.Effect<OrchestrationV2SearchThreadResult, OrchestratorV2Error>;
295+
readonly getThreadHistoryPage: (
296+
threadId: ThreadId,
297+
cursor: string,
298+
throughEntryId?: string,
299+
conversationOnly?: boolean,
300+
) => Effect.Effect<OrchestrationV2ThreadHistoryPage, OrchestratorV2Error>;
284301
readonly getTimelinePage: (
285302
threadId: ThreadId,
286303
options: ProjectionTimelinePageOptions,
@@ -10817,6 +10834,26 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
1081710834
recoverDelegatedTask,
1081810835
delegatedTaskResultPending,
1081910836
dispatch: dispatchWithReceipt,
10837+
searchThreadStream: (input) =>
10838+
projectionStore
10839+
.searchThreadStream(input)
10840+
.pipe(
10841+
Stream.mapError(
10842+
(cause) => new OrchestratorProjectionError({ threadId: input.threadId, cause }),
10843+
),
10844+
),
10845+
searchThread: (input) =>
10846+
projectionStore
10847+
.searchThread(input)
10848+
.pipe(
10849+
Effect.mapError(
10850+
(cause) => new OrchestratorProjectionError({ threadId: input.threadId, cause }),
10851+
),
10852+
),
10853+
getThreadHistoryPage: (threadId, cursor, throughEntryId, conversationOnly) =>
10854+
projectionStore
10855+
.getThreadHistoryPage(threadId, cursor, throughEntryId, conversationOnly)
10856+
.pipe(Effect.mapError((cause) => new OrchestratorProjectionError({ threadId, cause }))),
1082010857
getTimelinePage: (threadId, options) =>
1082110858
projectionStore
1082210859
.getTimelinePage(threadId, options)
@@ -10951,6 +10988,11 @@ const layerUnavailable: Layer.Layer<OrchestratorV2> = Layer.succeed(
1095110988
cause: "Orchestration V2 live runtime is not configured.",
1095210989
}),
1095310990
),
10991+
searchThreadStream: (input) =>
10992+
Stream.fail(new OrchestratorProjectionError({ threadId: input.threadId })),
10993+
searchThread: (input) =>
10994+
Effect.fail(new OrchestratorProjectionError({ threadId: input.threadId })),
10995+
getThreadHistoryPage: (threadId) => Effect.fail(new OrchestratorProjectionError({ threadId })),
1095410996
getTimelinePage: (threadId) => Effect.fail(new OrchestratorProjectionError({ threadId })),
1095510997
getMessageCount: (threadId) => Effect.fail(new OrchestratorProjectionError({ threadId })),
1095610998
getTurnItem: ({ threadId }) => Effect.fail(new OrchestratorProjectionError({ threadId })),

0 commit comments

Comments
 (0)