The best way to control Claude Code, Codex and more from any computer or phone
fix(web): overlong content search queries explain the 256-character limit (#35020)
Julius Marminge committed
Nov 12, 2026 at 02:29 UTC
c17ec829d04566a3ff02f9084889a996f18f6770
3 files changed
+29
-7
apps/web/src/state/queries.filesystem.test.ts
+10
@@ -124,6 +124,16 @@ it.each([
124
},
125
);
126
127
+it("explains an overlong content query instead of sending it", () => {
128
+ state.session = { authenticated: true, scopes: [AuthFilesystemReadScope] };
129
+ const result = useProjectContentSearch({ ...contentTarget, query: "a".repeat(257) });
130
+
131
+ expect(state.contentRequests).not.toHaveBeenCalled();
132
+ expect(result.matches).toEqual([]);
133
+ expect(result.isPending).toBe(false);
134
+ expect(result.error).toMatch(/256/);
135
+});
136
+
137
it("shows content-search denial before typing and never issues an unauthorized request", () => {
138
state.session = { authenticated: true, scopes: [] };
139
for (const query of ["", contentTarget.query]) {
apps/web/src/state/queries.ts
+14
-6
@@ -12,7 +12,10 @@ import {
12
type ThreadSearchResultsState,
13
type ThreadSearchScope,
14
} from "@t3tools/client-runtime/state/thread-search";
15
-import { THREAD_SEARCH_QUERY_MAX_LENGTH } from "@t3tools/contracts";
15
+import {
16
+ PROJECT_SEARCH_CONTENTS_QUERY_MAX_LENGTH,
17
+ THREAD_SEARCH_QUERY_MAX_LENGTH,
18
+} from "@t3tools/contracts";
19
import { messageSearchTokens } from "@t3tools/shared/paletteSearch";
20
import { type VcsRefTarget } from "@t3tools/client-runtime/state/vcs";
21
import type {
@@ -364,13 +367,16 @@ export function useProjectContentSearch(target: ProjectContentSearchTarget) {
367
// Preserve query whitespace; trim only to detect blank input.
368
const query = target.query;
369
const hasQuery = query.trim().length > 0;
370
+ const queryTooLong = query.length > PROJECT_SEARCH_CONTENTS_QUERY_MAX_LENGTH;
371
const debouncedQuery = useDebouncedValue(query, PROJECT_CONTENT_SEARCH_DEBOUNCE_MS);
372
const result = useEnvironmentQuery(
373
canReadFiles &&
374
target.environmentId !== null &&
375
target.cwd !== null &&
376
hasQuery &&
373
- debouncedQuery.trim().length > 0
377
+ !queryTooLong &&
378
+ debouncedQuery.trim().length > 0 &&
379
+ debouncedQuery.length <= PROJECT_SEARCH_CONTENTS_QUERY_MAX_LENGTH
380
? projectContentSearch({
381
environmentId: target.environmentId,
382
input: {
@@ -392,12 +398,14 @@ export function useProjectContentSearch(target: ProjectContentSearchTarget) {
398
error:
399
!hasTarget || isCheckingAccess
400
? null
395
- : canReadFiles
396
- ? result.error
397
- : (fileAccess.error ?? "This connection cannot search host files."),
401
+ : !canReadFiles
402
+ ? (fileAccess.error ?? "This connection cannot search host files.")
403
+ : queryTooLong
404
+ ? `Search is limited to ${PROJECT_SEARCH_CONTENTS_QUERY_MAX_LENGTH} characters.`
405
+ : result.error,
406
isPending:
407
isCheckingAccess ||
400
- (canReadFiles && hasQuery && (query !== debouncedQuery || result.isPending)),
408
+ (canReadFiles && hasQuery && !queryTooLong && (query !== debouncedQuery || result.isPending)),
409
hasQuery,
410
truncated: result.data?.truncated ?? false,
411
invalidRegex: target.useRegex && result.data?.regexFallbackError !== undefined,
packages/contracts/src/project.ts
+5
-1
@@ -18,6 +18,7 @@ import {
18
19
const PROJECT_SEARCH_ENTRIES_MAX_LIMIT = 200;
20
const PROJECT_SEARCH_CONTENTS_MAX_LIMIT = 500;
21
+export const PROJECT_SEARCH_CONTENTS_QUERY_MAX_LENGTH = 256;
22
const PROJECT_WRITE_FILE_PATH_MAX_LENGTH = 512;
23
const PROJECT_READ_FILE_PATH_MAX_LENGTH = 512;
24
@@ -262,7 +263,10 @@ export type ProjectSearchEntriesResult = typeof ProjectSearchEntriesResult.Type;
263
export const ProjectSearchContentsInput = Schema.Struct({
264
cwd: TrimmedNonEmptyString,
265
// Preserve whitespace because it is significant in content queries.
265
- query: Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(256)),
266
+ query: Schema.String.check(
267
+ Schema.isNonEmpty(),
268
+ Schema.isMaxLength(PROJECT_SEARCH_CONTENTS_QUERY_MAX_LENGTH),
269
+ ),
270
limit: PositiveInt.check(Schema.isLessThanOrEqualTo(PROJECT_SEARCH_CONTENTS_MAX_LIMIT)),
271
caseSensitive: Schema.Boolean,
272
wholeWord: Schema.Boolean,