fix: address second round of PR review bot findings

cursor[bot]:
- style: directives with dynamic values now fall back to source-preview
  instead of being scaffolded as boolean condition props that falsified
  the style in the detached preview.
- class: directives carry a className probe, so v2 hydration answers the
  condition from the live DOM instead of always defaulting to false.
- The existing-wrapper remount path now checks the mount result; a failed
  remount keeps the error card instead of advancing to a CYCLING bar over
  a page where nothing rendered.

greptile-apps[bot]:
- The repo-root live pointer records every booted app (most recent
  first) and resolution prefers the app whose helper server is alive, so
  a helper run from the repo root of a two-app monorepo can no longer be
  redirected onto the wrong app's session store by the last boot. Legacy
  single-value pointers still read.

This work was produced with AI assistance (Claude Code).

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
Paul Bakaus
2026-07-27 15:34:57 -07:00
co-authored by Claude Code
parent 2d66c9acf1
commit a6f965e8bf
5 changed files with 145 additions and 12 deletions
+45 -8
View File
@@ -258,11 +258,45 @@ export function writeRootsManifest(manifest) {
if (path.resolve(manifest.repoRoot) !== path.resolve(manifest.appRoot)) {
const pointer = pointerFilePath(manifest.repoRoot);
fs.mkdirSync(path.dirname(pointer), { recursive: true });
fs.writeFileSync(pointer, JSON.stringify({ appRoot: manifest.appRoot }));
// The pointer records EVERY app that has booted live in this repo, most
// recent first. A single last-boot-wins value made a helper run from the
// repo root silently target whichever app booted last, even while an
// earlier app's session was the one still live.
const entries = readPointerEntries(manifest.repoRoot)
.filter((entry) => path.resolve(entry.appRoot) !== path.resolve(manifest.appRoot));
entries.unshift({ appRoot: manifest.appRoot, bootedAt: new Date().toISOString() });
fs.writeFileSync(pointer, JSON.stringify({ version: 2, appRoots: entries }));
}
return file;
}
function readPointerEntries(repoRoot) {
try {
const raw = JSON.parse(fs.readFileSync(pointerFilePath(repoRoot), 'utf-8'));
if (Array.isArray(raw?.appRoots)) {
return raw.appRoots.filter((entry) => entry && typeof entry.appRoot === 'string');
}
// v1 shape: a single { appRoot } value.
if (raw && typeof raw.appRoot === 'string') return [{ appRoot: raw.appRoot }];
return [];
} catch {
return [];
}
}
/** True when the app's live helper server is recorded and its pid is alive. */
function hasLiveServer(appRoot) {
try {
const info = JSON.parse(fs.readFileSync(path.join(appRoot, '.impeccable', 'live', 'server.json'), 'utf-8'));
if (!info || typeof info.pid !== 'number') return false;
process.kill(info.pid, 0);
return true;
} catch (err) {
// EPERM: the process exists but is not signalable by this user.
return err?.code === 'EPERM';
}
}
function readManifestAt(appRoot) {
try {
const raw = JSON.parse(fs.readFileSync(rootsFilePath(appRoot), 'utf-8'));
@@ -297,13 +331,16 @@ export function resolveLiveRoots(cwd = process.cwd(), { targetPath = null } = {}
const gitRoot = findGitRoot(absCwd);
if (gitRoot) {
try {
const pointer = JSON.parse(fs.readFileSync(pointerFilePath(gitRoot), 'utf-8'));
if (pointer && typeof pointer.appRoot === 'string') {
const viaPointer = readManifestAt(pointer.appRoot);
if (viaPointer) return { manifest: viaPointer, source: 'pointer' };
}
} catch { /* no pointer */ }
// Several apps in one repo may have booted live. Prefer the one whose
// helper server is actually running; a stale pointer entry must not
// redirect status/poll/accept onto the wrong app's session store.
const candidates = readPointerEntries(gitRoot)
.map((entry) => readManifestAt(entry.appRoot))
.filter(Boolean);
if (candidates.length > 0) {
const live = candidates.find((manifest) => hasLiveServer(manifest.appRoot));
return { manifest: live || candidates[0], source: 'pointer' };
}
}
}