Skip to content

feat/stop autocorrecting me#206

Merged
matheusfillipe merged 4 commits into
mainfrom
feat/stop-autocorrecting-me
May 12, 2026
Merged

feat/stop autocorrecting me#206
matheusfillipe merged 4 commits into
mainfrom
feat/stop-autocorrecting-me

Conversation

@matheusfillipe
Copy link
Copy Markdown
Contributor

@matheusfillipe matheusfillipe commented May 12, 2026

  • Make autocorrect mobile only
  • Avoid correcting nicknames in channel

Summary by CodeRabbit

Release Notes

  • New Features

    • Mention autocorrect guard prevents text replacement when selecting mentions in chat and media comments.
    • Mobile device detection now intelligently toggles text input behaviors (autocorrect, spell check, capitalization) based on device type.
    • Improved mention detection for direct replies to current user.
    • Added browser notifications for mentions in reply scenarios.
  • Tests

    • Added comprehensive test coverage for mention autocorrect guard behavior.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f3dee2e2-1451-4166-96ed-dd4ba1a148a5

📥 Commits

Reviewing files that changed from the base of the PR and between b23cef5 and f150754.

📒 Files selected for processing (1)
  • src/store/handlers/messages.ts

📝 Walkthrough

Walkthrough

PR adds mention autocorrect prevention via a new useMentionAutocorrectGuard hook and mobile device detection utility; applies these to chat input and sidebar comments with platform-aware input behavior; and updates message handlers to treat replies to the current user as mentions with browser notifications.

Changes

Mention Protection and Mobile Input UX

Layer / File(s) Summary
Mention guard hook and platform detection utilities
src/hooks/useMentionAutocorrectGuard.ts, src/lib/platformUtils.ts
useMentionAutocorrectGuard hook intercepts insertReplacementText events and prevents replacement when selected text matches a provided nickname (case-insensitive). isMobileDevice() detects soft-keyboard scenarios for iOS, Android, and Tauri builds.
ChatArea mention guard and mobile input control
src/components/layout/ChatArea.tsx
ChatArea wires the mention guard into its textarea via onBeforeInput using the current channel's user list; derives isMobileInput and conditionally enables autoCorrect, autoCapitalize, and spellCheck only on mobile devices.
MediaCommentsSidebar mention guard and mobile input control
src/components/ui/MediaCommentsSidebar.tsx
MediaCommentsSidebar applies the same mention guard and mobile-aware input behavior pattern to its comments textarea, matching ChatArea's integration.
Message handler reply-aware mention detection
src/store/handlers/messages.ts
CHANMSG and MULTILINE_MESSAGE handlers now detect mentions when the message replies to the current user; multiline messages populate mentioned data and emit browser notifications for mentions outside the active channel.
Test coverage for mention autocorrect guard
tests/hooks/useMentionAutocorrectGuard.test.ts
Vitest suite covers four cases: nickname match (case-insensitive) prevents replacement, non-match allows replacement, non-insertReplacementText events ignored, and empty selections ignored.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Textarea
  participant MentionGuard
  participant SelectionAPI
  
  User->>Textarea: Type mention + autocorrect trigger
  Textarea->>MentionGuard: beforeinput (insertReplacementText)
  MentionGuard->>SelectionAPI: Read selectionStart/End
  SelectionAPI-->>MentionGuard: Selection range
  MentionGuard->>MentionGuard: Normalize selected text + nickname set (case-insensitive)
  alt Selected text matches nickname
    MentionGuard->>Textarea: preventDefault()
    Textarea-->>User: Autocorrect blocked
  else No match
    Textarea-->>User: Autocorrect applied
  end
Loading
sequenceDiagram
  participant MessageHandler as CHANMSG/<br/>MULTILINE_MESSAGE
  participant Store
  participant CurrentUser as Current Server<br/>User
  participant Notification
  
  MessageHandler->>Store: Fetch replyMessage if ID present
  Store-->>MessageHandler: Message or null
  MessageHandler->>CurrentUser: Get current username
  CurrentUser-->>MessageHandler: Username
  alt replyMessage.userId == currentUser.username
    MessageHandler->>MessageHandler: isReplyToMe = true
    MessageHandler->>MessageHandler: hasMention = true
  else checkForMention detected
    MessageHandler->>MessageHandler: hasMention = true
  else Own message
    MessageHandler->>MessageHandler: hasMention = false
  end
  MessageHandler->>Store: Populate newMessage.mentioned
  alt Not historical & outside active channel
    alt hasMention true
      MessageHandler->>Notification: showMentionNotification
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • ObsidianIRC/ObsidianIRC#207: Implements the same mention-autocorrect guard, mobile device detection, and message handler reply-mention logic across chat input and sidebar components.

Suggested labels

enhancement, IRC Client

Suggested reviewers

  • ValwareIRC

Poem

🐰 A mention guard hops in to save the day,
Stopping autocorrect from leading names astray.
Mobile keyboards now know their place so right,
And replies spark mentions—oh, what delight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly relates to the main objective: preventing autocorrection of nicknames and restricting autocorrect to mobile. It captures the core intent of the changeset.
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/stop-autocorrecting-me

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

@matheusfillipe matheusfillipe requested a review from ValwareIRC May 12, 2026 15:20
@github-actions
Copy link
Copy Markdown

Pages Preview
Preview URL: https://feat-stop-autocorrecting-me.obsidianirc.pages.dev

Automated deployment preview for the PR in the Cloudflare Pages.

Copy link
Copy Markdown
Contributor

@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: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src-tauri/plugins/share-sheet/.tauri/tauri-api/Sources/Tauri/Invoke.swift`:
- Around line 33-38: The new implementation of getArgs() uses force-unwraps and
forced casts (self.data.data(using: .utf8)!, JSONSerialization result cast as!
NSDictionary, and JSTypes.coerceDictionaryToJSObject(...)!) which can crash the
process; restore the previous guarded error handling by: check UTF-8 conversion
(guard let jsonData = self.data.data(using: .utf8) else { throw NSError(...) }),
use JSONSerialization and guard that the top-level value is an NSDictionary via
conditional cast (guard let dict = data as? NSDictionary else { throw
NSError(...) }), and unwrap the result of JSTypes.coerceDictionaryToJSObject
safely (guard let jsObj = JSTypes.coerceDictionaryToJSObject(dict,
formattingDatesAsStrings: true) else { throw NSError(...) }) and return jsObj;
also verify this file is not an unintended vendored/generated change and revert
if it was modified accidentally.

In `@src-tauri/plugins/share-sheet/.tauri/tauri-api/Sources/Tauri/Tauri.swift`:
- Line 22: The PluginManager.shared singleton currently holds a strong reference
via the public var viewController: UIViewController? which prevents view
controllers set in onWebviewCreated from being deallocated; revert this to a
weak reference (e.g., make viewController a weak var of type UIViewController?)
so the assigned controller can be released when dismissed, and verify this
change under .tauri/tauri-api is intentional (or remove the accidental
regeneration) to restore the previous lifecycle behavior.
- Around line 78-90: The vendored Tauri iOS bridge in Tauri.swift is using an
incorrect IMP signature (currently casting methodIMP to use OpaquePointer) which
causes the NSError to be deallocated and the code to leak via
Unmanaged.passRetained(error); fix this by upgrading the tauri dependency to the
version that uses AutoreleasingUnsafeMutablePointer<NSError?> for the
selectorWithThrows/methodIMP bridge, then regenerate the vendored sources via
build.rs so the method cast for methodIMP uses the correct signature (i.e.
`@convention`(c) (Any?, Selector, Invoke,
AutoreleasingUnsafeMutablePointer<NSError?>) -> Void) and remove the
Unmanaged.passRetained(error) leak workaround and the manual OpaquePointer
usage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2aaffde3-2ed2-4943-9c4e-82b6b10bd6e5

📥 Commits

Reviewing files that changed from the base of the PR and between b5796c4 and b23cef5.

⛔ Files ignored due to path filters (1)
  • src-tauri/gen/apple/ObsidianIRC_iOS/Info.plist is excluded by !**/gen/**
📒 Files selected for processing (7)
  • src-tauri/plugins/share-sheet/.tauri/tauri-api/Sources/Tauri/Invoke.swift
  • src-tauri/plugins/share-sheet/.tauri/tauri-api/Sources/Tauri/Tauri.swift
  • src/components/layout/ChatArea.tsx
  • src/components/ui/MediaCommentsSidebar.tsx
  • src/hooks/useMentionAutocorrectGuard.ts
  • src/lib/platformUtils.ts
  • tests/hooks/useMentionAutocorrectGuard.test.ts

Comment thread src-tauri/plugins/share-sheet/.tauri/tauri-api/Sources/Tauri/Tauri.swift Outdated
@ValwareIRC
Copy link
Copy Markdown
Contributor

This will be great

@ValwareIRC
Copy link
Copy Markdown
Contributor

Can we get rid of coderabbit

ValwareIRC
ValwareIRC previously approved these changes May 12, 2026
@matheusfillipe matheusfillipe merged commit 4d8a583 into main May 12, 2026
3 of 4 checks passed
@matheusfillipe matheusfillipe deleted the feat/stop-autocorrecting-me branch May 12, 2026 18:32
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