Skip to content

MLSグループ状態のTypedArray復元処理を追加#609

Open
tako0614 wants to merge 1 commit intomasterfrom
codex/fix-typeerror-in-createroom-function
Open

MLSグループ状態のTypedArray復元処理を追加#609
tako0614 wants to merge 1 commit intomasterfrom
codex/fix-typeerror-in-createroom-function

Conversation

@tako0614
Copy link
Copy Markdown
Owner

@tako0614 tako0614 commented Aug 22, 2025

概要

  • グループ状態から失われたTypedArrayを復元するreviveGroupStateを追加
  • Commit/Welcome生成前にグループ状態を復元してAES-GCMエラーを回避

テスト

  • deno fmt app/client/src/components/Chat.tsx app/client/src/components/e2ee/storage.ts app/client/src/components/chat/ChatSettingsOverlay.tsx
  • deno lint app/client/src/components/Chat.tsx app/client/src/components/e2ee/storage.ts app/client/src/components/chat/ChatSettingsOverlay.tsx

https://chatgpt.com/codex/tasks/task_e_68a873c3ff348328b06cd9a9e06ae9bc

Summary by CodeRabbit

  • 新機能
    • なし
  • バグ修正
    • グループチャットの暗号化セッション処理を見直し、安定性を向上。まれに発生する送受信エラーを抑制。
  • スタイル
    • チャット設定(一般)でUIを調整。ルームアイコンの表示を改善し、アイコン未設定時に「なし」を表示。
    • 画像アップロードの状態表示をわかりやすく更新(「アップロード中」/「画像を選択」)。
    • 余白・整列・インデントを微調整し、視認性を向上。

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Aug 22, 2025

Walkthrough

createCommitAndWelcomes の呼び出し前に、保存済みMLSグループ状態を reviveGroupState で再構築する処理を追加。Chat.tsx と ChatSettingsOverlay.tsx に適用。reviveGroupState を e2ee/storage.ts に実装・公開。ChatSettingsOverlay の一般タブで軽微なUIレイアウト調整。

Changes

Cohort / File(s) Change Summary
MLS state revival integration (chat)
app/client/src/components/Chat.tsx, app/client/src/components/chat/ChatSettingsOverlay.tsx
createCommitAndWelcomes 呼び出し時に生グループ状態ではなく reviveGroupState(state) を渡すように変更。必要な import を追加。ChatSettingsOverlay では一般タブのアイコン表示/アップロードUIに軽微なレイアウトと表示テキストの調整。
E2EE storage helper
app/client/src/components/e2ee/storage.ts
reviveGroupState(state: StoredGroupState) を追加・export。serializeGroupState→deserializeGroupState の往復で保存状態を再構築。

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User as User
  participant Chat as Chat/Settings UI
  participant Store as e2ee/storage.reviveGroupState
  participant MLS as createCommitAndWelcomes

  User->>Chat: メンバー変更/設定更新操作
  Chat->>Store: reviveGroupState(storedGroup)
  Store-->>Chat: revivedGroup
  Chat->>MLS: createCommitAndWelcomes(revivedGroup, ...)
  MLS-->>Chat: commit, welcomes
  Chat-->>User: 完了/反映
  note over Store,MLS: 復元を必須化し、非JSON要素を再構築
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

ぴょんと跳ねて、鍵を整え
眠る状態を呼び覚まし
revive してから commit へGO
ようこそパケット、歓迎の風
(∩^o^)⊃━☆ ひみつは無事に繋がった

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/fix-typeerror-in-createroom-function

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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.

Actionable comments posted: 0

🧹 Nitpick comments (2)
app/client/src/components/e2ee/storage.ts (1)

142-145: reviveGroupState の追加は目的に合致(TypedArrayの復元)—ただし安全性と将来拡張に向けて微調整を提案

  • 直前で serialize → deserialize の往復を行う実装は、JSON 化で壊れた TypedArray を最小変更で復元でき、createCommitAndWelcomes 直前の AES-GCM エラー回避という目的に合っています。
  • 併せて、deserialize 側の reviver が globalThis から動的にコンストラクタを引いて new する実装は柔軟ですが、将来的な安全性/保守性の観点では許容 $type のホワイトリスト化を推奨します(例えば TypedArray 系 + Date/Map など、想定する最小集合に限定)。また未知の $type は素通し/警告で握りつぶすと事故りにくいです。
  • パフォーマンス面では JSON 往復がオーバーヘッドになる可能性がありますが、呼び出し箇所が限定的(Commit/Welcome 生成前のみ)であれば実害は小さいと見ています。

以下の2点、意図を確認させてください。

  • reviveGroupState 経由だと clientConfig が defaultClientConfig に置き換わります(Line 108, 139 近辺の処理)。ランタイムで clientConfig を差し替えるユースケースはありませんか?
  • $type の許容値を TypedArray 系のみに限定してよい前提でしょうか?

ホワイトリスト化の骨子(参考・抜粋、既存関数内の修正案):

// 許可する型のみを明示
const ALLOWED_CTORS = new Map<string, new (data: unknown) => unknown>([
  ["Uint8Array", Uint8Array],
  ["Uint16Array", Uint16Array],
  ["Uint32Array", Uint32Array],
  ["Int8Array", Int8Array],
  ["Int16Array", Int16Array],
  ["Int32Array", Int32Array],
  ["Float32Array", Float32Array],
  ["Float64Array", Float64Array],
  ["BigInt64Array", BigInt64Array],
  ["BigUint64Array", BigUint64Array],
]);

// reviver の default 節:
const ctor = ALLOWED_CTORS.get(v.$type);
if (ctor) return new ctor(v.data as unknown);
// 未知の $type はそのまま返す or ログ
return value;
app/client/src/components/chat/ChatSettingsOverlay.tsx (1)

588-644: 一般タブのUI微調整(a11y/小さな可読性改善の提案)

  • Line 591/595: label と input が別要素なので関連付け(for/id)の追加を推奨。
  • Line 617-629: file input は class="hidden" と inline style={{ display: "none" }} が重複。style は不要です。アップロード中は疑似ボタン(label)に pointer-events を無効化して二重送信を防ぐとより扱いやすいです。

以下の差分で軽量に改善できます(該当範囲内のみ変更):

-                    <label class="block text-sm text-gray-400 mb-1">
+                    <label for="roomName" class="block text-sm text-gray-400 mb-1">
                       ルーム名
                     </label>
-                    <input
+                    <input id="roomName"
                       value={roomName()}
                       onInput={(e) => setRoomName(e.currentTarget.value)}
                       class="w-full bg-[#2b2b2b] border border-[#3a3a3a] rounded px-3 py-2 text-white focus:outline-none focus:border-blue-500"
                       placeholder="ルーム名"
                     />
...
-                      <label class="px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded cursor-pointer text-sm">
+                      <label
+                        class={`px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded cursor-pointer text-sm ${uploading() ? "opacity-60 pointer-events-none" : ""}`}
+                        aria-disabled={uploading()}
+                      >
                         <input
                           type="file"
                           accept="image/*"
                           class="hidden"
-                          style={{ display: "none" }}
                           onChange={(e) => {
                             const f = e.currentTarget.files?.[0];
                             if (f) handleIconChange(f);
                           }}
                         />
                         {uploading() ? "アップロード中..." : "画像を選択"}
                       </label>
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b9a375e and ce349b8.

📒 Files selected for processing (3)
  • app/client/src/components/Chat.tsx (3 hunks)
  • app/client/src/components/chat/ChatSettingsOverlay.tsx (3 hunks)
  • app/client/src/components/e2ee/storage.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: TypeScriptの型定義を活用する
エラーハンドリングを適切に実装する

Files:

  • app/client/src/components/e2ee/storage.ts
  • app/client/src/components/Chat.tsx
  • app/client/src/components/chat/ChatSettingsOverlay.tsx
🧬 Code graph analysis (3)
app/client/src/components/e2ee/storage.ts (1)
app/client/src/components/e2ee/mls_wrapper.ts (1)
  • StoredGroupState (40-40)
app/client/src/components/Chat.tsx (1)
app/client/src/components/e2ee/storage.ts (1)
  • reviveGroupState (143-145)
app/client/src/components/chat/ChatSettingsOverlay.tsx (1)
app/client/src/components/e2ee/storage.ts (1)
  • reviveGroupState (143-145)
🔇 Additional comments (4)
app/client/src/components/Chat.tsx (2)

63-64: reviveGroupState の import 追加は妥当です

createCommitAndWelcomes 前の復元フローと整合しています。


1539-1543: 全てのアプリケーションコード呼び出しで reviveGroupState を適用済み

  • 下記ファイルにある createCommitAndWelcomes 呼び出しはすべて reviveGroupState を第一引数に渡しています
    • app/client/src/components/chat/ChatSettingsOverlay.tsx (行 412)
    • app/client/src/components/Chat.tsx (行 1539, 1741)
  • テストコード(app/client/src/components/e2ee/mls_test.ts)の呼び出しは意図的に異なる引数を渡しているため、本件検証の対象外としています

将来的に「呼び忘れ」を防止するには、mls_wrapper.ts 側で内部的に revive を自動実行するラッパー設計を検討すると良いでしょう。

app/client/src/components/chat/ChatSettingsOverlay.tsx (2)

11-13: reviveGroupState の import 追加は妥当です

後段の createCommitAndWelcomes での利用と一致しています。


412-415: メンバー追加の Commit/Welcome 生成前に revive を適用している点は適切です

永続状態や props 経由の state に含まれる TypedArray の欠落を確実に補正できます。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant