Skip to content

feat(detector): resolve the TanStack Start output directory from the vite config - #13914

Closed
ChiragAgg5k wants to merge 2 commits into
mainfrom
feat/detector-tanstack-output
Closed

ChiragAgg5k wants to merge 2 commits into
mainfrom
feat/detector-tanstack-output

Conversation

@ChiragAgg5k

Copy link
Copy Markdown
Member

TanStackStart::getOutputDirectory() now resolves ./.output or ./dist depending on whether a nitro plugin is both declared in package.json and registered in the vite config, and picks the static assets subdirectory (public / client) from the adapter. getAdapter() now treats a narrowed prerender (routes, filter) or enabled: false as ssr, and matches the prerender block with balanced braces.

Ported from utopia-php/detector#19 after detector moved to packages/detector (#13891).

One adaptation: in packages/detector, Detector\Framework::detect() already parses each manifest into a list of dependency names, so the detection is handed the raw manifests ($manifests) instead of $packages.

Check Result
bin/monorepo check detector (Pint, PHPStan, Rector) passed
bin/monorepo test detector 123 tests, 321 assertions, OK
bin/monorepo validate all packages valid
git diff --check clean

🤖 Generated with Claude Code

@greptile-apps

greptile-apps Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 3/5

[Medium risk] Changes framework detection logic for TanStack Start output paths.

The PR should not merge until config evidence reaches output-path detection and multiple manifests are handled correctly; the explicit repository requirements also need to be satisfied.

Fix All in Claude CodeFindings

  1. P1 Static output paths remain unreachable ▶
  2. P1 Multiple manifests select Nitro output ▶
  3. P2 New regex checks violate guidance ▶
  4. P2 Tests bypass config delivery ▶
Fix with agent prompt
### Issue 1
packages/detector/src/Detection/Framework/TanStackStart.php:50
When Appwrite detects a prerendered TanStack Start repository, it passes `package.json` and file names to the detector but never passes the Vite config content. This call therefore runs with an empty config and always selects `ssr`, reporting `./dist` or `./.output` instead of the static assets directory `./dist/client` or `./.output/public`. The missing config also prevents the plugin-registration check from determining whether Nitro is enabled.

### Issue 2
packages/detector/src/Detector/Framework.php:132
If a caller supplies more than one supported `INPUT_PACKAGES` manifest, joining them with a newline produces a string that cannot be decoded as one JSON document. `usesNitro()` then treats the decode failure as evidence of Nitro, so a TanStack project without Nitro reports `./.output` rather than `./dist`.

### Issue 3
packages/detector/src/Detection/Framework/TanStackStart.php:107-110
The new prerender check uses a recursive `preg_match`, and the Nitro check also adds `preg_replace` and `preg_match`. The repository guide directs contributors not to add regex checks: use string operations or an existing validator, or explain in the PR why neither works. That requirement must be satisfied before merging.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

### Issue 4
packages/detector/tests/DetectorTest.php:825-826
These tests create a framework result and inject Vite config directly, so they pass for static output paths even though the real detection flow never supplies that config. The additional syntax-specific config cases also couple the tests to the parser. The repository instruction requires tests of observable behavior rather than mirrored configuration details; cover the detection-to-output behavior before merging.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR makes TanStack Start’s output directory depend on Nitro dependencies, Vite plugin registration, and prerender configuration, and extends adapter classification for narrowed prerendering.

  • The deployed detection flow does not deliver Vite config content, leaving the new static-output decisions unused.
  • Passing multiple manifests can incorrectly select Nitro output.
  • The added regexes and configuration-focused tests conflict with repository review requirements.

Reviews (1) · Last reviewed commit: "fix(detector): hand TanStack Start the r..."

public function getOutputDirectory(): string
{
return './.output';
$static = $this->getAdapter($this->config) === 'static';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Static output paths remain unreachable
When Appwrite detects a prerendered TanStack Start repository, it passes package.json and file names to the detector but never passes the Vite config content. This call therefore runs with an empty config and always selects ssr, reporting ./dist or ./.output instead of the static assets directory ./dist/client or ./.output/public. The missing config also prevents the plugin-registration check from determining whether Nitro is enabled.

Knowledge Base Used: Runtime detector library

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/detector/src/Detection/Framework/TanStackStart.php
Line: 50

Comment:
**Static output paths remain unreachable**
When Appwrite detects a prerendered TanStack Start repository, it passes `package.json` and file names to the detector but never passes the Vite config content. This call therefore runs with an empty config and always selects `ssr`, reporting `./dist` or `./.output` instead of the static assets directory `./dist/client` or `./.output/public`. The missing config also prevents the plugin-registration check from determining whether Nitro is enabled.

**Knowledge Base Used:** [Runtime detector library](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/appwrite/appwrite/-/docs/runtime-detector-library.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Codex

foreach ($this->options as $detector) {
if ($detector->getName() === $bestFramework) {
$detector->setPackager($this->packager);
$detector->setPackages(\implode("\n", $manifests));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Multiple manifests select Nitro output
If a caller supplies more than one supported INPUT_PACKAGES manifest, joining them with a newline produces a string that cannot be decoded as one JSON document. usesNitro() then treats the decode failure as evidence of Nitro, so a TanStack project without Nitro reports ./.output rather than ./dist.

Knowledge Base Used: Runtime detector library

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/detector/src/Detector/Framework.php
Line: 132

Comment:
**Multiple manifests select Nitro output**
If a caller supplies more than one supported `INPUT_PACKAGES` manifest, joining them with a newline produces a string that cannot be decoded as one JSON document. `usesNitro()` then treats the decode failure as evidence of Nitro, so a TanStack project without Nitro reports `./.output` rather than `./dist`.

**Knowledge Base Used:** [Runtime detector library](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/appwrite/appwrite/-/docs/runtime-detector-library.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Codex

Comment on lines +107 to +110
\preg_match('/\bprerender[\x27\x22]?\s*:\s*(\{(?:[^{}]|(?1))*\})/s', $stripped, $prerender);

// Listing routes, filtering them, or switching it off all leave part of the site to a server.
if (\preg_match('/\b(?:routes|filter)[\x27\x22]?\s*:|\benabled[\x27\x22]?\s*:\s*false\b/', $prerender[1] ?? '')) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 New regex checks violate guidance
The new prerender check uses a recursive preg_match, and the Nitro check also adds preg_replace and preg_match. The repository guide directs contributors not to add regex checks: use string operations or an existing validator, or explain in the PR why neither works. That requirement must be satisfied before merging.

Context Used: CLAUDE.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/detector/src/Detection/Framework/TanStackStart.php
Line: 107-110

Comment:
**New regex checks violate guidance**
The new prerender check uses a recursive `preg_match`, and the Nitro check also adds `preg_replace` and `preg_match`. The repository guide directs contributors not to add regex checks: use string operations or an existing validator, or explain in the PR why neither works. That requirement must be satisfied before merging.

**Context Used:** CLAUDE.md ([source](https://github.com/appwrite/appwrite/blob/main/CLAUDE.md))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Codex

Comment on lines +825 to +826
$this->assertSame('./.output/public', (new TanStackStart())->setPackages($nitro)->setConfig($nitroPrerender)->getOutputDirectory());
$this->assertSame('./dist/client', (new TanStackStart())->setPackages($plain)->setConfig($prerender)->getOutputDirectory());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Tests bypass config delivery
These tests create a framework result and inject Vite config directly, so they pass for static output paths even though the real detection flow never supplies that config. The additional syntax-specific config cases also couple the tests to the parser. The repository instruction requires tests of observable behavior rather than mirrored configuration details; cover the detection-to-output behavior before merging.

Context Used: Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/detector/tests/DetectorTest.php
Line: 825-826

Comment:
**Tests bypass config delivery**
These tests create a framework result and inject Vite config directly, so they pass for static output paths even though the real detection flow never supplies that config. The additional syntax-specific config cases also couple the tests to the parser. The repository instruction requires tests of observable behavior rather than mirrored configuration details; cover the detection-to-output behavior before merging.

**Context Used:** Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Codex

@github-actions

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → feat/detector-tanstack-output (after).

Metric Before After Change
🚀 Requests/sec 201.67 207.99 ⚪ +3.1%
⏱️ Latency P50 86.44 ms 83.01 ms ⚪ -4%
⏱️ Latency P95 197.44 ms 199.37 ms ⚪ +1%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 83.01 199.37 12,882 207.99 +1.92
Account 160.25 306.78 678 11.25 -10.69
TablesDB 79.18 144.99 7,006 114.88 -21.07
Storage 78.16 171.71 3,390 57.86 +9.91
Functions 120 256.29 1,808 31.38 +18.77

Top API waits (after)

API request Max wait (ms)
account.name.update 494.09
account.prefs.update 410.8
storage.buckets.create 387.1
functions.create 384.83
functions.variables.create 365.68

@ChiragAgg5k

Copy link
Copy Markdown
Member Author

@HarshMN2345 your utopia-php/detector#19 is ported here, now that detector lives in packages/detector. You're credited as co-author.

@ChiragAgg5k

Copy link
Copy Markdown
Member Author

Closing this port. @HarshMN2345, re-open it if you still want the change in packages/detector.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant