Skip to content

refactor(desktop): downgrade terminal.renderer routine logs to breadcrumb-only#395

Merged
MocA-Love merged 2 commits intomainfrom
feat/terminal-breadcrumb-only
Apr 24, 2026
Merged

refactor(desktop): downgrade terminal.renderer routine logs to breadcrumb-only#395
MocA-Love merged 2 commits intomainfrom
feat/terminal-breadcrumb-only

Conversation

@MocA-Love
Copy link
Copy Markdown
Owner

@MocA-Love MocA-Love commented Apr 23, 2026

Summary

  • 正常系 terminal.renderer イベント(mount, webgl-load, cache-attach, runtime-attach, flush-pending-events, 集計メトリクス)を captureMessage から Breadcrumb-only に格下げ
  • 異常系イベント(webgl-context-lost, terminal-write-mutate-failed, ws-reconnect-scheduled)はそのまま captureMessage を維持
  • DebugChannelcaptureMessageByDefault オプションを追加し、集計 flush のデフォルト挙動をチャンネル単位で制御可能に

期待効果: アクティブなターミナルセッション中の Sentry Issue 生成量が ~90% 減少。Breadcrumb は全イベントを記録し続けるため、エラー発生時の調査力は変わらない。

変更分類

イベント 変更前 変更後
cache-attach-to-container captureMessage ✅ breadcrumb
webgl-addon-loaded captureMessage ✅ breadcrumb
webgl-context-lost captureMessage ❌ 残す(異常系)
mount captureMessage ✅ breadcrumb
terminal-write-mutate-failed captureMessage ❌ 残す(error)
flush-pending-events captureMessage ✅ breadcrumb
ws-reconnect-scheduled captureMessage ❌ 残す(異常系)
runtime-attach-to-container captureMessage ✅ breadcrumb
runtime-attach captureMessage ✅ breadcrumb
aggregate flush (5種) captureMessage ✅ breadcrumb

Test plan

  • bun run lint — 通過
  • bunx turbo typecheck --filter=@superset/desktop — 通過
  • ローカル dev でターミナルを開き、Sentry Issues に正常系イベントが上がらないことを確認
  • DevTools で Breadcrumb が記録されていることを確認

Full Changelog: main...feat/terminal-breadcrumb-only

💘 Generated with Crush

Assisted-by: GLM-5 via Crush crush@charm.land

Summary by CodeRabbit

リリースノート

  • メンテナンス
    • デバッグチャネルの設定オプションを拡張し、メッセージキャプチャのデフォルト動作を制御可能にしました
    • ターミナルレンダラー関連の複数のデバッグログ呼び出しを簡略化し、コード保守性を向上させました
    • 内部ログ処理の効率化により、デバッグ機能の柔軟性が向上しました

…rumb-only

Normal terminal lifecycle events (mount, webgl-load, cache-attach, runtime-attach,
flush-pending-events, aggregate metrics) now only add breadcrumbs instead of
creating Sentry Issues. This cuts Sentry quota usage by ~90% for active terminal
sessions while preserving full debug context — breadcrumbs are still attached to
any error that occurs.

Error/warning events (webgl-context-lost, terminal-write-mutate-failed,
ws-reconnect-scheduled) remain as captureMessage.

A new `captureMessageByDefault` option on DebugChannel controls aggregate flush
behavior per-channel, defaulting to true for backward compatibility.

💘 Generated with Crush

Assisted-by: GLM-5 via Crush <crush@charm.land>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

📝 Walkthrough

Walkthrough

デバッグチャネル設定に captureMessageByDefault オプションを追加し、ターミナルレンダラーのデバッグログからキャプチャ関連のメタデータ(captureMessagefingerprint)を削除することで、デバッグログの設定と呼び出しを簡略化しました。

Changes

Cohort / File(s) Summary
Debug Channel Core Configuration
apps/desktop/src/shared/debug-channel.ts, apps/desktop/src/renderer/lib/terminal/debug.ts
DebugChannelOptionscaptureMessageByDefault オプションを追加し、DebugChannel のフラッシュ時のデフォルト動作を制御可能にしました。debug.ts では新しいオプション(captureMessageByDefault: false)を指定してターミナルレンダラーチャネルを設定しています。
Terminal Runtime Logging
apps/desktop/src/renderer/lib/terminal/terminal-runtime-registry.ts, apps/desktop/src/renderer/lib/terminal/terminal-runtime.ts
ランタイム接続・アタッチ時のデバッグログから captureMessagefingerprint メタデータを削除し、コア情報(terminalId、接続状態など)のみをログ出力するよう簡略化しました。
Terminal Component Logging
apps/desktop/src/renderer/screens/.../helpers.ts, apps/desktop/src/renderer/screens/.../v1-terminal-cache.ts
WebGL アドオンロードおよびキャッシュアタッチ時のデバッグログから追加のメタデータオプション引数を削除し、イベント名と基本的なペイロード(suggestedRendererTypepaneId など)のみを出力するよう簡略化しました。
Terminal Lifecycle Logging
apps/desktop/src/renderer/screens/.../hooks/useTerminalLifecycle.ts, apps/desktop/src/renderer/screens/.../hooks/useTerminalRestore.ts
マウント時および保留中イベントフラッシュのデバッグログから captureMessagefingerprint オプションを削除し、イベント名と基本コンテキスト情報のみを出力するよう簡略化しました。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰✨ デバッグの粗雑さを削ぎ落とし、
シンプルなログが輝く時代へ、
メタデータは選別され、
本質だけが記録される世界、
ターミナルの声がいっそう澄み渡る! 🌙

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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
Title check ✅ Passed タイトルはPRの主要な変更内容を正確に反映しており、terminal.rendererのログを「breadcrumb-only」に格下げするというリファクタリングの目的を明確に伝えている。
Description check ✅ Passed 説明はテンプレートの要件をおおむね満たしており、変更内容、テスト計画、期待効果が詳細に記載されている。ただし、Related Issuesセクションが記載されていない。
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 feat/terminal-breadcrumb-only

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

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
apps/desktop/src/shared/debug-channel.ts (1)

36-36: LGTM — 後方互換を保った既定値スイッチ

captureMessageByDefault?: boolean(既定 true)の追加と、observe() での options?.captureMessage ?? this.captureMessageByDefault による per-call オーバーライド優先は適切な設計です。既存のチャンネル/呼び出し側に影響を与えずに、terminal.renderer のような新規チャンネルだけを breadcrumb 既定に切り替えられます。

1点だけ補足として、flushAll()(Line 267)はチャンネル既定値のみを使用し、observe() 呼び出しごとに指定された options.captureMessage オーバーライドは握りつぶします(オーバーライドはタイマーのクロージャ内にしか保持されていないため)。この挙動は本 PR 以前から同等(以前はハードコード true)なので回帰ではありませんが、将来 per-aggregate に override を尊重させたい場合は AggregateStatecaptureMessage フィールドを持たせる小リファクタが候補です。現状の PR スコープでは対応不要と考えます。

Also applies to: 129-129, 138-138, 258-258, 267-267

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/desktop/src/shared/debug-channel.ts` at line 36, The current
implementation adds captureMessageByDefault and lets observe() prefer
options?.captureMessage ?? this.captureMessageByDefault, but flushAll() (and
other aggregate-level logic) only uses the channel default and thus ignores
per-observe overrides because those overrides live only in the timer closure; to
fix this, add a captureMessage boolean field to the AggregateState (or
equivalent aggregate object used by observe()/flushAll()), set that field from
the per-call resolved value inside observe() when creating/updating the
aggregate, and update flushAll() and any aggregate-level code to read
aggregate.captureMessage instead of the channel default so per-observe overrides
are honored across timer/flush boundaries.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/desktop/src/shared/debug-channel.ts`:
- Line 36: The current implementation adds captureMessageByDefault and lets
observe() prefer options?.captureMessage ?? this.captureMessageByDefault, but
flushAll() (and other aggregate-level logic) only uses the channel default and
thus ignores per-observe overrides because those overrides live only in the
timer closure; to fix this, add a captureMessage boolean field to the
AggregateState (or equivalent aggregate object used by observe()/flushAll()),
set that field from the per-call resolved value inside observe() when
creating/updating the aggregate, and update flushAll() and any aggregate-level
code to read aggregate.captureMessage instead of the channel default so
per-observe overrides are honored across timer/flush boundaries.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 22c1d379-a896-4430-a442-303c5ef60dc5

📥 Commits

Reviewing files that changed from the base of the PR and between 374c87c and f179479.

📒 Files selected for processing (8)
  • apps/desktop/src/renderer/lib/terminal/debug.ts
  • apps/desktop/src/renderer/lib/terminal/terminal-runtime-registry.ts
  • apps/desktop/src/renderer/lib/terminal/terminal-runtime.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/helpers.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/hooks/useTerminalLifecycle.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/hooks/useTerminalRestore.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/v1-terminal-cache.ts
  • apps/desktop/src/shared/debug-channel.ts

@MocA-Love MocA-Love merged commit 1cbec9f into main Apr 24, 2026
6 checks passed
@MocA-Love MocA-Love deleted the feat/terminal-breadcrumb-only branch April 24, 2026 19:39
@github-actions
Copy link
Copy Markdown

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch
  • ⚠️ Electric Fly.io app

Thank you for your contribution! 🎉

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