Skip to content

Report the outcome of reminders and shares to notes instead of guessing it - #6717

Open
AndyScherzinger wants to merge 3 commits into
masterfrom
feat/noid/optimisticReminders
Open

AndyScherzinger wants to merge 3 commits into
masterfrom
feat/noid/optimisticReminders

Conversation

@AndyScherzinger

@AndyScherzinger AndyScherzinger commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

#6715 and #6694 have both merged, so this branch now targets master and can be reviewed on its own.

Two things in the chat reported the wrong outcome, and both sat behind the last RxJava subscriptions in ChatViewModel that still used the disposableSet the chat throws away on pause.

refactor(chat): move reminders and sharing to notes off RxJava — setReminder, getReminder, deleteReminder, shareToNotes and shareLocationToNotes move down through ChatNetworkDataSource and RetrofitChatNetwork onto four new NcApiCoroutines endpoints. This is not the pure refactor it looks like: disposableSet is disposed in onPause, not in onCleared, so backgrounding the chat while one of these requests was in flight cancelled it silently. On viewModelScope they finish.

getCapabilities, joinRoom and createRoom stay on RxJava on purpose. They sit in that same disposableSet, so moving them is the same behaviour change — and for a join or a capability fetch, what should happen when the chat is backgrounded mid-request is a decision, not a refactor. Neither blocks anything.

fix(chat): tell the user when a reminder or a share to notes failed — a reminder the server refused was written to the log and nowhere else. And showSnackBar fires "Message sent" the moment a share to notes is started, before the answer arrives, so a share that failed was reported to the user as a success. Both now report the failure, through the SharedFlow and snackbar shape #6694 established for reaction failures.

A share that failed for a transient reason is retried, but never blindly. Talk stores a message's referenceId and never looks at it again — verified against a Nextcloud 36 dev instance with Talk main: posting twice with the same reference id returns 201 twice and leaves two messages in the room. So before a second attempt the client asks the note to self whether the message arrived anyway, and only sends it again when it did not. A lookup that cannot be answered counts as "it may be there", because a duplicate note is worse than a missing retry. The location share now carries a reference id too, which the share endpoint has always accepted.

Deliberately without an optimistic reminder state, although the implementation plan asked for one: getReminderExistState has exactly one consumer, the reminder dialog header, and DateTimeCompose refetches the reminder in its constructor every time that dialog opens, while Set and Delete dismiss it immediately. An optimistic value would never be rendered.

🖼️ Screenshots

No UI was added or changed. One new string, nc_message_not_added_to_notes, shown in the existing chat snackbar.

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed — four tests cover holdsShare, the rule that decides whether a failed share is sent again. ChatViewModel takes 14 constructor dependencies plus sharedApplication, so there is no view-model-level test for the snackbar itself; the helper contract these paths rely on is covered in Put every optimistic action on one helper and fix the ones that failed silently #6715
  • 🔖 Capability is checked or not needed
  • 🔙 Backport requests are created or not needed — not backported, this goes into 25.1.0
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Summary by CodeRabbit

  • Bug Fixes
    • Improved the reliability of sharing messages and locations to Notes, helping prevent duplicate shares when a request fails temporarily.
    • Chat now displays an error message when a reminder or Notes-sharing action fails.

@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticReminders branch 2 times, most recently from 1cff49c to 93bea38 Compare September 18, 2026 07:38
@AndyScherzinger AndyScherzinger added this to the 25.1.0 milestone Sep 18, 2026
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticConversationActions branch from 5099081 to f8ce16e Compare September 24, 2026 14:24
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticReminders branch from 93bea38 to 0e97e99 Compare September 24, 2026 14:27
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticConversationActions branch from f8ce16e to 36e1a8e Compare September 24, 2026 15:01
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticReminders branch from 0e97e99 to 0f19149 Compare September 24, 2026 15:01
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticConversationActions branch from 36e1a8e to ba3d4b7 Compare September 24, 2026 16:32
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticReminders branch from 0f19149 to bf571a9 Compare September 24, 2026 16:41
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticConversationActions branch from ba3d4b7 to ca9e10d Compare October 1, 2026 18:59
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticReminders branch from bf571a9 to a0740e5 Compare October 1, 2026 19:02
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticConversationActions branch 2 times, most recently from 75b1f11 to fdb65eb Compare October 2, 2026 16:55
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticReminders branch from a0740e5 to 08df497 Compare October 2, 2026 16:57
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticConversationActions branch from fdb65eb to 4db6b67 Compare October 5, 2026 22:29
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticReminders branch from 08df497 to 00d3a61 Compare October 5, 2026 22:32
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticConversationActions branch from 4db6b67 to 77b4de6 Compare October 5, 2026 23:20
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticReminders branch from 00d3a61 to 8200d2c Compare October 5, 2026 23:20
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticConversationActions branch from 77b4de6 to 24c3354 Compare October 5, 2026 23:45
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticReminders branch from 8200d2c to 57e7e04 Compare October 5, 2026 23:48
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticConversationActions branch from 24c3354 to 007ce89 Compare October 6, 2026 05:48
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticReminders branch from 57e7e04 to 2fb50b7 Compare October 6, 2026 05:50
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticConversationActions branch from 007ce89 to 18a84d3 Compare October 6, 2026 08:56
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticReminders branch from 2fb50b7 to 85883e2 Compare October 6, 2026 08:59
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticConversationActions branch from 18a84d3 to 43377cb Compare October 10, 2026 16:03
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticReminders branch from 85883e2 to c7fd3fb Compare October 10, 2026 16:05
@AndyScherzinger

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

📝 Walkthrough

The API and network data source add coroutine operations for reminders and Notes sharing. ChatViewModel uses these operations, checks recent messages after transient sharing failures, and retries once when the lookup confirms the share is absent. It reports action failures through a flow that ChatActivity displays in a snackbar. Tests cover the reference lookup helper.

Changes: Chat reminders and Notes sharing

Layer / File(s) Summary
Add coroutine network operations
app/src/main/java/com/nextcloud/talk/api/NcApiCoroutines.kt, app/src/main/java/com/nextcloud/talk/chat/data/network/ChatNetworkDataSource.kt, app/src/main/java/com/nextcloud/talk/chat/data/network/RetrofitChatNetwork.kt
The coroutine API adds reminder and location endpoints. The network data source and Retrofit implementation use suspend functions and direct response values. Notes-sharing requests accept and forward a reference ID.
Handle reminder and share outcomes
app/src/main/java/com/nextcloud/talk/chat/viewmodels/ChatViewModel.kt, app/src/test/java/com/nextcloud/talk/chat/viewmodels/ChatViewModelTest.kt
ChatViewModel updates reminder state with coroutine requests. After a transient Notes-sharing failure, it checks recent messages and retries once with the same reference ID only when the lookup confirms the share is absent. Tests cover reference lookup results.
Show action failures
app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt, app/src/main/res/values/strings.xml
ChatActivity displays emitted action-failure messages in a long-duration snackbar. A Notes-sharing failure string is added.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant ChatViewModel
  participant ChatNetworkDataSource
  participant ChatActivity
  ChatViewModel->>ChatNetworkDataSource: Send Notes request with referenceId
  ChatNetworkDataSource-->>ChatViewModel: Return transient failure
  ChatViewModel->>ChatNetworkDataSource: Look up recent messages
  ChatNetworkDataSource-->>ChatViewModel: Return lookup result
  ChatViewModel->>ChatNetworkDataSource: Retry once if share is absent
  ChatViewModel-->>ChatActivity: Emit action-failure message
  ChatActivity->>ChatActivity: Display snackbar
Loading

Suggested reviewers: mahibi

Merge Risk: 🟡 Moderate · up to 465d0

Some Notes shares may neither retry nor report an uncertain outcome, and concurrent failures may not reach the snackbar. These feedback gaps should be resolved before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 12.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 50 functions across 6 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
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.
Title check Passed The title clearly and concisely describes the main change: reporting reminder and share-to-notes outcomes instead of assuming success.
Description check Passed The description explains the motivation, implementation, retry behavior, testing, screenshots, checklist items, and AI usage. The optional TODO section is omitted, but the description is otherwise com…
Full details: Docstring Coverage

Explanation

Docstring coverage is 12.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 50 functions across 6 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 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

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

@coderabbitai coderabbitai 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.

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fbe4d5e8-5473-4715-bd02-27cbbd313487
📥 Commits

Reviewing files that changed from the base of the PR and between 43377cb and c7fd3fb.

📒 Files selected for processing (7)
  • app/src/main/java/com/nextcloud/talk/api/NcApiCoroutines.kt
  • app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt
  • app/src/main/java/com/nextcloud/talk/chat/data/network/ChatNetworkDataSource.kt
  • app/src/main/java/com/nextcloud/talk/chat/data/network/RetrofitChatNetwork.kt
  • app/src/main/java/com/nextcloud/talk/chat/viewmodels/ChatViewModel.kt
  • app/src/main/res/values/strings.xml
  • app/src/test/java/com/nextcloud/talk/chat/viewmodels/ChatViewModelTest.kt

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

Comment thread app/src/main/java/com/nextcloud/talk/chat/viewmodels/ChatViewModel.kt Outdated
Comment thread app/src/main/java/com/nextcloud/talk/chat/viewmodels/ChatViewModel.kt Outdated
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticConversationActions branch from 43377cb to a238355 Compare October 11, 2026 09:14
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticReminders branch from c7fd3fb to dcc3a79 Compare October 11, 2026 09:14
@mahibi
mahibi force-pushed the feat/noid/optimisticConversationActions branch from a238355 to 09db8f2 Compare October 12, 2026 13:42
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticConversationActions branch 2 times, most recently from c43e42d to d440ed1 Compare October 14, 2026 15:46
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticReminders branch from dcc3a79 to 415f322 Compare October 14, 2026 15:46
Base automatically changed from feat/noid/optimisticConversationActions to master October 15, 2026 09:20
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticReminders branch from 415f322 to 465d034 Compare October 15, 2026 11:00
@AndyScherzinger
AndyScherzinger marked this pull request as ready for review October 15, 2026 11:12
@AndyScherzinger

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: nextcloud/talk-android/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 1210353a-2465-43e6-b090-e4286203f6ca
📥 Commits

Reviewing files that changed from the base of the PR and between c7fd3fb and 465d034.

📒 Files selected for processing: 2
  • app/src/main/java/com/nextcloud/talk/chat/viewmodels/ChatViewModel.kt
  • app/src/main/res/values/strings.xml

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

Comment thread app/src/main/java/com/nextcloud/talk/chat/viewmodels/ChatViewModel.kt Outdated
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticReminders branch from 465d034 to 3d8dd2a Compare October 15, 2026 11:48
@AndyScherzinger AndyScherzinger added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Oct 15, 2026
@AndyScherzinger
AndyScherzinger force-pushed the feat/noid/optimisticReminders branch 5 times, most recently from c6db06c to 6840143 Compare October 16, 2026 11:28
AndyScherzinger and others added 3 commits October 16, 2026 13:51
Both used an Observable with a disposable that the chat throws away when it
is paused, so backgrounding the app while the request was in flight dropped
it silently. They now run in the view model scope like every other request
that has to finish.

Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
A reminder the server refused was only logged, and the chat says "Message
sent" the moment a share to notes starts, before the answer arrives - so a
share that failed was reported as a success. Both now show what happened.

Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
@mahibi
mahibi force-pushed the feat/noid/optimisticReminders branch from 6840143 to aa0d8cc Compare October 16, 2026 12:12
@mahibi
mahibi self-requested a review October 16, 2026 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews AI assisted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants