web: adding a new project for a dashed folder name falls back to "/" project

未关闭
#62,776 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript
领域
frontend

调研方向

Start by reading packages/app/src/pages/session.tsx, which the issue identifies as decoding the dir URL parameter and falling back to the server directory. Trace how the web UI encodes and sends the selected project path, then check the related tests or add-project flow for coverage. Done when a dashed directory opens as its own project and no / project is created.

由索引模型根据 Issue 内容生成。

描述

Summary

Adding a brand-new project folder to the web UI via "new project" silently lands on the root / project instead of the requested directory. Reproduced with a folder whose name contains a dash (~/doom-scroller); an otherwise-identical no-dash control folder works on the first try. Impact: new projects with dashed names cannot be created from the web UI at all, and a stray / project is left behind that the API cannot delete.

Environment

  • opencode version: v2.2.5 (pacman package opencode 2.2.5-1.1, Arch/CachyOS official build)
  • OS: Linux 7.3.1-1-cachyos x86_64
  • Terminal: Browser web UI (served by opencode serve --port 4096 --hostname 0.0.0.0 running as a systemd user service with no WorkingDirectory=, so the server process CWD is /)
  • Shell: /bin/fish
  • Install/channel: release (official repo package)
  • Active plugins: none configured

Reproduction

  1. Start the server: opencode serve --port 4096 --hostname 0.0.0.0 (e.g. systemd user unit; no WorkingDirectory set).
  2. Create a new directory with a dash in the name: mkdir ~/doom-scroller (tried both plain and after git init — same result).
  3. Open the web UI and try to add ~/doom-scroller as a new project.
  4. Observe: the root project / is added/activated instead; no doom-scroller project entry is ever created in GET /api/project.
  5. Control: mkdir ~/Music (no dash, also not a git repo) and add via the same flow → works immediately, project entry created.

Expected Behavior

The web UI creates/opens a session on a project for the directory the user chose (/home/<user>/doom-scroller).

Actual Behavior

The root project / (the server process's CWD) is added/activated instead — one second after the server momentarily initialized the correct directory. The requested project never appears in the project picker.

Additional Context

Server journal (journalctl --user -u opencode-web) shows the correct path arriving, then a fallback one second later:

12:04:50 INFO spawning process { ... cwd: "/home/<user>/doom-scroller" }   # correct — UI sent the right path
12:04:51 INFO spawning process { ... cwd: "/" }                            # 1s later — fell back to server CWD
12:05:32 INFO spawning process { ... cwd: "/home/<user>/Music" }           # no-dash control — success

Suspected mechanism, matching previously reported issues:

  • #12918 identified packages/app/src/pages/session.tsx doing const projectDirectory = decode64(params.dir) ?? sdk.directory — when the base64 URL parameter fails to decode, it silently falls back to the server's base directory.
  • #14445 / #6336: opencode serve uses / as its base directory — which is exactly where this bug lands.
  • #18593 / #15719: other users report the same stray / "ghost" project in the picker; GET /api/project exposes only GET + PATCH (no delete), so it cannot be cleaned up via API either.

Frequency: consistent — failed on 3+ attempts with the dashed folder (git and non-git); the no-dash control succeeded on the first attempt every time. The dash is inferred from this A/B comparison (one dashed vs one no-dash folder); other special characters not tested.

Workaround that works reliably: start any session in the directory once from the CLI (cd ~/doom-scroller && opencode run "hi") — the project is registered server-side and immediately appears and works in the web UI picker.

主要语言
TypeScript
星标
225k
派生
30.4k
平均合并
4 小时 16 分钟
30 天内合并 PR
528

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

anomalyco/opencode 的其他 Issue

查看 anomalyco/opencode 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。