fix: scope useWorkspace to panel and add FLY_TOKEN env fallbacks

This commit is contained in:
nandi committed 2026-11-18 16:39:17 -08:00
1 parent b8f5b77931
commit d399919690
3 files changed
+33 -16

No files matched your search

+15 -10
View File
@@ -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}>
+13 -5
View File
@@ -1,7 +1,8 @@
import type {
PluginClientContext,
PluginSidebarItemProps,
PluginWorkspacePanelProps,
import {
type PluginClientContext,
type PluginSidebarItemProps,
type PluginWorkspacePanelProps,
useWorkspace,
} from "@getpaseo/plugin/client";
import { SidebarRow } from "@getpaseo/plugin/client/ui";
import { FlySpritesSettingsScreen } from "./client/settings-screen";
@@ -18,7 +19,14 @@ function WorkersSidebarItem({ currentScreen, openScreen }: PluginSidebarItemProp
}
function WorkspaceWorkersPanel({ workspaceId, ...hostProps }: PluginWorkspacePanelProps) {
return <FlySpritesWorkersScreen {...hostProps} workspaceId={workspaceId} />;
const workspace = useWorkspace(workspaceId);
return (
<FlySpritesWorkersScreen
{...hostProps}
workspaceName={workspace?.name}
workspaceDirectory={workspace?.directory}
/>
);
}
export default function contribute(client: PluginClientContext) {
+5 -1
View File
@@ -109,7 +109,11 @@ export class SpritesManager {
if (fromSettings) {
return { token: fromSettings, source: "settings", baseUrl };
}
const fromEnv = process.env.SPRITES_TOKEN?.trim() ?? "";
const fromEnv =
process.env.SPRITES_TOKEN?.trim() ||
process.env.FLY_TOKEN?.trim() ||
process.env.FLY_API_TOKEN?.trim() ||
"";
if (fromEnv) {
return { token: fromEnv, source: "env", baseUrl };
}