Skip to content

chore(upstream): PR2 MCP OAuth audience + tray menu refactor (#3459 #3458)#177

Merged
MocA-Love merged 3 commits intomainfrom
upstream-merge/pr2-mcp-oauth-tray
Apr 15, 2026
Merged

chore(upstream): PR2 MCP OAuth audience + tray menu refactor (#3459 #3458)#177
MocA-Love merged 3 commits intomainfrom
upstream-merge/pr2-mcp-oauth-tray

Conversation

@MocA-Love
Copy link
Copy Markdown
Owner

概要

upstream から MCP OAuth 検証の audience 追加と、tray メニューのイベント駆動リファクタを取り込みます。12コミット中、小修正バンドル (PR #176) の次に低リスクな2件です。

取り込む upstream コミット

# Commit 内容
1 #3459 93140d936 fix(mcp): MCP resource URL を有効な OAuth audience として受理
2 #3458 be9e00049 fix(desktop): tray メニューをイベント駆動化、組織名を実際に fetch

superset-sh#3459 について (衝突なし)

packages/auth/src/server.tsvalidAudiences${NEXT_PUBLIC_API_URL}/api/agent/mcp を追加しただけの 4行変更。fork 固有の MCP 統合 (packages/chat/src/server/trpc/utils/runtime/superset-mcp.ts) とも整合しており、JWT verifier (apps/api/src/app/api/agent/[transport]/auth-flow.ts:220) も同じ audience を受理。

削除された2テストファイル (auth-flow.test.ts, oauth-metadata.test.ts) は upstream のコミットでも削除されており、fork 側のカスタマイズはありません。

superset-sh#3458 について (競合あり、手動解決)

apps/desktop/src/main/lib/tray/index.ts で content conflict。fork 側は pre-superset-sh#3458 時点で以下の差分を持っていました:

  1. getHostServiceCoordinator as getHostServiceManager alias import (fork が coordinator rename を最小差分で吸収する方針)
  2. formatStatusLabel(status) ヘルパで "Running"/"Starting..."/"Stopped" にマッピング
  3. Restart ボタンなし (FORK NOTE で "coordinator.restart() requires SpawnConfig not available in tray" と記載)
  4. POLL_INTERVAL_MS = 5000 + setInterval フォールバック
  5. Quit メニューが2モード: "Quit (Keep Services Running)" → requestQuit(\"release\"), "Quit & Stop Services" → requestQuit(\"stop\")

upstream superset-sh#3458 はこの実装を大幅に書き換え、fetchHostInfo() で `/trpc/host.info` から実際の組織名を取得し、loadToken() + env.NEXT_PUBLIC_API_URL を使って tray から Restart を復活させ、ポーリングを廃止して mouse-enter / status-changed イベントで更新する構造に変えています。

解決方針

upstream の実装をほぼ全面採用 し、fork 固有の dual quit mode メニューだけを戻しました。

  • 1, 3, 4 番の fork 差分は破棄 (FORK NOTE の前提 "loadToken + env は tray から使えない" は fix(desktop): event-driven tray menu + real org name superset-sh/superset#3458 によって反証された)
  • 2 番の formatStatusLabel も破棄 (upstream は \\\ ${status}\`` テンプレートで直接表示)
  • 5 番の dual quit mode は温存: upstream は quitApp() を直接呼んでいますが、fork では host-service lifecycle に合わせて requestQuit(\"release\" | \"stop\") を呼ぶ必要があるため、そこだけ差し戻しました。requestQuitapps/desktop/src/main/index.ts:348QuitMode 引数を取り、before-quit イベントで stopAll() / releaseAll() に分岐します。

これにより fork の特別ビヘイビアは維持したまま、upstream のイベント駆動アーキテクチャと組織名表示を取り込めます。

Codex 事前レビュー結果

Yes。マージ可です。コード上の blocker は見つかりませんでした。

テスト

  • bun install
  • bun run lint
  • bun run typecheck: `/tmp` worktree 特有の @types/node 解決問題があり、CI のtypecheck に委ねます (origin/main でも同じエラーが再現するため cherry-pick とは無関係の環境問題)
  • 実機スモーク: tray メニューで組織名が表示されること、Restart が動作すること、Quit dual-mode がそれぞれ host-service を release/stop すること

次のステップ

このPRマージ後、PR3 (v2 workspace delete unification, +1457/-107) に進みます。

…h#3459)

MCP clients on spec 2025-06-18 send resource=<mcp-url> in authorize/token
requests. better-auth 1.5.6 validates that against validAudiences and our
allowlist only contained the bare API origin, so tokens were rejected with
"requested resource invalid". Add the MCP endpoint to validAudiences and to
the JWT verifier's audience list.
…et-sh#3458)

Replace the 5s tray polling interval with event-driven refresh:
`mouse-enter` + host-service status-changed trigger an async rebuild.
Drop the hostInfoCache Map — updateTrayMenu is now async and fetches
host.info inline with a 2s AbortController timeout, so there is no
stale state to manage. Unwrap the superjson envelope (`result.data.json`)
that the original polling code missed, which was causing every org to
render as a UUID slice (previously) or "Loading…" (after the first
pass of this fix).

Closes superset-sh#3454
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2026

Warning

Rate limit exceeded

@MocA-Love has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 19 minutes and 17 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 19 minutes and 17 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d10d161b-b515-4cd1-92c7-0d21e6439974

📥 Commits

Reviewing files that changed from the base of the PR and between 5673b65 and 9629c13.

📒 Files selected for processing (5)
  • apps/api/src/app/api/agent/[transport]/auth-flow.test.ts
  • apps/api/src/app/api/agent/[transport]/auth-flow.ts
  • apps/api/src/lib/oauth-metadata.test.ts
  • apps/desktop/src/main/lib/tray/index.ts
  • packages/auth/src/server.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch upstream-merge/pr2-mcp-oauth-tray

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.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e19f9ccca6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/main/lib/tray/index.ts
Address Codex review on #177: updateTrayMenu is triggered by both
status-changed and mouse-enter and awaits fetchHostInfo in between, so
an older invocation can finish after a newer one and overwrite the
tray state with a stale orgIds snapshot. In practice that could
reintroduce a stopped service's submenu entries and flip the Quit menu
between single- and dual-mode variants.

Introduce a monotonic trayUpdateToken bumped on entry; drop the result
if trayUpdateToken has advanced by the time fetchHostInfo resolves.
@MocA-Love
Copy link
Copy Markdown
Owner Author

9629c13 で対応しました。trayUpdateToken を単調増加カウンターとして導入し、fetchHostInfo await 後に token が進んでいたら結果を破棄するようにしました。status-changed と mouse-enter が重なっても古いスナップショットで新しい状態を上書きすることはなくなります。

@MocA-Love MocA-Love merged commit b412515 into main Apr 15, 2026
14 checks passed
MocA-Love added a commit that referenced this pull request Apr 15, 2026
-s ours merge to record that upstream commits a3e34bf through
de70163 (13 commits) are semantically already present on origin/main
via the PR1-6 cherry-pick series (PRs #176, #177, #178, #179, #180,
#182), plus fork-adaptation fixes layered on top.

This merge target is de70163 specifically (not upstream/main) so
newer upstream commits (9fff075 and later) remain visible in future
behind counts.

Upstream commits covered by this audit merge:
- a3e34bf  fix(desktop): restore cmd+click requirement for v1 terminal file links (superset-sh#3457)  [PR1/#176]
- 57557f8  fix(desktop): gate v2 workspace children on collection readiness (superset-sh#3464)       [PR1/#176]
- 4ee2e61  fix(desktop): use native clipboard for copy path in v2 sidebar (superset-sh#3462)         [PR1/#176]
- 87d6e93  feat(desktop): close settings with Escape key (superset-sh#3466)                          [PR1/#176]
- 9c7f5f4  chore(desktop): auto-restart host-service on bundle change in dev (superset-sh#3461)      [PR1/#176]
- 93140d9  fix(mcp): accept MCP resource URL as valid OAuth audience (superset-sh#3459)              [PR2/#177]
- be9e000  fix(desktop): drive tray menu off events, fetch real org name (superset-sh#3458)          [PR2/#177]
- c5f791e  feat(v2): unify workspace delete through host-service (superset-sh#3443)                  [PR3/#178]
- 2c24d93  feat(desktop): paginated branch picker with checkout + open actions (superset-sh#3397)    [PR4/#179]
- 2bf1049  feat(desktop/hotkeys): v1 directional pane focus + best-effort v1 override migrator (superset-sh#3460)  [PR5/#180]
- 1294a7d  feat(desktop/hotkeys): restore Cmd+Alt+Arrow for tab/workspace nav (superset-sh#3472)    [PR5/#180]
- de70163  feat(desktop): v2 review tab first pass — PR info, checks, comments (superset-sh#3463)    [PR6/#182]

Intentionally skipped (version bump, fork has independent versioning):
- 1e23353  chore(desktop): bump version to 1.5.5 (superset-sh#3473)

Fork-adaptation fixes layered on top of the cherry-picks:
- PR1: host-service-coordinator alias import fix, settings Escape
       selector narrowing (role-based + popper wrapper), Escape
       close uses replace navigation
- PR2: dual quit mode preservation (requestQuit "release"/"stop"),
       trayUpdateToken guard for stale async fetchHostInfo results
- PR4: ChangesHeader.normalizeBranchName regex rewrite (lint false
       positive), worktree add uses fullRef for remote-tracking
       refs, syncTimedOut reset on pendingId change, GIT_REFS.md
       barrel example fix
- PR5: migrate.ts re-sanitize of existing localStorage overrides
       (v2 marker bump intent), FOCUS_PANE_* enabled:isActive for
       KeepAliveWorkspaces, CATEGORY_ORDER merges Navigation (upstream)
       and Browser (fork)
- PR6: normalizeThreadsToComments flattens all thread.comments (not
       just first), CommentPane overrides <a> (openUrl) and <img>
       (SafeImage), zero-badge suppression, pr-null comments gate

Fork features verified intact (Explore agent audit of combined
36d4de4..35d95f3 range):
- BROWSER_RELOAD / BROWSER_HARD_RELOAD hotkeys
- dual quit mode menu in tray
- v1 terminal cold-restore + retry reconnect (out of range but
  unaffected)
- KeepAliveWorkspaces (FOCUS_PANE_* gated on isActive)
- useCommandPalette + addMemoTab in v2 workspace
- host-service-coordinator rename alias pattern
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.

2 participants