Skip to content

fix: accept labeled Shared key paste in Observer - #223

Merged
grunch merged 2 commits into
mainfrom
fix/observer-shared-key-label
Oct 13, 2026
Merged

grunch merged 2 commits into
mainfrom
fix/observer-shared-key-label

Conversation

@grunch

@grunch grunch commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Summary

Mostro mobile v2 shares the conversation key (K_conv) as text with a label:

Shared key: 23e9ba260f0e8ba1ea94e6aac24e58b19f0041b9fda33c8f24a7028f0b9df558

When a solver pasted that into the Observer tab and pressed Enter, Mostrix showed
Shared key must be a valid 64-char hex secret (32 bytes). Enter only trimmed the
field and then validated the whole string, label included, as hex.

Now, when the solver presses Enter, the field is reduced to the 64-char hex key
before it is validated and loaded:

  • chat_utils::extract_shared_key_hex() returns the first run of exactly 64 ASCII
    hex digits. It rejects a longer hex run rather than truncating it, so it never loads
    a wrong key without telling the solver.
  • AppState::normalize_observer_shared_key_input() replaces the field with that hex.
    It zeroizes the original text first, as the other Observer secrets are handled. The
    field then shows exactly the key that was loaded, which keeps the
    observer_loaded_shared_key pin and the divergence check consistent.
  • If no 64-char hex run is found, the same error as before is shown and the field is
    left unchanged.

Test plan

  • Unit tests for extract_shared_key_hex: text with the mobile label, a bare key, a key padded with whitespace, and hex of the wrong length (empty, short, 63 and 65 chars)
  • Unit tests for normalize_observer_shared_key_input: the label is stripped, and the field is unchanged when no key is present
  • cargo fmt --all -- --check, cargo clippy --all-targets --all-features -- -D warnings, cargo test --all-features
  • Manual: pasted Shared key: <hex> from Mostro mobile v2 into the Observer tab and pressed Enter; the chat loaded

Summary by CodeRabbit

  • Bug Fixes
    • Observer chat key submission now accepts pasted labels containing a valid 64-character hexadecimal key and uses the extracted key.
    • Blank or invalid keys now show an error instead of starting a fetch.
    • Pasted text without a valid key is left unchanged.

Mostro mobile v2 shares K_conv as "Shared key: <hex>", which the
Observer rejected because Enter validated the whole field as hex.
On Enter, reduce the field to the single 64-char hex run (zeroizing
the original text) before validating and loading the chat. Longer
hex runs are rejected rather than truncated.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T14:44:57.437237Z 0325da9 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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 22 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
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0199c3a8-1c72-421c-9004-fb07b8058012
📥 Commits

Reviewing files that changed from the base of the PR and between 0325da9 and 7197ce9.

📒 Files selected for processing (2)
  • src/ui/app_state.rs
  • src/util/chat_utils.rs

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: edae6dda-6817-4f35-a448-b89c48b58f8b
📥 Commits

Reviewing files that changed from the base of the PR and between b5dee5b and 0325da9.

📒 Files selected for processing (3)
  • src/ui/app_state.rs
  • src/ui/key_handler/enter_handlers.rs
  • src/util/chat_utils.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

Observer chat submission now extracts a 64-character hexadecimal key from pasted text, normalizes the input field, and validates the normalized value before fetching.

Changes

Observer Shared Key Input

Layer / File(s) Summary
Key extraction and submission
src/util/chat_utils.rs, src/ui/app_state.rs, src/ui/key_handler/enter_handlers.rs
The extractor returns a run of exactly 64 ASCII hexadecimal characters. AppState replaces differing field contents with the extracted key. Observer chat submission rejects blank or unmatched input and uses the normalized key for validation and fetching. Tests cover extraction, normalization, and input without a matching key.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant EnterHandler
  participant AppState
  participant ChatUtils
  participant ObserverFetch
  User->>EnterHandler: Submit pasted key
  EnterHandler->>AppState: Normalize key input
  AppState->>ChatUtils: Extract 64-character hex run
  ChatUtils-->>AppState: Return extracted key or no match
  AppState-->>EnterHandler: Return normalization result
  EnterHandler->>ObserverFetch: Fetch with valid normalized key
Loading

Suggested reviewers: arkanoider

Merge Risk: ⚪ Minimal · up to 0325d

Observer accepts labeled key pastes while using the same normalized key throughout loading; invalid input does not trigger a fetch. No actionable merge-blocking risk remains.

Pre-merge checks · Passed 5
Passed Passed checks (5 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: accepting labeled Shared key pastes in Observer.
Docstring Coverage Passed Docstring coverage is 93.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 3 files.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • 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

A rabbit pastes a key with care
Sixty-four bright digits there
The label fades, the hex stays clear
A valid key is ready here
The rabbit hops and nibbles greens

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

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

Copy link
Copy Markdown

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: 0325da9f1a

ℹ️ 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 src/util/chat_utils.rs Outdated
Pasting a labeled key after an old one without clearing the field
left two 64-char hex runs; normalization picked the first and
silently reloaded the previous conversation. Return None when the
field holds two different keys so Enter reports invalid input.
@grunch
grunch merged commit 66b0751 into main Oct 13, 2026
15 checks passed
@grunch
grunch deleted the fix/observer-shared-key-label branch October 13, 2026 16:26
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