The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 14:30 UTC
refactor(mobile): git action results buzz from where they are reported (#25912)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 27, 2026 at 05:35 UTC
319c572c966b19ac1e89a0114a40fb924695bd58
3 files changed
+32
-15
apps/mobile/src/features/threads/GitActionProgressOverlay.tsx
+1
-15
@@ -1,7 +1,6 @@
1
import { tryOpenExternalUrl } from "../../lib/openExternalUrl";
2
-import * as Haptics from "expo-haptics";
2
import { HeaderHeightContext } from "@react-navigation/elements";
4
-import { useContext, useEffect, useRef } from "react";
3
+import { useContext } from "react";
4
import { Platform } from "react-native";
5
import Animated, { FadeIn, FadeOut, ReduceMotion } from "react-native-reanimated";
6
import { useSafeAreaInsets } from "react-native-safe-area-context";
@@ -26,19 +25,6 @@ export function GitActionProgressOverlay(props: {
25
Platform.OS === "android"
26
? toolbar.paddingTop + toolbar.height + toolbar.paddingBottom + 8
27
: headerHeight + 8;
29
- const prevPhaseRef = useRef(progress.phase);
30
-
31
- useEffect(() => {
32
- const prev = prevPhaseRef.current;
33
- prevPhaseRef.current = progress.phase;
34
-
35
- if (prev === "running" && progress.phase === "success") {
36
- Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
37
- } else if (prev === "running" && progress.phase === "error") {
38
- Haptics.notificationAsync(Haptics.NotificationFeedbackType.Error);
39
- }
40
- }, [progress.phase]);
41
-
28
const handlePress = () => {
29
if (progress.prUrl) {
30
void (openPullRequest
apps/mobile/src/state/use-vcs-action-state.test.ts
new
+24
@@ -0,0 +1,24 @@
1
+import { describe, expect, it, vi } from "vite-plus/test";
2
+
3
+const mocks = vi.hoisted(() => ({
4
+ notificationAsync: vi.fn(() => Promise.resolve()),
5
+}));
6
+
7
+vi.mock("expo-haptics", () => ({
8
+ NotificationFeedbackType: { Success: "success", Error: "error" },
9
+ notificationAsync: mocks.notificationAsync,
10
+}));
11
+
12
+vi.mock("./vcs", () => ({ vcsActionManager: {} }));
13
+
14
+import { dismissGitActionResult, showGitActionResult } from "./use-vcs-action-state";
15
+
16
+describe("showGitActionResult", () => {
17
+ it("buzzes once per reported result with the matching feedback type", () => {
18
+ showGitActionResult({ type: "success", title: "Pushed" });
19
+ showGitActionResult({ type: "error", title: "Git action failed", description: "rejected" });
20
+ dismissGitActionResult();
21
+
22
+ expect(mocks.notificationAsync.mock.calls).toEqual([["success"], ["error"]]);
23
+ });
24
+});
apps/mobile/src/state/use-vcs-action-state.ts
+7
@@ -2,6 +2,7 @@ import { useAtomValue } from "@effect/atom-react";
2
import { secondTick } from "@t3tools/client-runtime/clock";
3
import { type VcsActionState, type VcsActionTarget } from "@t3tools/client-runtime/state/vcs";
4
import { Atom } from "effect/reactivity";
5
+import * as Haptics from "expo-haptics";
6
import { useSyncExternalStore } from "react";
7
8
import { appAtomRegistry } from "./atom-registry";
@@ -31,6 +32,12 @@ function broadcast(result: GitActionResultNotification | null): void {
32
}
33
34
export function showGitActionResult(result: GitActionResultNotification): void {
35
+ // Best effort: devices without a haptics engine reject.
36
+ Haptics.notificationAsync(
37
+ result.type === "success"
38
+ ? Haptics.NotificationFeedbackType.Success
39
+ : Haptics.NotificationFeedbackType.Error,
40
+ ).catch(() => undefined);
41
if (dismissTimer) clearTimeout(dismissTimer);
42
broadcast(result);
43
dismissTimer = setTimeout(() => {