Skip to content

[codex] fix 5chan hash redirect behind daemon#61

Open
tomcasaburi wants to merge 1 commit into
masterfrom
codex/fix-5chan-hash-router
Open

[codex] fix 5chan hash redirect behind daemon#61
tomcasaburi wants to merge 1 commit into
masterfrom
codex/fix-5chan-hash-router

Conversation

@tomcasaburi
Copy link
Copy Markdown
Member

@tomcasaburi tomcasaburi commented May 30, 2026

Summary

  • Strip 5chan's inline root hash redirect by matching the actual window.location.replace('/#' + window.location.pathname + window.location.search) call instead of relying on the old comment text.
  • Tighten the daemon web UI regression test so it fails if that root redirect is served again.

Root Cause

5chan v0.8.5 changed the surrounding normalization-script comment, so the existing CLI regex no longer removed the script. Behind the daemon, that script can navigate to /#..., which targets the Express root instead of the auth-key web UI route.

Validation

  • npm run build
  • npm run build:test
  • npm run ci:download-web-uis
  • npx vitest run --config config/vitest.config.ts test/cli/daemon.test.ts -t "5chan webui does not contain the root hash redirect script"

Note

Low Risk
Localized change to HTML preprocessing and a CLI test; no auth, RPC, or data-path behavior changes.

Overview
Fixes 5chan being served behind the daemon with an inline root hash redirect still present after a web UI update changed the script’s comment text, so the old strip regex no longer matched.

daemon-server.ts now removes the whole <script> block by matching the actual window.location.replace('/#' + pathname + search) call instead of the obsolete “Redirect non-hash URLs” comment. The daemon web UI test was updated to assert that redirect snippet is absent from served HTML.

Reviewed by Cursor Bugbot for commit 82b53fc. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Bug Fixes
    • Updated URL redirect handling in the web UI daemon to use more precise script pattern matching.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2e178a5d-c1e9-45b7-8548-dcc65eab4f0d

📥 Commits

Reviewing files that changed from the base of the PR and between 95aec49 and 82b53fc.

📒 Files selected for processing (2)
  • src/webui/daemon-server.ts
  • test/cli/daemon.test.ts

📝 Walkthrough

Walkthrough

The PR refines the script removal logic in the daemon webui HTML generation. A new rootHashRedirectScriptPattern constant provides a more precise regex targeting window.location.replace("/#" + window.location.pathname + window.location.search) behavior. The corresponding test assertion is updated to verify this specific pattern is absent from generated HTML.

Changes

Root-hash redirect script removal

Layer / File(s) Summary
Root-hash redirect script pattern definition and removal
src/webui/daemon-server.ts, test/cli/daemon.test.ts
rootHashRedirectScriptPattern constant targets a specific root-hash redirect <script> block. The HTML generation function uses this refined pattern, and the daemon webui test asserts the pattern is absent from the /5chan page response.

🎯 2 (Simple) | ⏱️ ~8 minutes

🐰 A script that redirects now has rules so precise,
Root-hash patterns captured, clean and concise,
Tests verify the removal, working just right,
Webui flows cleaner through day and through night! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main change: fixing 5chan's hash redirect when running behind the daemon by updating the script removal logic.
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.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-5chan-hash-router

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/webui/daemon-server.ts

Oops! Something went wrong! :(

ESLint: 8.27.0

Error: ESLint configuration in --config » eslint-config-oclif is invalid:

  • Unexpected top-level property "__esModule".

Referenced from: /.eslintrc
at ConfigValidator.validateConfigSchema (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2156:19)
at ConfigArrayFactory._normalizeConfigData (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2998:19)
at ConfigArrayFactory._loadConfigData (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2963:21)
at ConfigArrayFactory._loadExtendedShareableConfig (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3264:21)
at ConfigArrayFactory._loadExtends (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3135:25)
at ConfigArrayFactory._normalizeObjectConfigDataBody (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3074:25)
at _normalizeObjectConfigDataBody.next ()
at ConfigArrayFactory._normalizeObjectConfigData (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3019:20)
at _normalizeObjectConfigData.next ()
at ConfigArrayFactory.loadFile (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2829:16)

test/cli/daemon.test.ts

Oops! Something went wrong! :(

ESLint: 8.27.0

Error: ESLint configuration in --config » eslint-config-oclif is invalid:

  • Unexpected top-level property "__esModule".

Referenced from: /.eslintrc
at ConfigValidator.validateConfigSchema (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2156:19)
at ConfigArrayFactory._normalizeConfigData (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2998:19)
at ConfigArrayFactory._loadConfigData (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2963:21)
at ConfigArrayFactory._loadExtendedShareableConfig (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3264:21)
at ConfigArrayFactory._loadExtends (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3135:25)
at ConfigArrayFactory._normalizeObjectConfigDataBody (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3074:25)
at _normalizeObjectConfigDataBody.next ()
at ConfigArrayFactory._normalizeObjectConfigData (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3019:20)
at _normalizeObjectConfigData.next ()
at ConfigArrayFactory.loadFile (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2829:16)


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@tomcasaburi tomcasaburi marked this pull request as ready for review May 30, 2026 05:15
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