fix: scope useWorkspace to panel and add FLY_TOKEN env fallbacks
This commit is contained in:
1 parent
b8f5b77931
commit
d399919690
3 files changed
+33
-16
No files matched your search
+15
-10
@@ -2,7 +2,6 @@ import {
|
||||
type PluginHostProps,
|
||||
useRpc,
|
||||
useSubscription,
|
||||
useWorkspace,
|
||||
} from "@getpaseo/plugin/client";
|
||||
import { ScrollView, TextInput, copyText, useToast } from "@getpaseo/plugin/client/ui";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
@@ -25,11 +24,17 @@ import {
|
||||
} from "../shared/contracts";
|
||||
|
||||
interface WorkersScreenProps extends PluginHostProps {
|
||||
workspaceId?: string;
|
||||
workspaceName?: string;
|
||||
workspaceDirectory?: string;
|
||||
}
|
||||
|
||||
export function FlySpritesWorkersScreen({ theme, layout, host, workspaceId }: WorkersScreenProps) {
|
||||
const workspace = useWorkspace(workspaceId ?? "");
|
||||
export function FlySpritesWorkersScreen({
|
||||
theme,
|
||||
layout,
|
||||
host,
|
||||
workspaceName,
|
||||
workspaceDirectory,
|
||||
}: WorkersScreenProps) {
|
||||
const toast = useToast();
|
||||
|
||||
const fetchStatus = useRpc(statusRpc);
|
||||
@@ -53,8 +58,8 @@ export function FlySpritesWorkersScreen({ theme, layout, host, workspaceId }: Wo
|
||||
|
||||
const [spriteNameInput, setSpriteNameInput] = useState("");
|
||||
const [commandInput, setCommandInput] = useState("");
|
||||
const [syncPathInput, setSyncPathInput] = useState(workspace?.directory ?? "");
|
||||
const [syncBeforeSpawn, setSyncBeforeSpawn] = useState(Boolean(workspace?.directory));
|
||||
const [syncPathInput, setSyncPathInput] = useState(workspaceDirectory ?? "");
|
||||
const [syncBeforeSpawn, setSyncBeforeSpawn] = useState(Boolean(workspaceDirectory));
|
||||
|
||||
const [selectedWorkerId, setSelectedWorkerId] = useState<string | null>(null);
|
||||
const [fullLogs, setFullLogs] = useState<string>("");
|
||||
@@ -62,11 +67,11 @@ export function FlySpritesWorkersScreen({ theme, layout, host, workspaceId }: Wo
|
||||
const [checkpoints, setCheckpoints] = useState<CheckpointSummary[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
if (workspace?.directory && !syncPathInput) {
|
||||
setSyncPathInput(workspace.directory);
|
||||
if (workspaceDirectory && !syncPathInput) {
|
||||
setSyncPathInput(workspaceDirectory);
|
||||
setSyncBeforeSpawn(true);
|
||||
}
|
||||
}, [workspace?.directory, syncPathInput]);
|
||||
}, [workspaceDirectory, syncPathInput]);
|
||||
|
||||
const watchInput = useMemo(() => ({}), []);
|
||||
useSubscription(watchWorkersSub, watchInput, (event) => {
|
||||
@@ -341,7 +346,7 @@ export function FlySpritesWorkersScreen({ theme, layout, host, workspaceId }: Wo
|
||||
<Text style={styles.title}>Fly Sprites Workers</Text>
|
||||
<Text style={styles.muted}>
|
||||
Host: {host.label} · Token: {tokenSource}
|
||||
{workspace ? ` · Workspace: ${workspace.name}` : ""}
|
||||
{workspaceName ? ` · Workspace: ${workspaceName}` : ""}
|
||||
</Text>
|
||||
</View>
|
||||
<Pressable style={styles.btnSecondary} onPress={() => void refresh()} disabled={loading}>
|
||||
|
||||
Reference in new issue
Block a user