mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
* Fix permission response by including directory parameter Extract directory from query key in useActiveRepos hook and pass it to OpenCodeClient when responding to permissions. Use composite keys for client and SSE connection tracking to support multiple repos with the same URL but different directories. * Keep permission dialog open on response failure and show error toast * Fix permission request proxying to preserve query parameters The backend proxy was incorrectly handling URL query parameters when stripping the /api/opencode prefix. This caused the directory parameter to not be passed correctly to the OpenCode server, breaking the permission request/response flow. Changes: - Separate pathname and search parameters explicitly - Only strip /api/opencode from pathname, preserve search params - Add logging for permission requests to aid debugging - Update error logging to use correct variables This fix ensures that permission responses are properly forwarded to the OpenCode server with all necessary query parameters, allowing the session to proceed correctly when users grant permissions. * Fix permission client lookup when only individual sessions are loaded The PermissionContext failed to find a client when responding to permissions because it only scanned the sessions list query, but SessionDetail and other pages only load individual sessions via useSession. Changes: - Update useActiveRepos to also scan individual session queries - Match query keys like ['opencode', 'session', url, sessionId, directory] - Extract session ID from individual session query data - Build active repos map from both sessions list and individual session queries This ensures permission dialogs can find the appropriate client to send responses, even when viewing a single session without loading the full sessions list. * Fix permission client lookup with fallback to query cache The activeRepos state was often empty when permission dialogs appeared due to timing issues with the React Query cache subscription. This caused No client found for session errors. Changes: - Add fallback scan of query cache directly in getClient when activeRepos is empty - Remove excessive debug logging that was spamming console - Add minimal log only when fallback is actually used - Fix query key length checks to be more robust This ensures permission responses work correctly even if the useActiveRepos hook hasn't yet populated the state, by falling back to scanning the query cache directly to find the session and creating the appropriate OpenCodeClient. * Add directory-based permission requests with global notification and message auto-refresh --------- Co-authored-by: OpenCode Agent <agent@opencode.ai> Co-authored-by: Chris Scott <chris@cstech.dev>
54 lines
1.9 KiB
TypeScript
54 lines
1.9 KiB
TypeScript
import { Settings } from "lucide-react";
|
|
import { Button } from "@/components/ui/button";
|
|
import { BackButton } from "@/components/ui/back-button";
|
|
import { useSettingsDialog } from "@/hooks/useSettingsDialog";
|
|
import { useTheme } from "@/hooks/useTheme";
|
|
import type { ReactNode } from "react";
|
|
|
|
interface HeaderProps {
|
|
title: string;
|
|
backTo?: string;
|
|
action?: ReactNode;
|
|
}
|
|
|
|
export function Header({ title, backTo, action }: HeaderProps) {
|
|
const { open: openSettings } = useSettingsDialog();
|
|
const theme = useTheme();
|
|
|
|
return (
|
|
<header className="sticky top-0 z-10 bg-gradient-to-b from-background via-background to-background border-b border-border backdrop-blur-sm">
|
|
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
|
<div className="flex items-center justify-between h-16">
|
|
<div className="flex items-center gap-4">
|
|
{backTo && <BackButton to={backTo} />}
|
|
<div className="flex items-center gap-2">
|
|
{title === "OpenCode" ? (
|
|
<img
|
|
src={theme === 'light' ? "/opencode-wordmark-light.svg" : "/opencode-wordmark-dark.svg"}
|
|
alt="OpenCode"
|
|
className="h-6 w-auto sm:h-8"
|
|
/>
|
|
) : (
|
|
<h1 className="text-xl font-semibold bg-gradient-to-r from-foreground to-muted-foreground bg-clip-text text-transparent truncate">
|
|
{title}
|
|
</h1>
|
|
)}
|
|
</div>
|
|
</div>
|
|
<div className="flex items-center gap-2">
|
|
{action && <div>{action}</div>}
|
|
<Button
|
|
variant="ghost"
|
|
size="icon"
|
|
onClick={openSettings}
|
|
className="text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-200"
|
|
>
|
|
<Settings className="w-10 h-10" />
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
);
|
|
}
|