Skip to content

chore(upstream): PR4 - terminal ensureSession 手動移植 + bundle name sanitize#137

Merged
MocA-Love merged 2 commits into
mainfrom
upstream-merge/pr4-terminal-ensure-session
Apr 10, 2026
Merged

chore(upstream): PR4 - terminal ensureSession 手動移植 + bundle name sanitize#137
MocA-Love merged 2 commits into
mainfrom
upstream-merge/pr4-terminal-ensure-session

Conversation

@MocA-Love
Copy link
Copy Markdown
Owner

Summary

当初の計画では「PR4 = auto-updater/quit 系4コミット取り込み」だったが、Codex 事前調査の結果、fork 独自実装 (requestQuit(mode) / GitHub API ベース auto-updater / cleanupMainWindowResources() / tray 二択メニュー) と 4コミットの大半が直接衝突することが判明した。

そのため PR4 は方針を縮小し、実質的に価値があり fork 独自実装を壊さない部分のみを手動移植する。

取り込み内容

コミット1: c3cdd68fa terminal ensureSession tRPC mutation(upstream superset-sh#3252 部分)

upstream 54e8a1c88 から terminal 関連部分のみ抽出。quit lifecycle 変更は除外。

目的: terminal session 作成を WebSocket query params → tRPC mutation に移行し、WebSocket URL を安定化。workspace 切替時の xterm 描画 garbling を修正。

取り込んだファイル:

  • packages/host-service/src/trpc/router/router.ts (+terminalRouter)
  • packages/host-service/src/trpc/router/terminal/index.ts (新規)
  • packages/host-service/src/trpc/router/terminal/terminal.ts (新規 ensureSession mutation)
  • packages/host-service/src/terminal/terminal.ts (+export, WS handler のフォールバック処理)
  • apps/desktop/src/renderer/.../TerminalPane/TerminalPane.tsx (ensureSession 呼び出し追加)

意図的に除外したファイル:

  • apps/desktop/src/main/index.ts — upstream が setSkipQuitConfirmation() / quitApp() を追加しようとするが、fork は requestQuit(mode: QuitMode) / pendingQuitMode / prepareQuit('stop'|'release') を使用
  • apps/desktop/src/main/lib/auto-updater.ts — fork は IS_FORK=true で GitHub API ベース auto-updater に置換済み、prepareQuit('stop') で macOS quit ブロック回避

host-service 側の WebSocket handler は query-param フォールバックを残したため、v1 callers との後方互換あり。

コミット2: 5f83081a6 bundle display name sanitize(upstream superset-sh#3253 部分)

upstream 146c86d73 から patch-dev-protocol.ts の sanitize hunk のみ抽出。quit lifecycle 書き換え本体は除外。

目的: workspace 名に特殊文字(例: アポストロフィ)が含まれると PlistBuddy コマンドが壊れるバグ修正。allowlist (英数字・スペース・ハイフン) でサニタイズ。

スキップ確定コミット(取り込まない)

memory project_upstream_merge_workflow に記録する:

コミット スキップ理由
146c86d73 本体 (superset-sh#3253) fork の QuitMode/requestQuit/prepareQuit/cleanupMainWindowResources/closeLocalDb/shutdownExtensionHost を丸ごと捨てる方向。tray 二択メニューも消す。fork 独自 cleanup 体系が壊れる
129839219 (superset-sh#3278) fork は IS_FORK=true で GitHub Releases 外部オープン完結のため、upstream の quitAndInstall() 起点修正が現行 runtime に効かない。commit 単体でも import/call が不整合(quitApp import しつつ setSkipQuitConfirmation() 呼ぶ)
6daee831b (superset-sh#3291) macOS close-to-hide 削除は fork の tray UX(Quit Keep/Stop Services 二択)を前提にしており UX 破壊
54e8a1c88 (superset-sh#3252) quit 部分 本 PR コミット1 と同様、quit 部分のみ除外

Fork 独自要素(維持必須 - memoryにも記録済み)

  • cleanupMainWindowResources() @ main/index.ts
  • shutdownExtensionHost(), closeLocalDb()
  • IS_FORK=true GitHub API auto-updater
  • app-command (マウス戻る/進む) @ windows/main.ts
  • tray 二択メニュー @ tray/index.ts
  • QuitMode = "release" | "stop", prepareQuit('stop') (macOS quit ブロック回避)

検証

  • bun run typecheck → 既存の ModelsSettings.tsx エラーのみ
  • 2コミット分離 (terminal feature / unrelated sanitize bug fix)
  • fork 独自 auto-updater, quit lifecycle, tray menu は一切触らない

Test plan

  • CI通過確認
  • rv-pr スキルによるレビュー
  • ローカル検証:
    • v2 terminal で workspace 切替時に描画が garble しない
    • terminal.ensureSession が正常に呼ばれる
    • host-service 再起動なしでも既存の v1 terminal が query-param fallback で動作する
    • アポストロフィを含む workspace 名で dev 起動できる
    • auto-updater / quit 挙動に regression なし(fork 独自 prepareQuit フロー維持)

…perset-sh#3252)

Cherry-picked from upstream 54e8a1c (fix(desktop): prevent xterm garbling
via tRPC-first terminal sessions). Only the terminal-related portion was
taken; the quit lifecycle changes (setSkipQuitConfirmation / quitApp in
main/index.ts and auto-updater.ts) were deliberately excluded because they
collide with fork's independent requestQuit(mode: QuitMode) / GitHub API
based auto-updater implementation.

Changes:
- Add terminal.ensureSession tRPC mutation in host-service
- TerminalPane calls ensureSession before attaching WebSocket
- WebSocket URL becomes stable (no workspaceId/themeType query params),
  preventing spurious reconnects that caused xterm rendering garbling on
  workspace switches
- host-service WS handler retains query-param fallback for backwards
  compatibility with v1 callers

Fork-specific decisions:
- main/index.ts and auto-updater.ts intentionally left untouched
- setSkipQuitConfirmation() helper NOT added to fork (fork uses
  prepareQuit('stop') instead)
…m upstream superset-sh#3253)

Cherry-picked from upstream 146c86d (only the patch-dev-protocol.ts
sanitize hunk). The rest of superset-sh#3253 is a quit lifecycle rewrite that
conflicts with fork's requestQuit(mode) system and is intentionally
NOT being taken.

Workspace names with special characters (e.g. apostrophes) break
PlistBuddy commands. Use an allowlist (alphanumeric, spaces, hyphens)
instead of stripping individual characters.
@MocA-Love MocA-Love merged commit dd4336b into main Apr 10, 2026
MocA-Love added a commit that referenced this pull request Apr 10, 2026
All 28 upstream commits have been processed via cherry-pick across
7 PRs (#134-#140). This merge marks the git history as synchronized
without changing any file content.

=== Cherry-picked (25 commits) ===
PR1 (#134): efc736f, a57f9fb, dfafa5a
PR2 (#135): 97031ad, ed7fb56, abdcdc6, a8f560d, e0b99ef
PR3 (#136): d98533c, 89d7903, d1ea876
PR4 (#137): 54e8a1c (terminal only), 146c86d (sanitize only)
PR5 (#139): 14de45b, 5ac13af, 50e609f, b12c710, dbf8320
PR6 (#138): 7ab64a7, a876354, 5e1d432, ff57e31
PR7 (#140): cd25bee, fa861c4, 5b14771

=== Intentionally not adopted (4 commits) ===
- 1298392 Fix auto update — fork uses GitHub API updater (IS_FORK=true)
- 6daee83 unbreak autoupdate by removing close-to-hide — breaks fork tray UX
- 146c86d quit lifecycle rewrite (main body) — destroys fork's QuitMode/requestQuit/cleanupMainWindowResources
- 82236fa gitignore .mcp.json — fork tracks .mcp.json per AGENTS.md
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