feat(server): make workspace list cap configurable #5107
main fromrefs/pull/5107/head·opened View on GitHubProblem#
The workspace Files listing always asks FFF for 25,002 results and materializes up to 25,000 paths. Large workspace roots therefore retain substantial server memory even when users do not need that many entries in the Files panel, and there was no way to trade listing depth for memory use.
Using the included probe against a workspace root with roughly 222,000 entries, each limit ran in a fresh Node process and sampled RSS after forced GC:
| list limit | listed RSS | RSS added by list() | peak RSS added |
|---|---|---|---|
| 1,000 | 196.2 MiB | 24.1 MiB | 3.5 MiB |
| 5,000 | 219.5 MiB | 44.7 MiB | 24.4 MiB |
| 25,000 | 290.1 MiB | 117.5 MiB | 99.8 MiB |
Reproduce with:
node apps/server/scripts/workspace-index-memory-probe.ts /path/to/large/workspace 1000 5000 25000
How this helps#
- Add
T3CODE_WORKSPACE_LIST_MAX_ENTRIESwith an allowed range of 1 through 25,000. - Preserve the existing 25,000 default, so this is an opt-in memory mitigation rather than a behavior change for existing installs.
- Apply the limit before FFF result materialization and to the returned Files listing. Path and content search continue to use the full index.
- Fall back to 25,000 with a warning for invalid values.
- Document the setting and add focused tests for valid, zero, over-limit, and non-numeric configuration.
Verification#
vp lint apps/server/scripts/workspace-index-memory-probe.ts apps/server/src/workspace/WorkspaceSearchIndex.ts apps/server/src/workspace/WorkspaceSearchIndex.test.tsvp test run apps/server/src/workspace/WorkspaceSearchIndex.test.ts(10 tests passed)vp run -F t3 typecheck- Production-path memory probe shown above
- Reviewed by Claude Fable 5 directly and Claude Opus 5 through Paseo
Implemented with Codex (GPT-5.6 Sol) in T3 Code; reviewed by Claude Fable 5 and Claude Opus 5.
Note
Low Risk Opt-in configuration with the same 25,000 default; changes only workspace listing depth and memory, not auth or search over the full index.
Overview
Adds T3CODE_WORKSPACE_LIST_MAX_ENTRIES (1–25,000, default 25,000) so the Files panel listing can cap how many paths are fetched and returned from the workspace index, trading shorter lists for lower server memory on huge roots. Invalid values keep the default and log a warning; path and content search still use the full index.
WorkspaceSearchIndex.make and the layer path honor the limit for list() page size and truncation. A new workspace-index-memory-probe script measures RSS across limits in isolated child processes. Install docs describe the setting and desktop/WSL launch caveats. Tests cover configured caps and invalid env fallback.
Note
Make workspace list entry cap configurable via T3CODE_WORKSPACE_LIST_MAX_ENTRIES#
- Replaces the fixed 25,000-entry cap in
WorkspaceSearchIndexwith a value read from theT3CODE_WORKSPACE_LIST_MAX_ENTRIESenv var (range 1–25,000, default 25,000). - Invalid config values log a warning and fall back to the default; the cap is applied to both the search page size and the final slice in
list(). - Adds a workspace-index-memory-probe script to measure RSS before/after listing at configurable limits.
- Documents the new env var and large-workspace memory guidance in install.md.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
Approvability#
Verdict: Needs human review
This PR introduces a new feature allowing users to configure the workspace list cap via environment variable. While implementation is solid with safe defaults and validation, new user-facing configurable behavior warrants human review. The author is also new to this codebase area.
You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).Note: GPT-5 on behalf of shivam (@shivamhwp).
Thanks for investigating this and including memory measurements. The cost of listing large workspaces is worth addressing.
We're closing this because we'd prefer to reduce that cost through batched or on-demand listing rather than another environment setting. Lowering the cap saves memory by returning fewer files, while leaving default performance unchanged.
The implementation is a reasonable opt-in workaround, but we'd rather improve the default experience without requiring users to trade file visibility for memory use.
shivamhwp(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
8b755ea5-3f73-4494-8c32-8b4e90e58514You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
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