Conversation
Co-authored-by: DaehoYang <129835752+DaehoYang@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Improve rootPath implementation for better stability and maintainability
Improve rootPath implementation with fallback strategy and refactoring
Feb 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Addresses instability in rootPath functionality by implementing automatic fallback and eliminating code duplication.
Core Changes:
Fallback Strategy:
createStaticOrProxyHandler()serves local build when available, proxies toapp.opencode.aiotherwise. WhenrootPathis set, local build is required (no fallback) - throws clear error if missing.Deduplication: Extracted common routing logic into
createAppWithRoutes(), eliminating ~40 lines of duplicated setup between rootPath and non-rootPath modes.Test Coverage: Added 9 tests covering special characters, URL normalization edge cases, WebSocket paths, and fallback behavior.
Constants: Hardcoded paths moved to
APP_DIST_PATH,APP_INDEX_PATH,REMOTE_PROXY_URL.Behavior Matrix:
Example:
No breaking changes. Security measures (XSS prevention, CSP headers) preserved.
How did you verify your code works?
Original prompt
목표
기존 rootPath 구현을 개선하여 기존 사용자에게 영향을 주지 않으면서도 안정성과 유지보수성을 높입니다.
주요 개선 사항
1. Fallback 전략 구현 (최우선)
현재 문제:
해결 방안:
packages/opencode/src/server/server.ts에 다음 로직 추가:rootPath 사용 시 로컬 빌드 강제:
2. server.ts 리팩토링 - 중복 제거
현재 문제:
해결 방안:
3. 포괄적인 테스트 추가
packages/opencode/test/server/rootpath.test.ts에 다음 테스트 추가: