Public: anyone can read this; the crew can change it.

A search query has a length limit at the boundary: /explore?q= with 5,000 characters answers a 31 KB page today #14400

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

/explore with a 5,000-character q no longer repeats the whole paste. Most of the issue was already on main from #13862: the 200-character cap in src/core/querylimit.ts, the 422 naming q on /api/v1/explore and /api/v1/search, and the trimmed box with its one-line note on the pages.

Notes

shipped production is serving it deploy 3dfbd46

opened this

/explore with a 5,000-character q no longer repeats the whole paste. Most of the issue was already on main from #13862: the 200-character cap in src/core/query_limit.ts, the 422 naming q on /api/v1/explore and /api/v1/search, and the trimmed box with its one-line note on the pages. The 31 KB page came from three links back to the page, which copied the address uncut: the sign-in next, the sign-up next and the command palette's Sign in.

  • The fix: a new hereAddress(ctx) in src/web/return_to.ts cuts q to the 200 characters the page actually searched. Both signInHref functions (src/web/chrome.ts, src/web/layout.ts) and returnTo now build from it. An address whose q is within the limit is passed through as it came, so the common path does no extra work.
  • MCP: the explore and search tools already refused a long q, but with a literal 200. Their schemas and the checks in src/http/mcp/reads.ts now use MAX_QUERY_CHARS, so the limit is named in one place.
  • Docs: docs/features/explore.md has a new section, "The longest query", naming the limit and every door that applies it.
  • Tests: test/explore-q-limit.test.ts has one test per door: the page, both API endpoints and both MCP tools. The page test checks that no run of the query longer than 200 characters appears anywhere, and that the sign-in link carries the capped query. It fails without the fix. The API and MCP tests pass with or without this change, because those checks were already in place.

Not done: /changelog?repo= takes a repository name, not a search query, so it isn't part of this cap. Production still answers 31 KB until this lands.

Checks: bun scripts/gate.ts --fix (it rewrapped one comment, committed), bun x tsc --noEmit, bun scripts/design-lint.ts, and bun test on test/mcp-size.test.ts, test/query-limit.test.ts and test/explore-q-limit.test.ts all pass. In test/deadends.test.ts, "the findings are the known ones" fails in this sandbox, with and without this change: it reaches for parent.example, which the sandbox blocks. The forge's check runs it. The keep_plan and estimate tools weren't available in this run, so the issue has no plan or estimate recorded.

The desk note asking to hold changes while production rolls doesn't affect this: it's a pull, and nothing reaches production until a person merges it.

To try it: open /explore?q= followed by 5,000 a's while signed out. The page says it searched the first 200 characters, the box holds those 200, and the Sign in link carries only them.

🤖 Generated with Claude Code

Closes #14389

9 earlier comments · 1 event
commented

/explore with a 5,000-character q no longer repeats the whole paste. Most of the issue was already on main from #13862: the 200-character cap in src/core/query_limit.ts, the 422 naming q on /api/v1/explore and /api/v1/search, and the trimmed box with its one-line note on the pages. The 31 KB page came from three links back to the page, which copied the address uncut: the sign-in next, the sign-up next and the command palette's Sign in.

  • The fix: a new hereAddress(ctx) in src/web/return_to.ts cuts q to the 200 characters the page actually searched. Both signInHref functions (src/web/chrome.ts, src/web/layout.ts) and returnTo now build from it. An address whose q is within the limit is passed through as it came, so the common path does no extra work.
  • MCP: the explore and search tools already refused a long q, but with a literal 200. Their schemas and the checks in src/http/mcp/reads.ts now use MAX_QUERY_CHARS, so the limit is named in one place.
  • Docs: docs/features/explore.md has a new section, "The longest query", naming the limit and every door that applies it.
  • Tests: test/explore-q-limit.test.ts has one test per door: the page, both API endpoints and both MCP tools. The page test checks that no run of the query longer than 200 characters appears anywhere, and that the sign-in link carries the capped query. It fails without the fix. The API and MCP tests pass with or without this change, because those checks were already in place.

Not done: /changelog?repo= takes a repository name, not a search query, so it isn't part of this cap. Production still answers 31 KB until this lands.

Checks: bun scripts/gate.ts --fix (it rewrapped one comment, committed), bun x tsc --noEmit, bun scripts/design-lint.ts, and bun test on test/mcp-size.test.ts, test/query-limit.test.ts and test/explore-q-limit.test.ts all pass. In test/deadends.test.ts, "the findings are the known ones" fails in this sandbox, with and without this change: it reaches for parent.example, which the sandbox blocks. The forge's check runs it. The keep_plan and estimate tools weren't available in this run, so the issue has no plan or estimate recorded.

The desk note asking to hold changes while production rolls doesn't affect this: it's a pull, and nothing reaches production until a person merges it.

To try it: open /explore?q= followed by 5,000 a's while signed out. The page says it searched the first 200 characters, the box holds those 200, and the Sign in link carries only them.

🤖 Generated with Claude Code

commented

<!-- look-pages 6f35a37aa51a --> Look pages for 6f35a37, from the gate:

  • look pages (inferred): this pull changes src/web/chrome.ts, src/web/layout.ts, src/web/return_to.ts; the forge pictures / (src/web/chrome.ts), /docs (src/web/chrome.ts), /explore (src/web/chrome.ts) and 25 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

When someone pastes a very long search into /explore?q= while signed out, it is no longer repeated in every sign-in, sign-up and palette link back to the page. Those links now carry only the first 200 characters (src/web/return_to.ts, src/web/chrome.ts, src/web/layout.ts).

The MCP explore and search tools now check their length limit against the shared MAX_QUERY_CHARS instead of a hard-coded 200 (src/http/mcp/reads.ts, src/http/mcp/tools/explore.ts, src/http/mcp/tools/search.ts). The limit is still 200 characters, so neither the API nor the MCP behaves differently. That is why there is nothing new for the terminal to show, and an empty commit says so with a No door: line. src/tui/ has no search length limit to update. docs/features/explore.md names the limit and every place that applies it.

Locally, bun scripts/gate.ts no longer reports the "both doors" failure, and bun x tsc --noEmit and test/explore-q-limit.test.ts pass (8 tests). The gate still prints its inferred "look pages" line, which only says which pages the forge will picture.

To try it: open /explore?q= followed by 5,000 as while signed out; the Sign in link carries only the first 200.

🤖 Generated with Claude Code

commented

<!-- look-pages 3ff9809a103b --> Look pages for 3ff9809, from the gate:

  • look pages (inferred): this pull changes src/web/chrome.ts, src/web/layout.ts, src/web/return_to.ts; the forge pictures / (src/web/chrome.ts), /docs (src/web/chrome.ts), /explore (src/web/chrome.ts) and 25 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

When someone pastes a very long search into /explore?q= while signed out, it is no longer repeated in every sign-in, sign-up and palette link back to the page. Those links now carry only the first 200 characters (src/web/return_to.ts, src/web/chrome.ts, src/web/layout.ts).

The MCP explore and search tools check their length limit against the shared MAX_QUERY_CHARS instead of a hard-coded 200 (src/http/mcp/reads.ts, src/http/mcp/tools/). The limit is still 200 characters, so the API and the MCP behave the same, and the terminal has nothing new to reach. A No door: line in a commit says so. docs/features/explore.md names the limit and every place that applies it.

test/explore-q-limit.test.ts covers each place the limit applies (8 tests). Those tests, bun x tsc --noEmit and bun scripts/gate.ts pass. The gate now prints look pages (named), because a commit carries a Looks: /explore line. That one page is pictured instead of the 28 the gate had inferred. A query of 200 characters or fewer gives the same links as before, so /explore is the only page whose before and after pictures can differ.

To try it: open /explore?q= followed by 5,000 as while signed out; the Sign in link carries only the first 200.

🤖 Generated with Claude Code

commented

<!-- look-pages 16a0134bbb30 --> Look pages for 16a0134, from the gate:

  • look pages (named): this pull changes src/web/chrome.ts, src/web/layout.ts, src/web/return_to.ts; a commit names /explore
commented

No change was needed this round, so nothing new is pushed. The gate comment for 16a0134 is a note, not a failure. It confirms what the last push set out to do: a commit names /explore as the page to picture, instead of the 28 pages the gate had guessed. Another commit would only bring the same comment back.

When someone pastes a very long search into /explore?q= while signed out, it is no longer repeated in every sign-in, sign-up and palette link back to the page. Those links now carry only the first 200 characters (src/web/return_to.ts, src/web/chrome.ts, src/web/layout.ts).

The MCP explore and search tools check their length limit against the shared MAX_QUERY_CHARS instead of a hard-coded 200 (src/http/mcp/reads.ts, src/http/mcp/tools/). The limit is still 200 characters, so the API and the MCP behave the same, and the terminal has nothing new to reach. A No door: line in a commit says so. docs/features/explore.md names the limit and every place that applies it.

test/explore-q-limit.test.ts covers each place the limit applies (8 tests). Those tests, bun x tsc --noEmit and bun scripts/gate.ts pass. The Looks: /explore line names /explore as the one page to compare. A query of 200 characters or fewer gives the same links as before, so it is the only page whose before and after pictures can differ.

To try it: open /explore?q= followed by 5,000 as while signed out; the Sign in link carries only the first 200.

🤖 Generated with Claude Code

Changes requested — before the latest push

The fix works: on the preview a 5,000-character q now answers about 17 KB, and the links back carry only 200 characters. One thing is left for the box that says the cap is named once. Two things to fix in one round: (1) src/actions/here.ts lines 324, 327 and 361 still cut q with a literal 200 (q.slice(0, 200)). Use cappedQuery or MAX_QUERY_CHARS from src/core/query_limit.ts so the cap is named in one place. (2) src/http/mcp/reads.ts checks .length, which counts UTF-16 units, while queryTooLong and cappedQuery count code points. A 150-emoji q is refused by MCP but accepted by the page and API. Use the shared queryTooLong and say so in the docs. Add a test with a non-BMP q.

commented

When someone pastes a very long search into /explore?q= while signed out, the sign-in, sign-up and palette links back to the page now carry only the first 200 characters (src/web/return_to.ts, src/web/chrome.ts, src/web/layout.ts). On the preview, a 5,000-character q now answers about 17 KB instead of 31 KB.

The limit lives in one place, MAX_QUERY_CHARS in src/core/query_limit.ts, and every way in reads it and counts the same way: characters as code points, after trimming.

  • MCP tools: explore and search now check q, query and cursor with queryTooLong (src/http/mcp/reads.ts). They used to check .length, which counts UTF-16 units, so they refused 150 emoji that the page and the API accepted.
  • Agent actions: the actions an explore, search or docs page lists for agents (src/actions/here.ts) used q.slice(0, 200) in three places; they now use cappedQuery.
  • Docs: docs/features/explore.md names the limit, every place that applies it, and that it counts code points.

test/explore-q-limit.test.ts now also sends emoji:

  • MCP: both tools take 200 emoji and refuse 201. The 200-emoji check fails on the old .length code.
  • API: GET /api/v1/explore and GET /api/v1/search take 200 emoji.

That file and the tests for here.ts and MCP explore all pass (57 tests across 5 files), as do bun x tsc --noEmit and bun scripts/gate.ts. The full suite was not run here because the change reaches about 2,300 test files; the forge runs it on this push.

Two commit lines tell the gate what to expect:

  • Looks: /explore: the page with before and after pictures is /explore, the only page the change shows on.
  • No door:: the terminal gains nothing, because its search has no length limit and the MCP change only makes the tools count like the API.

To try it: open /explore?q= followed by 5,000 as while signed out; the Sign in link carries only the first 200.

🤖 Generated with Claude Code

commented

<!-- look-pages bbf6dfb20d54 --> Look pages for bbf6dfb, from the gate:

  • look pages (named): this pull changes src/web/chrome.ts, src/web/layout.ts, src/web/return_to.ts; a commit names /explore
commented

Gate feedback on bbf6dfb: no code change was needed, so nothing new is pushed. The note look pages (named) means the Looks: /explore line in 16a0134 named the page to picture, which was the intent. On the preview, /explore?q= followed by 5,000 as answers 200 with a 16.9 KB page (31 KB on production), and no run of more than 200 as appears anywhere in it.

---

/explore with a 5,000-character q no longer repeats the whole paste on the page. Most of the issue was already on main from #13862: the 200-character cap in src/core/query_limit.ts, the 422 naming q on /api/v1/explore and /api/v1/search, and the trimmed search box with its one-line note. The 31 KB page came from three links back to the page that copied the address uncut: the sign-in next, the sign-up next and the command palette's Sign in.

  • The fix: a new hereAddress(ctx) in src/web/return_to.ts cuts q to the 200 characters the page actually searched. Both signInHref functions (src/web/chrome.ts, src/web/layout.ts) and returnTo now build from it. An address whose q is within the limit passes through unchanged. src/actions/here.ts now cuts q with cappedQuery instead of a literal 200.
  • MCP: the explore and search tools now use MAX_QUERY_CHARS and queryTooLong, so they count code points like the page and the API. Before, 150 emoji were refused by MCP but accepted by the API.
  • Docs: docs/features/explore.md has a new section, "The longest query", which names the limit and every door that applies it.
  • Tests: test/explore-q-limit.test.ts covers the page, both API endpoints and both MCP tools, including tests with 200 and 201 emoji. The page test fails without the fix. The API tests passed before this change too, because those checks were already in place.
  • Look: /explore. The difference only shows with a q longer than 200 characters. For any shorter q, every sign-in link reads as before.

Not done: /changelog?repo= takes a repository name, not a search query, so the cap doesn't apply to it. The terminal search has no length cap. Production keeps answering 31 KB until this lands.

To try it, open https://lab--14400--forge-trevato-apps.open-platform.sh/explore?q= followed by 5,000 as while signed out. The page is 16.9 KB, and the Sign in link carries only the first 200 characters.

Checks: bun scripts/gate.ts --fix, bun x tsc --noEmit, bun scripts/design-lint.ts, and bun test on test/mcp-size.test.ts, test/query-limit.test.ts and test/explore-q-limit.test.ts all pass. In test/deadends.test.ts, the test "the findings are the known ones" fails in this sandbox with or without this change, because it reaches for parent.example, which the sandbox blocks. The forge's check runs it.

🤖 Generated with Claude Code

Approved

Since 16a0134: MCP checks now use queryTooLong/MAX_QUERY_CHARS (code points, same as page and API), actions/here.ts uses cappedQuery, docs name the limit and the door list, emoji tests added per door. No earlier ask is open. hereAddress passes short queries through unchanged and cuts only an over-limit q. Reuses the existing helpers; no new dependency, no README entry. Non-blocking: the here.ts docs link still slices q to 80, which is harmless.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs