Skip to content

fix(offline): 手動のオフラインモード中は、誰が timer を持っていても巡回しない (#1350) - #1387

Merged
hitalin merged 1 commit into
developfrom
fix/offline-heartbeat-gate-1350
Nov 12, 2026
Merged

hitalin merged 1 commit into
developfrom
fix/offline-heartbeat-gate-1350

Conversation

@hitalin

@hitalin hitalin commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

何を直すか

#1350 の 1 と 3 のうち、実害の本体。設計は issue のコメント にある。

配布版のデスクトップでは AI の本体 (notemaid) が別プロセスで HEARTBEAT の timer を持つが、オフラインをどこも見ていなかった。アプリ側の判定は in-process のときしか効かないので、手動のオフラインでも巡回が AI とサーバーに通信していた。

変更

  • 巡回の先頭で手動のオフラインを見て見送る (skip:offline)。timer を誰が持つか (アプリ / 子プロセス / 常駐) に関わらず効き、アプリを閉じた常駐も巡回しない
    • 連続失敗に数えず、日次も消費しない
    • 待機の理由「オフライン」を AI 設定に出す。知らせは出さない (利用者が自分で切り替えた状態)
    • オフラインでなくなった最初の巡回で、この待機を消す
  • 「今すぐ巡回」はオフライン中は始めず、理由を返す (エラーの種類は OFFLINE_MODE。再ログインの案内にも、再試行できる通信エラーにも当たらない)
  • 判定を 1 関数に寄せる: notecore::offline::manual を新設し、複製していた 3 か所 (HEARTBEAT の timer / 更新確認 / 起動時の main チャンネル) を置き換える
  • DEVELOPMENT.md の棚卸し表の HEARTBEAT の行を実装に合わせる

設計との差

設計は「読めないときはオフラインとして扱う」だが、この PR では今のまま (読めないときはオンライン)。その規則は、保存先を Rust だけが書く専用のファイルへ移した後の前提。今の置き場は利用者が手で編集して同期する設定ファイルで、編集途中の誤りでオフラインに倒すと、理由の分からないまま通信が止まる。保存先の移動と一緒に切り替える。

確認

  • 判定の関数と、待機の出入り (apply_offline) は、テストを先に書いてから実装
  • notemaid / notecore / アプリの Rust テスト、clippy (workspace)、rustfmt、typecheck、lint:i18n、lint:docs は通過
  • 型のコメントを変えたので bindings を再生成
  • 別プロセスの notemaid を実際に動かしての確認はしていない。巡回の本体の分岐 (先頭で判定して見送る) は Core が要るので単体テストに載せておらず、切り出した純関数だけをテストしている

#1350 に残るもの

  • 状態の保存先を state/ の専用のファイルへ移し、切替を専用の操作にする (読めないときの倒し方もここ)
  • 更新確認を解除時にやり直す
  • Misskey への送信の直前の検査 (門) と、押した操作の見え方 (投稿が失敗して本文が残る、など)
  • 棚卸し表の作り直しと、切替のダイアログの文言

Refs #1350

🤖 Generated with Claude Code

配布版のデスクトップでは notemaid が別プロセスで HEARTBEAT の timer を
持つが、オフラインをどこも見ていなかった。アプリ側の判定は in-process の
ときしか効かず、手動のオフラインでも巡回が AI とサーバーに通信していた。

- 巡回の先頭で手動のオフラインを見て見送る (skip:offline)。連続失敗にも
  日次にも数えない。待機の理由を AI 設定に出し、知らせは出さない。
  アプリを閉じた常駐でも同じに効く
- 「今すぐ巡回」はオフライン中は始めず、理由を返す
- 判定を notecore::offline::manual の 1 関数に寄せ、複製していた 3 か所
  (timer / 更新確認 / 起動時の main チャンネル) を置き換える

読めないときの倒し方は今のまま (オンライン)。置き場が手で編集する設定
ファイルの間は変えない。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 8 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 1a6c806 and 4258346.

Files ignored due to path filters: 1

  • src/i18n/locale.generated.ts is excluded by !**/*.generated.*
Files selected for processing: 15

  • DEVELOPMENT.md
  • crates/notecore/locales/en-US.json
  • crates/notecore/locales/ja-JP.json
  • crates/notecore/src/lib.rs
  • crates/notecore/src/offline.rs
  • crates/notecore/src/stream_mode.rs
  • crates/notemaid/src/commands/heartbeat.rs
  • crates/notemaid/src/heartbeat.rs
  • locales/en-US.source.json
  • locales/en-US.yml
  • locales/ja-JP.yml
  • src-tauri/src/commands/heartbeat.rs
  • src-tauri/src/commands/updater.rs
  • src-tauri/src/lib.rs
  • src/bindings.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-actions

Copy link
Copy Markdown

API surface diff

外部アプリ向け API 面 (src-tauri/openapi.json / src/bindings.ts) が変更されています。
互換性への影響 (#709) をレビューしてください。

src/bindings.ts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Full diff
diff --git a/src/bindings.ts b/src/bindings.ts
index 6743b44..6b78196 100644
--- a/src/bindings.ts
+++ b/src/bindings.ts
@@ -4003,7 +4003,7 @@ nextTickAt: number | null }
  */
 export type HeartbeatTickUsage = { inputTokens: number; estimatedInputTokens: number }
 /**
- * 待機中 (#1321)。`kind` は `no-provider` | `unreachable`。`message` は英語の正本文、
+ * 待機中 (#1321)。`kind` は `no-provider` | `unreachable` | `offline` (#1350)。`message` は英語の正本文、
  * `i18n` は `{ message: { key, params } }` (デバイスは `localizeNative` で描き直す)
  */
 export type HeartbeatWaiting = { kind: string; since: number; message: string; i18n: JsonValue }

@github-actions github-actions Bot added 📖Doc Documentation related issue/PR rust Pull requests that update rust code javascript Pull requests that update javascript code labels Nov 12, 2026
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying notedeck with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4258346
Status: ✅  Deploy successful!
Preview URL: https://10ab7d47.notedeck-d3a.pages.dev
Branch Preview URL: https://fix-offline-heartbeat-gate-1.notedeck-d3a.pages.dev

View logs

@claude

claude Bot commented Nov 12, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@hitalin
hitalin merged commit 7ecdac6 into develop Nov 12, 2026
16 checks passed
@hitalin hitalin self-assigned this Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📖Doc Documentation related issue/PR javascript Pull requests that update javascript code rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant