Repository navigation
feat(web,mobile): Continue on… a linked environment #16758
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
Open
+892
−22
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c0180c1
feat(web,mobile): Continue on… a linked environment
juliusmarminge 96f0f4d
fix(web): handoff menus, sends and banners respect the move's state
juliusmarminge 0a37602
fix(mobile): offer a thread's move only when it can work
juliusmarminge 885fac7
fix(web,mobile): Continue on… needs operate access, and the mobile fa…
juliusmarminge 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
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
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,95 @@ | ||
| import { threadHandoffNotice } from "@t3tools/client-runtime/state/peerLinks"; | ||
| import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime"; | ||
| import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell"; | ||
| import { useNavigation } from "@react-navigation/native"; | ||
| import { useState } from "react"; | ||
| import { View } from "react-native"; | ||
|
|
||
| import { AppText as Text } from "../../components/ui/AppText"; | ||
| import { cn } from "../../lib/cn"; | ||
| import { useEnvironments } from "../../state/environments"; | ||
| import { threadHandoffEnvironment } from "../../state/threadHandoff"; | ||
| import { useAtomCommand } from "../../state/use-atom-command"; | ||
| import { RequestActionButton } from "./RequestActionButton"; | ||
|
|
||
| /** Whether the composer is closed because the thread is moving or has moved away. */ | ||
| export function threadHandoffClosesComposer( | ||
| thread: Pick<EnvironmentThreadShell, "handoff">, | ||
| ): boolean { | ||
| return thread.handoff?.state === "departing" || thread.handoff?.state === "departed"; | ||
| } | ||
|
|
||
| /** | ||
| * A thread's move to a linked environment: waiting for its turn to end (with | ||
| * Keep it here), under way, moved (with a link there when this app is | ||
| * connected to it), or failed. | ||
| */ | ||
| export function ThreadHandoffCard({ thread }: { thread: EnvironmentThreadShell }) { | ||
| const navigation = useNavigation(); | ||
| const cancel = useAtomCommand(threadHandoffEnvironment.cancel, { | ||
| label: "cancel thread move", | ||
| reportFailure: false, | ||
| }); | ||
| const [cancelling, setCancelling] = useState(false); | ||
| const [error, setError] = useState<string | null>(null); | ||
| const { presentationById } = useEnvironments(); | ||
| const handoff = thread.handoff; | ||
| const notice = threadHandoffNotice(handoff); | ||
| if (handoff === null || notice === null) return null; | ||
|
|
||
| const keepHere = async () => { | ||
| setCancelling(true); | ||
| setError(null); | ||
| const result = await cancel({ | ||
| environmentId: thread.environmentId, | ||
| input: { threadId: thread.id }, | ||
| }); | ||
| setCancelling(false); | ||
| if (result._tag === "Failure") setError(String(squashAtomCommandFailure(result))); | ||
| }; | ||
|
|
||
| return ( | ||
| <View className="mx-3 mb-2 gap-2 rounded-xl border border-border-subtle bg-screen p-3"> | ||
| <Text | ||
| className={cn( | ||
| "text-sm font-t3-bold", | ||
| notice.tone === "error" ? "text-danger-foreground" : "text-foreground", | ||
| )} | ||
| > | ||
| {notice.title} | ||
| </Text> | ||
| {notice.detail !== null ? ( | ||
| <Text className="text-sm text-foreground-secondary">{notice.detail}</Text> | ||
| ) : null} | ||
| {handoff.state === "pending" ? ( | ||
| <View className="flex-row"> | ||
| <RequestActionButton | ||
| label={cancelling ? "Cancelling…" : "Keep it here"} | ||
| tone="secondary" | ||
| disabled={cancelling} | ||
| onPress={() => void keepHere()} | ||
| /> | ||
| </View> | ||
| ) : handoff.state === "departed" && | ||
| presentationById.get(handoff.environmentId)?.connection.phase === "connected" ? ( | ||
| <View className="flex-row"> | ||
| <RequestActionButton | ||
| label={`Open on ${handoff.label}`} | ||
| tone="secondary" | ||
| onPress={() => | ||
| navigation.navigate("Thread", { | ||
| environmentId: handoff.environmentId, | ||
| threadId: handoff.threadId, | ||
| }) | ||
| } | ||
| /> | ||
| </View> | ||
| ) : null} | ||
| {error !== null ? ( | ||
| <Text accessibilityRole="alert" className="text-sm text-danger-foreground"> | ||
| {error} | ||
| </Text> | ||
| ) : null} | ||
| </View> | ||
| ); | ||
| } |
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.