GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(web): overlong content search queries explain the 256-character l… · pingdotgg/t3code@3624738

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/web/src/state
    • queries.ts
  • packages/contracts/src
    • project.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/web/src/state/queries.ts‎

Copy file name to clipboardExpand all lines: apps/web/src/state/queries.ts
+14-6Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import {
1212
type ThreadSearchResultsState,
1313
type ThreadSearchScope,
1414
} 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";
1619
import { messageSearchTokens } from "@t3tools/shared/paletteSearch";
1720
import { type VcsRefTarget } from "@t3tools/client-runtime/state/vcs";
1821
import type {
@@ -364,13 +367,16 @@ export function useProjectContentSearch(target: ProjectContentSearchTarget) {
364367
// Preserve query whitespace; trim only to detect blank input.
365368
const query = target.query;
366369
const hasQuery = query.trim().length > 0;
370+
const queryTooLong = query.length > PROJECT_SEARCH_CONTENTS_QUERY_MAX_LENGTH;
367371
const debouncedQuery = useDebouncedValue(query, PROJECT_CONTENT_SEARCH_DEBOUNCE_MS);
368372
const result = useEnvironmentQuery(
369373
canReadFiles &&
370374
target.environmentId !== null &&
371375
target.cwd !== null &&
372376
hasQuery &&
373-
debouncedQuery.trim().length > 0
377+
!queryTooLong &&
378+
debouncedQuery.trim().length > 0 &&
379+
debouncedQuery.length <= PROJECT_SEARCH_CONTENTS_QUERY_MAX_LENGTH
374380
? projectContentSearch({
375381
environmentId: target.environmentId,
376382
input: {
@@ -392,12 +398,14 @@ export function useProjectContentSearch(target: ProjectContentSearchTarget) {
392398
error:
393399
!hasTarget || isCheckingAccess
394400
? 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,
398406
isPending:
399407
isCheckingAccess ||
400-
(canReadFiles && hasQuery && (query !== debouncedQuery || result.isPending)),
408+
(canReadFiles && hasQuery && !queryTooLong && (query !== debouncedQuery || result.isPending)),
401409
hasQuery,
402410
truncated: result.data?.truncated ?? false,
403411
invalidRegex: target.useRegex && result.data?.regexFallbackError !== undefined,
Collapse file

‎packages/contracts/src/project.ts‎

Copy file name to clipboardExpand all lines: packages/contracts/src/project.ts
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818

1919
const PROJECT_SEARCH_ENTRIES_MAX_LIMIT = 200;
2020
const PROJECT_SEARCH_CONTENTS_MAX_LIMIT = 500;
21+
export const PROJECT_SEARCH_CONTENTS_QUERY_MAX_LENGTH = 256;
2122
const PROJECT_WRITE_FILE_PATH_MAX_LENGTH = 512;
2223
const PROJECT_READ_FILE_PATH_MAX_LENGTH = 512;
2324

@@ -262,7 +263,10 @@ export type ProjectSearchEntriesResult = typeof ProjectSearchEntriesResult.Type;
262263
export const ProjectSearchContentsInput = Schema.Struct({
263264
cwd: TrimmedNonEmptyString,
264265
// 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+
),
266270
limit: PositiveInt.check(Schema.isLessThanOrEqualTo(PROJECT_SEARCH_CONTENTS_MAX_LIMIT)),
267271
caseSensitive: Schema.Boolean,
268272
wholeWord: Schema.Boolean,

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.