Skip to content

用sonnet4.6重写把后端改成nodejs#409

Open
hjyssg wants to merge 207 commits into
dev-vibecodingfrom
nodejs-backend
Open

用sonnet4.6重写把后端改成nodejs#409
hjyssg wants to merge 207 commits into
dev-vibecodingfrom
nodejs-backend

Conversation

@hjyssg
Copy link
Copy Markdown
Owner

@hjyssg hjyssg commented Feb 20, 2026

python不知道为什么会害windows狂删AppData。害我重装系统两次。
正好测试一下sonnet 4.6的实力。

@hjyssg
Copy link
Copy Markdown
Owner Author

hjyssg commented Feb 20, 2026

开始时间是0220的23:30,测试一下。一万多行 重写要多久。

@hjyssg hjyssg changed the title 用sonnet4.6重写把后端改成nodej 用sonnet4.6重写把后端改成nodejs Feb 20, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 04435cc1bb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread backendnode/src/routes/history.ts Outdated
Comment on lines +71 to +72
app.get("", listHistory);
app.post("", upsertProgress);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Expose history handlers on /list and /record

Both handlers are mounted at the history prefix root, so the backend only serves GET/POST /api/v1/history, but the current frontend and generated client call GET /api/v1/history/list and POST /api/v1/history/record (see frontend/src/routes/_layout/history.tsx and frontend/src/routes/_layout/read.tsx). This mismatch makes history fetch/save fail as soon as the Node backend is used.

Useful? React with 👍 / 👎.

Comment thread backendnode/src/routes/settings.ts Outdated
Comment on lines +6 to +8
fs_roots: config.FS_ROOTS
? config.FS_ROOTS.split(",").map(r => r.trim()).filter(Boolean)
: [],
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Return fs_roots in settings as a string

The settings response now serializes fs_roots as an array, but the existing UI expects a comma-separated string and immediately calls .split(",") (frontend/src/routes/_layout/settings.tsx), so a non-empty response will throw value.split is not a function and break settings rendering. Keeping wire format compatible avoids a client runtime error.

Useful? React with 👍 / 👎.

Comment thread backendnode/src/routes/settings.ts Outdated
}

export async function settingsRoutes(app: FastifyInstance) {
app.get("", getSettings);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Register a PUT handler for /api/v1/settings

Only GET is registered for this route, but the settings page persists changes with PUT /api/v1/settings (frontend/src/routes/_layout/settings.tsx), so saving FS roots/favorite/already-read paths cannot work against this backend. This is a functional API regression for user settings updates.

Useful? React with 👍 / 👎.

Comment thread backend/src/app.ts
Comment on lines +66 to +69
app.setNotFoundHandler((_req, reply) => {
const indexPath = path.join(frontendDist, "index.html");
if (fs.existsSync(indexPath)) {
return reply.type("text/html").send(fs.createReadStream(indexPath));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Bypass SPA index fallback for unmatched API routes

When frontend/dist exists, the global not-found handler serves index.html for every unknown path, including /api/..., so missing API endpoints return HTML with status 200 instead of a JSON 404. That causes API consumers to fail with parse/runtime errors and hides which endpoint is actually unsupported.

Useful? React with 👍 / 👎.

Comment thread backendnode/src/utils/fileType.ts Outdated
Comment on lines +11 to +12
export function getExt(filepath: string): string {
return path.extname(filepath).toLowerCase();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Detect .tar.gz archives before calling extname

getExt relies on path.extname, which only returns the final suffix (e.g. .gz for file.tar.gz), so ARCHIVE_SUFFIXES entry .tar.gz is never matched in getFileType. As a result .tar.gz files are misclassified as unknown, and archive-specific behavior is skipped for them.

Useful? React with 👍 / 👎.

@hjyssg
Copy link
Copy Markdown
Owner Author

hjyssg commented Feb 20, 2026

连续长时间写,ai会注意力丢失。
我叫他模仿python版本写。但它会偷偷写一个简化版。thumbnail的逻辑是简化的。

hjy added 23 commits February 21, 2026 02:06
**IO与后端性能:** `Promise.all()` 并行化目录 stat 操作;schema.sql 添加 13 个索引覆盖所有 WHERE/JOIN 字段;所有列表接口强制分页(带 max cap);文件服务全部使用 `createReadStream` 流式处理。

**代码质量与UT:** 新增 history、parse、recService、repository-boundary 四个测试文件,修复 fs.test.ts 的 5 个失败(改用 `fs.promises` 异步 mock),全部 12 个测试文件 230 个用例通过。

**对接与类型安全:** 前端广泛使用 `?.` 可选链;消除了 `settings.tsx` 和 `useFileNavigation.ts` 中的 `as any`,后端源码零 `any`;全局错误通过 `QueryCache/MutationCache` 的 `onError` + `showErrorToast` 实现透传。

额外:应用户要求,用 `p-limit` 为 thumbnail 生成(并发 3)和 archive 解压(并发 2)加入了 HDD 保护。
- `files` 表保留历史记录,通过 `is_missing` 标志位 + `last_seen_at` 时间戳区分"存在"和"已消失"
- `scanDirectory` 扫描每个目录后调用 `markMissingInFolder`,将磁盘上消失的文件标记为 `is_missing=1`,保留记录不删除
- 搜索端通过 `presence_filter` 控制结果范围:默认只返回存在的文件(`is_missing=0`),`all` 含历史记录,`watched` 只返回有观看进度的,`scanned_recent` 只返回 10 分钟内扫描到的
- 清理了所有废弃字段引用(`fingerprint`/`scan_state`)和已废弃的 `syncFileTable` 接口(前后端均已移除)
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