-
Notifications
You must be signed in to change notification settings - Fork 6.7k
fix(mobile): a message that fails to send now says why in the thread #15807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5a1f594
fix(mobile): show why a message failed to send in the thread
6dac48d
fix(mobile): keep send errors in one map and clear them when they sto…
23a1eea
fix(mobile): a resend during send-failure recovery no longer leaves a…
237bb20
fix(mobile): drop a stale recovery error once a rejected new task is …
2997fa0
Merge remote-tracking branch 'upstream/main' into fix/mobile-send-err…
c7fe5cc
Merge remote-tracking branch 'upstream/main' into fix/mobile-send-err…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { useEffect } from "react"; | ||
| import { AccessibilityInfo, Platform, Pressable, View } from "react-native"; | ||
|
|
||
| import { AppText as Text } from "../../components/AppText"; | ||
| import { SymbolView } from "../../components/AppSymbol"; | ||
|
|
||
| /** Why the thread's last message did not send, above the composer until dismissed. */ | ||
| export function ComposerErrorNotice({ | ||
| message, | ||
| onDismiss, | ||
| }: { | ||
| readonly message: string; | ||
| readonly onDismiss: () => void; | ||
| }) { | ||
| // accessibilityLiveRegion below only reaches TalkBack; VoiceOver needs an | ||
| // explicit announcement. | ||
| useEffect(() => { | ||
| if (Platform.OS === "ios") { | ||
| AccessibilityInfo.announceForAccessibility(message); | ||
| } | ||
| }, [message]); | ||
| return ( | ||
| <View className="px-4 pb-3"> | ||
| <View className="flex-row items-start gap-3 rounded-[20px] border-continuous bg-card p-4"> | ||
| <SymbolView | ||
| name="exclamationmark.circle" | ||
| size={16} | ||
| tintColorClassName="accent-danger-foreground" | ||
| type="monochrome" | ||
| /> | ||
| <Text | ||
| selectable | ||
| accessibilityLiveRegion="polite" | ||
| className="min-w-0 flex-1 text-sm text-foreground" | ||
| > | ||
| {message} | ||
| </Text> | ||
| <Pressable | ||
| accessibilityLabel="Dismiss error" | ||
| accessibilityRole="button" | ||
| hitSlop={12} | ||
| onPress={onDismiss} | ||
| className="p-1 active:opacity-60" | ||
| > | ||
| <SymbolView | ||
| name="xmark" | ||
| size={14} | ||
| tintColorClassName="accent-icon-muted" | ||
| type="monochrome" | ||
| /> | ||
| </Pressable> | ||
| </View> | ||
| </View> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { afterEach, describe, expect, it } from "vite-plus/test"; | ||
|
|
||
| import { appAtomRegistry } from "./atom-registry"; | ||
| import { | ||
| clearThreadComposerError, | ||
| clearThreadComposerErrorsForEnvironment, | ||
| setThreadComposerError, | ||
| threadComposerErrorsAtom, | ||
| } from "./thread-composer-error"; | ||
|
|
||
| afterEach(() => { | ||
| appAtomRegistry.set(threadComposerErrorsAtom, {}); | ||
| }); | ||
|
|
||
| describe("thread composer errors", () => { | ||
| it("clears a message-scoped error only for that message", () => { | ||
| setThreadComposerError("environment-1:thread-1", "rejected", "message-1"); | ||
|
|
||
| clearThreadComposerError("environment-1:thread-1", "message-2"); | ||
| expect(appAtomRegistry.get(threadComposerErrorsAtom)["environment-1:thread-1"]?.message).toBe( | ||
| "rejected", | ||
| ); | ||
|
|
||
| clearThreadComposerError("environment-1:thread-1"); | ||
| expect(appAtomRegistry.get(threadComposerErrorsAtom)).toEqual({}); | ||
| }); | ||
|
|
||
| it("clears every thread's error for a removed environment and no others", () => { | ||
| setThreadComposerError("environment-1:thread-1", "one"); | ||
| setThreadComposerError("environment-1:thread-2", "two"); | ||
| setThreadComposerError("environment-10:thread-1", "other environment"); | ||
|
|
||
| clearThreadComposerErrorsForEnvironment("environment-1"); | ||
|
|
||
| expect(Object.keys(appAtomRegistry.get(threadComposerErrorsAtom))).toEqual([ | ||
| "environment-10:thread-1", | ||
| ]); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import { Atom } from "effect/unstable/reactivity"; | ||
|
|
||
| import { appAtomRegistry } from "./atom-registry"; | ||
|
|
||
| interface ThreadComposerError { | ||
| readonly message: string; | ||
| /** The queued message this error is about, when it is about one. */ | ||
| readonly messageId: string | null; | ||
| } | ||
|
|
||
| /** | ||
| * Why a thread's last message did not go out, shown above that thread's | ||
| * composer. The outbox drain can reject a message after the user has left the | ||
| * thread, so the reason is kept per thread until they dismiss it, send again, | ||
| * or the message it describes is delivered after all. Keyed by `scopedThreadKey`. | ||
| */ | ||
| export const threadComposerErrorsAtom = Atom.make<Readonly<Record<string, ThreadComposerError>>>( | ||
| {}, | ||
| ).pipe(Atom.keepAlive, Atom.withLabel("mobile:thread-composer-errors")); | ||
|
|
||
| export function setThreadComposerError( | ||
| threadKey: string, | ||
| message: string, | ||
| messageId: string | null = null, | ||
| ): void { | ||
| appAtomRegistry.set(threadComposerErrorsAtom, { | ||
| ...appAtomRegistry.get(threadComposerErrorsAtom), | ||
| [threadKey]: { message, messageId }, | ||
| }); | ||
| } | ||
|
|
||
| /** With `messageId`, clears only an error that describes that message. */ | ||
| export function clearThreadComposerError(threadKey: string, messageId?: string): void { | ||
| const current = appAtomRegistry.get(threadComposerErrorsAtom); | ||
| const error = current[threadKey]; | ||
| if (!error || (messageId !== undefined && error.messageId !== messageId)) { | ||
| return; | ||
| } | ||
| const next = { ...current }; | ||
| delete next[threadKey]; | ||
| appAtomRegistry.set(threadComposerErrorsAtom, next); | ||
| } | ||
|
|
||
| export function clearThreadComposerErrorsForEnvironment(environmentId: string): void { | ||
| const current = appAtomRegistry.get(threadComposerErrorsAtom); | ||
| const prefix = `${environmentId}:`; | ||
| const keys = Object.keys(current).filter((key) => key.startsWith(prefix)); | ||
| if (keys.length === 0) { | ||
| return; | ||
| } | ||
| const next = { ...current }; | ||
| for (const key of keys) { | ||
| delete next[key]; | ||
| } | ||
| appAtomRegistry.set(threadComposerErrorsAtom, next); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.