Repository navigation
feat(reasonix): embed reasonix web chat UI as an instance kind (MVP) - #50
Merged
Merged
Conversation
整合 reasonix web UI 嵌入调研(方案 A 反代+iframe 推荐)+ 三项实测结论: - session lease 按 session 文件路径互斥,多 worktree 各起一个 serve 可并行 - 端口以 --port-file 为权威;serve 无自动递增、web 自动 +1 - /events 每 15s 自带 : ping 保活;Cookie: reasonix_token 注入实测 200 无重定向 - 布局问题:侧栏 220px 固定,需反代 + 轻量注入解锁折叠(§9)
Add a second instance type: kind=reasonix runs a per-worktree 'reasonix serve' subprocess and renders its web chat UI in an iframe via a same-origin reverse proxy at /rx/<id>/. - store: ManagedInstance.Kind (tty|reasonix, omitempty, no migration) - internal/instance/reasonix: driver with isolated REASONIX_HOME, ~/.reasonix config/.env symlinked in, kernel-assigned port via --port-file, fixed session file, cross-platform liveness (kill(pid,0) + TCP probe, no /proc), SIGTERM->SIGKILL stop - manager: kind branch for Start/Stop/Restart/Delete; Reconcile re-attaches live serve processes on startup (R-02); Delete stops before wiping state dir (N-01) - internal/app/reasonix_proxy: /rx/<id>/ reverse proxy with reasonix_token cookie injection, RawQuery stripped, Accept-Encoding forced to identity, SSE streaming, HTML URL-prefix rewrite for fetch/EventSource/XHR - frontend: iframe rendering branch, create-dialog checkbox, rx badge - docs: API §5.10, ARCHITECTURE §3.2/4.2, PRD §7, plans index + FEASIBILITY §9.5 security tradeoff, DEFERRED notes Two rounds of code review applied (R-01..R-08, N-01..N-06, T-01..T-03); follow-ups tracked in issues #43..#49. Pre-existing app test failures (TestHandleInstanceUpdate/Reorder, real-user state dir) tracked in #43.
…r-side Runtime issues found when exercising the MVP: - iframe reloaded every 2s poll tick: renderWorkspace() -> ensureWebFrame() assigned frame.src unconditionally; guard it with a dataset.instance check so the embedded page only navigates when the instance changes (trailing slash added so in-page relative URLs resolve under /rx/<id>/). - <img src="/assets/logo-wordmark.svg"> 404'd: the URL-prefix shim only covered fetch/EventSource/XHR. Rewrite root-relative src/href/action/ poster attributes server-side in ModifyResponse (rewriteRootAttrs) so the browser never issues a wrong first request, and keep a MutationObserver for dynamically inserted nodes. rewriteRootAttrs (two-level tag->attr regex): - all attributes in one tag rewritten (multiple-attrs case) - case-insensitive (?i), unquoted values, idempotent (already-prefixed and protocol-relative //host URLs skipped), data-src/xlink:href and JS property assignments (el.src=) not matched - documented regex tradeoffs (value containing '>' truncates; no second pass for initial page; CSS url()/srcset/SVG <use> uncovered) Tests: TestRewriteRootAttrs grown to 13 cases incl. the previously uncovered risk path (two attrs in one tag), verified via control experiment; proxy HTML-injection test now asserts real rewritten output instead of grepping for script source.
GitHub macOS runners have broken/unresponsive DNS, and HTTPServer.server_bind() calls socket.getfqdn() for a reverse lookup that hangs indefinitely. The fake reasonix serve scripts (python3 http.server) never wrote --port-file, so every reasonix test timed out with 'serve did not become ready within 15s' on macOS only. Patch socket.getfqdn to skip the DNS lookup in the test scripts.
This was referenced Aug 11, 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.
概要
新增第二种实例类型 :勾选创建后不启动 PTY 终端,而是在 worktree 内运行
reasonix serve子进程,并将其官方 web 聊天界面经同源反向代理/rx/<id>/以 iframe 嵌入实例标签页。组件
ManagedInstance.Kind(tty/reasonix,omitempty,旧 state 无需迁移)internal/instance/reasonix:隔离REASONIX_HOME、~/.reasonixconfig/.env symlink 继承、内核分配端口(--port-file权威)、固定 session 文件、跨平台探活(kill(pid,0)+TCP,无 /proc)/rx/<id>/:reasonix_token Cookie 注入、RawQuery 剥离、Accept-Encoding identity、SSE 透传、服务端改写根相对属性 + MutationObserver 兜底动态节点安全说明
同源 iframe 权限提升权衡已论证于
docs/plans/reasonix-native-ui/FEASIBILITY.md §9.5(远程模式风险最高,独立源方案列为 #44)。评审与测试
⑤/AH)已闭环;未决项转 issue test: app 包 TestHandleInstanceUpdate/Reorder 读写真实用户数据目录,结果依赖机器状态 #43~reasonix: 实例 Restart 丢失会话(当前 = 全新会话),建议按 worktree 组织或迁移 #49TestRewriteRootAttrs13 用例(含对照实验验证);proxy/manager/driver 测试全绿TestHandleInstanceUpdate/TestHandleInstanceReorder读真实~/.configstate(test: app 包 TestHandleInstanceUpdate/Reorder 读写真实用户数据目录,结果依赖机器状态 #43,与本 PR 无关)文档
docs/API.md §5.10、docs/ARCHITECTURE.md §3.2/§4.2、docs/PRD.md §7、docs/plans/reasonix-native-ui/(FEASIBILITY/README/DEFERRED)