Skip to content

[luv-336] fix: route OpenCode project pages by encoded cwd; drop ## Unreleased from changelog#335

Merged
NiveditJain merged 4 commits intomainfrom
luv-336
May 9, 2026
Merged

[luv-336] fix: route OpenCode project pages by encoded cwd; drop ## Unreleased from changelog#335
NiveditJain merged 4 commits intomainfrom
luv-336

Conversation

@NiveditJain
Copy link
Copy Markdown
Member

@NiveditJain NiveditJain commented May 9, 2026

Summary

Fix the OpenCode project-page 404

  • lib/opencode-projects.ts: set ProjectFolder.name to encodeFolderName(worktree) (matches every other CLI's URL-slug encoding) instead of proj.name/basename(worktree). Fixes a 404 on the project detail page for OpenCode-only sessions — e.g. /home/nivedit/dev-purge was being linked as /project/dev-purge, but the route resolver getOpenCodeSessionsByEncodedName matches via encodeFolderName(p.worktree) === name and so expected /project/-home-nivedit-dev-purge (which is the form that already worked for session URLs built via encodeCwdForUrl(cwd) in app/policies/hooks-client.tsx).
  • Side benefit: mergeProjectFolders keys by f.name, so an OpenCode project sharing a cwd with Claude/Codex/Copilot/Cursor/Pi/Gemini now collapses into a single Projects-page row with multiple CLI badges instead of appearing as two rows.
  • Display via decodeFolderName(folder.name) in the Projects list now renders the full path (/home/nivedit/dev-purge) instead of dev/purge, consistent with every other CLI.

Drop ## Unreleased — every feature PR ships release-ready

  • .failproofai/policies/workflow-policies.mjs:
    • new release-prep-check policy fires on gh pr create and instructs the agent to ensure CHANGELOG entries land under a versioned ## <version> — <YYYY-MM-DD> heading (creating that heading above the previous version's section if needed)
    • changelog-check updated to drop the ## Unreleased reference
    • all four workflow policies (changelog-check, docs-check, pr-description-check, release-prep-check) now route their verb-phrase match through a shared matchesCommand helper that anchors to command boundaries (^, ;, &&, ||, |, newline) so the literal phrases no longer false-positive when they appear inside HEREDOC bodies or quoted arguments (concrete repro: gh pr edit --body "...gh pr create..." previously fired release-prep-check)
  • CHANGELOG.md: drop the empty ## Unreleased heading; this PR's entry sits directly under ## 0.0.10-beta.10 — 2026-05-09
  • CLAUDE.md: update the Changelog section to describe the new no-Unreleased flow
  • Version bumps in package.json remain reserved for luv-cut-* PRs by the existing block-version-bumps policy

Test plan

  • bun run test:run — 1573/1573 unit tests pass (3 assertions in __tests__/lib/opencode-projects.test.ts updated to pin the encoded form -repo / -other)
  • bun run lint — clean
  • bun x tsc --noEmit — clean
  • bun run build — clean
  • release-prep-check fires correctly on real gh pr create and no longer false-positives on gh pr edit with backticked phrases in the body (verified live)
  • Visit /projects in the dashboard, click an OpenCode-only project — should land on /project/<encoded-cwd> (no 404) and list its OpenCode sessions
  • Confirm a project with both OpenCode and another CLI now shows as one row with two CLI badges

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • OpenCode projects use a consistent encoded folder-name across the app, fixing routing, display and duplicate-project listings.
  • Documentation
    • CHANGELOG guidance updated to require dated, versioned release headings and removed the top-level "Unreleased" section.
  • Chores
    • Added a release-prep policy and tightened workflow checks to match command phrases only at command boundaries to avoid false positives.
  • Tests
    • Updated tests to expect the encoded project-name behavior.

Review Change Stack

Align `ProjectFolder.name` for OpenCode projects with the URL-slug
encoding every other CLI uses (`encodeFolderName(worktree)`), replacing
the prior `proj.name`/`basename(worktree)` fallback. Fixes a 404 on the
project page for OpenCode-only sessions (e.g. /project/dev-purge → 404)
while session URLs already worked via `encodeCwdForUrl(cwd)`. As a side
benefit, OpenCode projects now merge with their Claude/Codex/Copilot/
Cursor/Pi/Gemini siblings into one row in `mergeProjectFolders`.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 61a8f41d-8306-4a35-be1a-19b504d0623d

📥 Commits

Reviewing files that changed from the base of the PR and between c1e68c9 and d3bc773.

📒 Files selected for processing (1)
  • CHANGELOG.md

📝 Walkthrough

Walkthrough

Exports for OpenCode projects now compute folder name from URL-encoded worktree paths (encodeFolderName(worktree)); tests updated to expect encoded names. CHANGELOG/CLAUDE require dated version headings. Workflow policies add a matchesCommand helper and a release-prep-check enforcing changelog heading placement.

Changes

OpenCode Folder-Name Encoding Standardization

Layer / File(s) Summary
Documentation & Contract
CHANGELOG.md, CLAUDE.md, lib/opencode-projects.ts
CHANGELOG adds 0.0.10-beta.10 — 2026-05-09 and removes ## Unreleased; contributor guidance and in-code comment updated to require exported name = encodeFolderName(worktree) or projectId fallback.
Core Encoding Logic
lib/opencode-projects.ts
getOpenCodeProjects() now computes ProjectFolder.name from encodeFolderName(worktree) when present, otherwise uses projectId; applies to grouped-session and session-less projects.
Test Assertions
__tests__/lib/opencode-projects.test.ts
Tests updated to expect encoded worktree names (e.g., "/repo""-repo") in grouped and no-session cases.
Workflow Policy
.failproofai/policies/workflow-policies.mjs
Added matchesCommand boundary-aware matcher; changelog-check text requiring versioned, dated CHANGELOG headings updated; docs-check and pr-description-check use matchesCommand; new release-prep-check validates changelog heading placement on gh pr create.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I hopped through folders, paths to mend,
I curled the slashes, made each name bend—
Encoded trails now line the way,
Policies guard changelogs each day—
Tests cheer as projects find their end!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description is comprehensive with detailed context; however, it deviates from the provided template structure lacking the required Type of Change and Checklist sections. Follow the repository's PR description template by including Type of Change checkboxes and a verification Checklist section for consistency with repository standards.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes both main changes: fixing OpenCode project routing by encoded cwd and dropping the Unreleased changelog section.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CHANGELOG.md`:
- Line 6: The changelog entry on line 6 is overly detailed; replace the long
paragraph with a single concise one-line bullet that summarizes the change and
references the PR (e.g., "Align OpenCode project folder naming with CLI URL
encoding to fix project links and merging (`#336`)"), and move the implementation
details (references to lib/opencode-projects.ts ProjectFolder.name,
encodeFolderName(worktree), getOpenCodeSessionsByEncodedName,
mergeProjectFolders, decodeFolderName(folder.name), and related test updates in
__tests__/lib/opencode-projects.test.ts) into the PR description or commit
message instead of the CHANGELOG.md.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d25c167e-5db4-4fd0-be9b-7f102bc732f3

📥 Commits

Reviewing files that changed from the base of the PR and between 4f41a97 and 75497b5.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • __tests__/lib/opencode-projects.test.ts
  • lib/opencode-projects.ts

Comment thread CHANGELOG.md Outdated
Switches the changelog convention so every feature PR's entry lands
directly under a versioned `## <version> — <YYYY-MM-DD>` section
(matching package.json's current version + today's date). The `##
Unreleased` heading is gone — feature PRs already ship release-ready,
so a separate cut PR is no longer required for the changelog rename.

- `.failproofai/policies/workflow-policies.mjs`:
  - new `release-prep-check` policy fires on `gh pr create` and
    instructs the agent to put entries under a dated versioned heading,
    creating that heading above the previous version's section if needed
  - `changelog-check` updated to drop the `## Unreleased` reference
- `CHANGELOG.md`: drop the empty `## Unreleased` heading; this PR's
  entry now sits directly under `## 0.0.10-beta.10 — 2026-05-09`
- `CLAUDE.md`: update the Changelog section to describe the new
  no-`Unreleased` flow

Version bumps in `package.json` remain reserved for `luv-cut-*` PRs by
the existing `block-version-bumps` policy.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@NiveditJain NiveditJain changed the title [luv-336] fix: route OpenCode project pages by encoded cwd, not basename [luv-336] fix: route OpenCode project pages by encoded cwd; drop ## Unreleased from changelog May 9, 2026
NiveditJain and others added 2 commits May 9, 2026 16:10
The `release-prep-check`, `changelog-check`, `docs-check`, and
`pr-description-check` policies used unanchored regexes against the
Bash command string, so the literal phrases (`gh pr create`,
`git commit`, `git push`) matched anywhere — including inside HEREDOC
bodies or quoted arguments. Concrete failure: editing a PR body that
contained the words "gh pr create" inside backticks fired the new
`release-prep-check` policy on the `gh pr edit` invocation.

Extracts a shared `matchesCommand(cmd, verbPattern)` helper that
anchors the verb-phrase match to a command boundary (`^`, `;`, `&&`,
`||`, `|`, or newline). All four policies route through it.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Per CLAUDE.md:425-435 the changelog convention is one short line per
entry with the PR number; the prior verbose paragraph form has been
trimmed to match. Implementation detail lives in commit messages and
the PR description. CodeRabbit flagged the previous verbosity on PR
#335.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@NiveditJain NiveditJain merged commit 3703ff0 into main May 9, 2026
9 checks passed
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