Skip to content
Source
Sign inSign up
pingdotgg/t3code

Add global project content search #4007

Closedjakeleventhal(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/4007/headopened View on GitHub

Summary

Screenshot 2026-07-15 at 9 32 39 AM Screenshot 2026-07-15 at 9 33 00 AM
  • add project-wide content search with Cmd/Ctrl+Shift+F
  • group matches by file with case-sensitive, whole-word, and regex options
  • syntax-highlight result lines and preserve precise match highlighting
  • open results at the matching line and reveal the selected file in the explorer

Why

T3 Code could locate files by name, but it did not provide a fast way to search file contents across an entire project. This adds a VS Code-style global search flow for navigating directly from a text match to its source file.

Implementation

  • adds shared contracts and RPC handling for content-search results
  • enables FFF content indexing and uses its native grep implementation with result limits and gitignore support
  • adds the default project.searchContents keybinding and search dialog
  • reuses the shared Shiki highlighter for language-aware result snippets
  • synchronizes opened search results with the right-side file explorer
  • handles punctuation-ended whole-word queries without including boundary characters in highlighted ranges

Validation

  • vp check
  • vp run typecheck
  • 101 focused tests across workspace search, contracts, keybindings, and right-panel state
  • punctuation whole-word regression tests
  • live browser verification of search options, syntax highlighting, result navigation, line reveal, and explorer selection

Note

[!NOTE]

Add project-wide content search with mod+shift+f keybinding

  • Adds a ProjectContentSearchDialog component accessible via mod+shift+f (outside terminal focus) that searches file contents across the active project with options for case sensitivity, whole word, and regex modes.
  • Adds a projects.searchContents WebSocket RPC endpoint backed by WorkspaceSearchIndex.searchContents, which delegates to FileFinder.grep and returns per-line matches with byte-accurate ranges; requires orchestration read scope.
  • Renders syntax-highlighted result lines with match highlighting via a new HighlightedSearchLine component and a shared getSyntaxHighlighterPromise utility.
  • Extends FileBrowserPanel to auto-reveal and scroll the currently open file into view when selectedPath or selectedPathRevealId props change.
  • Behavioral Change: FileFinder is now created with content indexing enabled (disableContentIndexing: false).
📊 Macroscope summarized 35a1864. 19 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted

🗂️ Filtered Issues

No issues evaluated.

>

Note

Medium Risk Enabling FileFinder content indexing changes workspace index cost/behavior for all projects; grep runs locally on the workspace with read-scope auth only, but search still touches full tree contents.

Overview Adds VS Code-style global content search for the active project via mod+shift+f (project.searchContents), opening a dialog with case-sensitive, whole-word, and regex options.

Backend: New projects.searchContents RPC and WorkspaceEntries.searchContents → WorkspaceSearchIndex.searchContents, which runs FileFinder.grep with limits, gitignore behavior, and structured errors (query text not leaked). Content indexing is turned on for workspace indexes (disableContentIndexing: false). Whole-word matching uses \b or non-word boundary fallbacks for punctuation-ended patterns; match ranges are mapped from byte offsets and trimmed for literal whole-word hits.

UI: ProjectContentSearchDialog debounces queries, groups results by file, syntax-highlights lines via shared getSyntaxHighlighterPromise, and opens the right panel at the matching line. FileBrowserPanel syncs selection/reveal when a file is opened from search. Shortcut handling treats the search dialog like the command palette for “palette open” checks.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 35a18648d7f73a09f14f8eca04ad7418bffc43b6. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 15e03ea3-4aaa-4df8-8801-4b8d5350cffc

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. Approvability

      Verdict: Needs human review

      This PR adds a new global project content search feature with new UI components, backend search functionality, and RPC endpoints. Multiple unresolved review comments (including a high-severity race condition) require human attention before merging.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. 💡 Codex Review

      Here are some automated review suggestions for this pull request.

      Reviewed commit: f52cf27096

      ℹ️ About Codex in GitHub

      Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

      • Open a pull request for review
      • Mark a draft as ready
      • Comment "@codex review".

      If Codex has suggestions, it will comment; otherwise it will react with 👍.

      Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

      @@ -310,0 +359,21 @@
      359+ reason: result.error,
      360+ });
      361+ }
      362+
      363+ const byteOffsetToStringIndex = (line: string, byteOffset: number): number =>
      364+ Buffer.from(line).subarray(0, byteOffset).toString().length;
      365+ const mapMatchRange = (line: string, startByte: number, endByte: number) => {
      366+ const start = byteOffsetToStringIndex(line, startByte);
      367+ const end = byteOffsetToStringIndex(line, endByte);
      368+ if (!input.wholeWord || input.useRegex) return { start, end };
      369+
      370+ const matchedText = line.slice(start, end);
      371+ const queryIndex = input.caseSensitive
      372+ ? matchedText.indexOf(input.query)
      373+ : matchedText.toLocaleLowerCase().indexOf(input.query.toLocaleLowerCase());
      374+ return queryIndex === -1
      375+ ? { start, end }
      376+ : { start: start + queryIndex, end: start + queryIndex + input.query.length };
      377+ };
      378+ return {
      379+ matches: result.value.items.map((match) => ({

      P2 Badge Suppress fallback matches for invalid regexes

      The fff grep API reports regexFallbackError after falling back to literal matching, but this code still maps result.value.items into normal search results. With regex enabled, an invalid pattern like foo[ can therefore render and open literal foo[ hits under the dialog's “Invalid regular expression” banner, which is not the requested regex result set. Treat regexFallbackError as an empty/error result before exposing matches.

      Useful? React with 👍 / 👎.

      @@ -216,0 +233,21 @@
      233+ const result = useEnvironmentQuery(
      234+ target.environmentId !== null &&
      235+ target.cwd !== null &&
      236+ query.length > 0 &&
      237+ debouncedQuery.length > 0
      238+ ? projectEnvironment.searchContents({
      239+ environmentId: target.environmentId,
      240+ input: {
      241+ cwd: target.cwd,
      242+ query: debouncedQuery,
      243+ limit: PROJECT_CONTENT_SEARCH_LIMIT,
      244+ caseSensitive: target.caseSensitive,
      245+ wholeWord: target.wholeWord,
      246+ useRegex: target.useRegex,
      247+ },
      248+ })
      249+ : null,
      250+ );
      251+
      252+ return {
      253+ matches: result.data?.matches ?? EMPTY_CONTENT_MATCHES,

      P2 Badge Hide stale matches while a new query is debouncing

      When the input changes from one non-empty query to another, debouncedQuery still points at the previous request for 120ms, but this returns the previous result.data?.matches unconditionally. During that window the dialog can show old rows while saying it is searching the new text, and pressing Enter opens matches[selectedIndex] from the previous search. Gate the returned data on query === debouncedQuery or clear matches while the new query is pending.

      Useful? React with 👍 / 👎.

      @@ -73,3 +79,17 @@
      7379 model.resetPaths(treePaths);
      7480 }, [entryKinds, model, treePaths]);
      7581
      82+ useEffect(() => {
      83+ if (!selectedPath || entryKinds.get(selectedPath) !== "file") return;
      84+
      85+ syncingSelectionRef.current = true;
      86+ model.closeSearch();
      87+ for (const path of model.getSelectedPaths()) {
      88+ model.getItem(path)?.deselect();
      89+ }
      90+
      91+ const segments = selectedPath.split("/");
      92+ let ancestorPath = "";
      93+ for (const segment of segments.slice(0, -1)) {
      94+ ancestorPath = ancestorPath ? `${ancestorPath}/${segment}` : segment;
      95+ const item = model.getItem(ancestorPath);

      P2 Badge Use directory item ids when expanding ancestors

      For a nested file opened from search while its parent folders are collapsed, this lookup uses ids like src or src/components, but the tree is populated with directory paths ending in / via treePath (for example src/). Those ancestor items are not found or expanded, so the subsequent select/scroll can target a hidden file and the explorer does not reveal the search result.

      Useful? React with 👍 / 👎.

    5. @@ -170,2 +176,21 @@
      170176 }, [entryKinds, model, treePaths]);
      171177
      178+ useEffect(() => {
      179+ if (!selectedPath || entryKinds.get(selectedPath) !== "file") return;
      180+
      181+ syncingSelectionRef.current = true;
      182+ model.closeSearch();
      183+ for (const path of model.getSelectedPaths()) {
      184+ model.getItem(path)?.deselect();
      185+ }
      186+
      187+ const segments = selectedPath.split("/");
      188+ let ancestorPath = "";
      189+ for (const segment of segments.slice(0, -1)) {
      190+ ancestorPath = ancestorPath ? `${ancestorPath}/${segment}` : segment;
      191+ const item = model.getItem(ancestorPath);
      192+ if (item && "expand" in item) item.expand();
      193+ }
      194+
      195+ model.getItem(selectedPath)?.select();
      196+ model.scrollToPath(selectedPath, { focus: true, offset: "center" });

      Explorer reveal steals editor focus

      Medium Severity

      After opening a search hit, the file-tree sync calls scrollToPath with focus: true, which moves keyboard focus into the explorer instead of leaving it in the file preview the user just opened.

      Fix in Cursor Fix in Web
      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 6ae2b295f373a33ebfce845aff336b9c164dd5e2. Configure [here](https://www.cursor.com/dashboard/bugbot).
    6. 💡 Codex Review

      Here are some automated review suggestions for this pull request.

      Reviewed commit: 6ae2b295f3

      ℹ️ About Codex in GitHub

      Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

      • Open a pull request for review
      • Mark a draft as ready
      • Comment "@codex review".

      If Codex has suggestions, it will comment; otherwise it will react with 👍.

      Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

      @@ -307,4 +312,15 @@
      307312 return mapMixedSearchResult(result, limit);
      308313 });
      309314
      310- return WorkspaceSearchIndex.of({ list, refresh, search });
      315+ const searchContents: WorkspaceSearchIndex["Service"]["searchContents"] = Effect.fn(
      316+ "WorkspaceSearchIndex.searchContents",
      317+ )(function* (input) {
      318+ const escapedQuery = input.query.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
      319+ const wordCharacter = /[\p{Letter}\p{Mark}\p{Number}_]/u;
      320+ const firstCharacter = Array.from(input.query).at(0) ?? "";
      321+ const lastCharacter = Array.from(input.query).at(-1) ?? "";
      322+ // Use \b only when the pattern edge is a word character; otherwise \b cannot
      323+ // match (e.g. query "foo-" → \b(?:foo-)\b never matches "foo- "). Fall back to
      324+ // (?:^|\W)/(?:$|\W) for non-word edges, same as the literal whole-word path.
      325+ const wrapWholeWord = (pattern: string) =>
      326+ `${wordCharacter.test(firstCharacter) ? "\\b" : "(?:^|\\W)"}(?:${pattern})${wordCharacter.test(lastCharacter) ? "\\b" : "(?:$|\\W)"}`;

      P2 Badge Use non-consuming whole-word boundaries

      When whole-word search is enabled for a query that both starts and ends with non-word characters, these fallback boundaries consume the separator characters around each hit. In a line like -foo- -foo-, searching whole-word for -foo- matches the first hit plus the trailing space, then the regex engine resumes at the second - where the leading (?:^|\W) can no longer see the separator, so the second hit is skipped. Use lookaround-style/non-consuming boundaries or otherwise avoid consuming delimiters before passing the pattern to grep.

      Useful? React with 👍 / 👎.

      @@ -26,3 +27,6 @@
      2627 });
      2728 export type ProjectSearchEntriesResult = typeof ProjectSearchEntriesResult.Type;
      2829
      30+export const ProjectSearchContentsInput = Schema.Struct({
      31+ cwd: TrimmedNonEmptyString,
      32+ query: TrimmedNonEmptyString.check(Schema.isMaxLength(256)),

      P2 Badge Preserve literal whitespace in content queries

      For content search, leading/trailing spaces are part of the string being searched, but this schema decodes the query through TrimmedNonEmptyString (and the web hook trims before sending), so a query like TODO or foo is silently sent as TODO/foo and returns broader, incorrectly highlighted matches. Use a schema that rejects all-whitespace queries without transforming the value, and stop trimming in the caller.

      Useful? React with 👍 / 👎.

    7. 💡 Codex Review

      Here are some automated review suggestions for this pull request.

      Reviewed commit: 663a8c8840

      ℹ️ About Codex in GitHub

      Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

      • Open a pull request for review
      • Mark a draft as ready
      • Comment "@codex review".

      If Codex has suggestions, it will comment; otherwise it will react with 👍.

      Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

      @@ -310,0 +322,21 @@
      322+ // Use \b only when the pattern edge is a word character; otherwise \b cannot
      323+ // match (e.g. query "foo-" → \b(?:foo-)\b never matches "foo- "). Fall back to
      324+ // (?:^|\W)/(?:$|\W) for non-word edges, same as the literal whole-word path.
      325+ const wrapWholeWord = (pattern: string) =>
      326+ `${wordCharacter.test(firstCharacter) ? "\\b" : "(?:^|\\W)"}(?:${pattern})${wordCharacter.test(lastCharacter) ? "\\b" : "(?:$|\\W)"}`;
      327+ const query = input.wholeWord
      328+ ? wrapWholeWord(input.useRegex ? input.query : escapedQuery)
      329+ : input.query;
      330+ const regexMode = input.useRegex || input.wholeWord;
      331+ const searchQuery = input.caseSensitive
      332+ ? query
      333+ : regexMode
      334+ ? `(?i:${query})`
      335+ : query.toLowerCase();
      336+ const result = yield* Effect.try({
      337+ try: () =>
      338+ finder.grep(searchQuery, {
      339+ mode: regexMode ? "regex" : "plain",
      340+ smartCase: !input.caseSensitive && !regexMode,
      341+ maxMatchesPerFile: input.limit,
      342+ pageSize: input.limit,

      P2 Badge Keep search matches within previewable bytes

      When FFF uses its default grep file-size cap (10 MB), this can return matches from bytes that the app cannot display: WorkspaceFileSystem only reads the first 1 MB for ProjectReadFileResult, and FilePreviewPanel then renders a truncated preview and clamps reveal requests to the loaded content. In files between 1 MB and 10 MB with a match after the first megabyte, selecting a search result opens the file but reveals the wrong/truncated location. Cap maxFileSize to the preview read limit or make the preview load enough content for searched matches.

      Useful? React with 👍 / 👎.

      @@ -310,0 +321,21 @@
      321+ const lastCharacter = Array.from(input.query).at(-1) ?? "";
      322+ // Use \b only when the pattern edge is a word character; otherwise \b cannot
      323+ // match (e.g. query "foo-" → \b(?:foo-)\b never matches "foo- "). Fall back to
      324+ // (?:^|\W)/(?:$|\W) for non-word edges, same as the literal whole-word path.
      325+ const wrapWholeWord = (pattern: string) =>
      326+ `${wordCharacter.test(firstCharacter) ? "\\b" : "(?:^|\\W)"}(?:${pattern})${wordCharacter.test(lastCharacter) ? "\\b" : "(?:$|\\W)"}`;
      327+ const query = input.wholeWord
      328+ ? wrapWholeWord(input.useRegex ? input.query : escapedQuery)
      329+ : input.query;
      330+ const regexMode = input.useRegex || input.wholeWord;
      331+ const searchQuery = input.caseSensitive
      332+ ? query
      333+ : regexMode
      334+ ? `(?i:${query})`
      335+ : query.toLowerCase();
      336+ const result = yield* Effect.try({
      337+ try: () =>
      338+ finder.grep(searchQuery, {
      339+ mode: regexMode ? "regex" : "plain",
      340+ smartCase: !input.caseSensitive && !regexMode,
      341+ maxMatchesPerFile: input.limit,

      P2 Badge Report truncation when one file hits the match cap

      When a single file has more than limit matching lines, this per-file cap silently drops the rest, but truncated is computed only from nextCursor. If that capped file is the last or only eligible file, the cursor can still be null, so the dialog reports an untruncated result set even though matches were omitted. Avoid a separate per-file cap here or include this cap in the truncation signal.

      Useful? React with 👍 / 👎.

    8. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      There are 2 total unresolved issues (including 1 from previous review).

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 35a18648d7f73a09f14f8eca04ad7418bffc43b6. Configure [here](https://www.cursor.com/dashboard/bugbot).
      @@ -0,0 +78,21 @@
      78+ const [useRegex, setUseRegex] = useState(false);
      79+ const [selectedIndex, setSelectedIndex] = useState(0);
      80+
      81+ const search = useProjectContentSearch({
      82+ environmentId: props.open ? props.environmentId : null,
      83+ cwd: props.open ? props.cwd : null,
      84+ query,
      85+ caseSensitive,
      86+ wholeWord,
      87+ useRegex,
      88+ });
      89+ const matches = search.matches;
      90+ const groups = useMemo(() => groupMatches(matches), [matches]);
      91+
      92+ useEffect(() => {
      93+ if (!props.open) setQuery("");
      94+ }, [props.open]);
      95+
      96+ useEffect(() => {
      97+ setSelectedIndex(0);
      98+ }, [matches]);

      Selection resets on revalidation

      Medium Severity

      The dialog resets the highlighted result to the first match whenever the matches array reference changes. Background refetches from the content-search query (5s stale cache) return a new array with the same hits, so keyboard or mouse selection jumps back to result zero while the dialog stays open.

      Fix in Cursor Fix in Web
      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 35a18648d7f73a09f14f8eca04ad7418bffc43b6. Configure [here](https://www.cursor.com/dashboard/bugbot).

Sign in to join this conversation.