-
Notifications
You must be signed in to change notification settings - Fork 5.4k
fix(web): chat pane preserves scroll position when todo card grows #2299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
13f4a39
9cd6d58
bd284df
d27ee6c
361f91d
619d138
57a6b95
d3c315c
ddad708
2c04814
ef67f4e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import type { NextConfig } from 'next'; | ||
| import { existsSync, realpathSync } from 'node:fs'; | ||
| import { networkInterfaces } from 'node:os'; | ||
| import { dirname, isAbsolute, relative } from 'node:path'; | ||
| import { dirname, isAbsolute, relative, resolve } from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| // Daemon port the local Express server binds to (see apps/daemon/src/cli.ts). The | ||
|
|
@@ -23,7 +24,52 @@ const isServerOutput = webOutputMode === 'server' || webOutputMode === 'standalo | |
| const shouldStaticExport = isProd && !isServerOutput; | ||
|
|
||
| const WEB_ROOT = dirname(fileURLToPath(import.meta.url)); | ||
| const WORKSPACE_ROOT = dirname(dirname(WEB_ROOT)); | ||
|
|
||
| function resolveWorkspaceRoot(): string { | ||
| const computed = dirname(dirname(WEB_ROOT)); | ||
| const override = process.env.OD_WORKSPACE_ROOT; | ||
| if (override && override.trim()) { | ||
| const resolved = isAbsolute(override.trim()) ? override.trim() : resolve(WEB_ROOT, override.trim()); | ||
| if (!existsSync(resolved)) { | ||
| throw new Error( | ||
| `OD_WORKSPACE_ROOT="${override}" resolved to "${resolved}" which does not exist. ` + | ||
| `Fix the path or unset the variable to use the computed default.`, | ||
| ); | ||
| } | ||
| // Canonicalize via realpathSync so that symlinked paths (e.g. macOS | ||
| // /tmp → /private/tmp) compare correctly against WEB_ROOT. | ||
| const canonicalResolved = realpathSync(resolved); | ||
| const canonicalWebRoot = realpathSync(WEB_ROOT); | ||
| const rel = relative(canonicalResolved, canonicalWebRoot); | ||
| // rel.startsWith('..') catches the non-ancestor case on POSIX. | ||
| // isAbsolute(rel) catches the Windows cross-drive case where relative() | ||
| // returns an absolute path (e.g. C:\repo\apps\web) instead of a ..-path. | ||
| if (rel.startsWith('..') || isAbsolute(rel)) { | ||
| throw new Error( | ||
| `OD_WORKSPACE_ROOT="${override}" resolved to "${canonicalResolved}" but WEB_ROOT "${canonicalWebRoot}" ` + | ||
| `is not inside it (relative path "${rel}"). ` + | ||
| `The override must be an ancestor of apps/web.`, | ||
| ); | ||
| } | ||
|
Comment on lines
+33
to
+53
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| // Require the resolved path to be a real pnpm workspace root. Without this, | ||
| // an ancestor like `<repo>/apps` would pass the relative-path check but | ||
| // miss the sibling `packages/*` directory that `apps/web` imports from | ||
| // (for example `@open-design/contracts`), and Next would later fail deep | ||
| // inside file tracing / Turbopack with a much harder-to-diagnose error. | ||
| if (!existsSync(resolve(canonicalResolved, 'pnpm-workspace.yaml'))) { | ||
| throw new Error( | ||
| `OD_WORKSPACE_ROOT="${override}" resolved to "${canonicalResolved}" but no ` + | ||
| `pnpm-workspace.yaml was found there. The override must point at the ` + | ||
| `pnpm workspace root so outputFileTracingRoot and turbopack.root can ` + | ||
| `resolve sibling packages.`, | ||
| ); | ||
| } | ||
| return canonicalResolved; | ||
| } | ||
| return computed; | ||
| } | ||
|
|
||
| const WORKSPACE_ROOT = resolveWorkspaceRoot(); | ||
| const toPosixPath = (value: string) => value.replaceAll('\\', '/'); | ||
|
|
||
| function resolveDistDir(defaultValue: string) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔁 Powered by Looper · runner=reviewer · agent=opencode · An autonomous AI dev team for your GitHub repos.OD_WORKSPACE_ROOTis still treated as valid as soon as it is non-blank, even though this branch introduced it specifically as a config override. If the value points at a missing directory or a directory that does not actually containapps/web, Next will fail later inside file tracing / Turbopack with a much harder-to-diagnose error instead of failing at config load time. The evidence is inresolveWorkspaceRoot(): the override is trimmed and resolved, but never checked for existence or containment before being assigned tooutputFileTracingRootandturbopack.root. Please validate the resolved path here (for example,stat/realpathit and throw when it does not exist or whenrelative(resolvedRoot, WEB_ROOT)escapes the root) so this new override follows the repo's fail-fast rule.