Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4593,6 +4593,7 @@ export default function ChatView({ threadId }: ChatViewProps) {
activeProjectCwd={activeProject?.cwd}
isGitRepo={isGitRepo}
isLocalDraftThread={isLocalDraftThread}
threadBranch={activeThread.branch ?? null}
openInCwd={gitCwd}
activeProjectScripts={activeProject?.scripts}
preferredScriptId={
Expand Down
53 changes: 52 additions & 1 deletion apps/web/src/components/chat/ChatHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ import {
type ThreadId,
type ResolvedKeybindingsConfig,
} from "@okcode/contracts";
import { memo, useEffect } from "react";
import { useQuery } from "@tanstack/react-query";
import { GitPullRequestIcon } from "lucide-react";
import { memo, useCallback, useEffect } from "react";
import type { ProjectScriptDraft } from "~/projectScriptDefaults";
import GitActionsControl from "../GitActionsControl";
import { EditableThreadTitle } from "../EditableThreadTitle";
import { Badge } from "../ui/badge";
import ProjectScriptsControl, { type NewProjectScriptInput } from "../ProjectScriptsControl";
import { SidebarTrigger } from "../ui/sidebar";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
import { useThreadTitleEditor } from "~/hooks/useThreadTitleEditor";
import { gitStatusQueryOptions } from "~/lib/gitReactQuery";
import { ensureNativeApi } from "~/nativeApi";
import { useProjectColor } from "~/projectColors";
import { useTheme } from "~/hooks/useTheme";
import type { ClientMode } from "~/lib/clientMode";
Expand All @@ -37,6 +42,7 @@ interface ChatHeaderProps {
previewAvailable: boolean;
previewOpen: boolean;
previewDock: PreviewDock;
threadBranch: string | null;
gitCwd: string | null;
diffOpen: boolean;
clientMode: ClientMode;
Expand All @@ -60,6 +66,7 @@ export const ChatHeader = memo(function ChatHeader({
activeProjectCwd,
isGitRepo,
isLocalDraftThread,
threadBranch,
openInCwd: _openInCwd,
activeProjectScripts,
preferredScriptId,
Expand Down Expand Up @@ -108,6 +115,25 @@ export const ChatHeader = memo(function ChatHeader({
cancelEditing();
}, [activeThreadId, cancelEditing]);

// Derive PR status from git status when the thread has an associated branch
const { data: gitStatus = null } = useQuery({
...gitStatusQueryOptions(gitCwd),
// Only need git status for PR info when thread has a branch
enabled: gitCwd !== null && threadBranch !== null,
staleTime: 30_000,
refetchInterval: 60_000,
});

const threadPr =
threadBranch !== null && gitStatus?.branch === threadBranch ? (gitStatus?.pr ?? null) : null;

const openPrLink = useCallback(
(url: string) => {
void ensureNativeApi().shell.openExternal(url);
},
[],
);

return (
<div className="flex min-w-0 flex-1 items-center gap-2">
{/* Left: Identity — thread title + project context */}
Expand Down Expand Up @@ -167,6 +193,31 @@ export const ChatHeader = memo(function ChatHeader({
onImportScripts={onImportProjectScripts}
/>
)}
{!isMobileCompanion && threadPr && (
<Tooltip>
<TooltipTrigger
render={
<button
type="button"
aria-label={`#${threadPr.number} PR ${threadPr.state}: ${threadPr.title}`}
className={`inline-flex size-7 cursor-pointer items-center justify-center rounded-md transition-colors hover:bg-accent ${
threadPr.state === "open"
? "text-emerald-600 dark:text-emerald-300/90"
: threadPr.state === "merged"
? "text-violet-600 dark:text-violet-300/90"
: "text-zinc-500 dark:text-zinc-400/80"
}`}
onClick={() => openPrLink(threadPr.url)}
>
<GitPullRequestIcon className="size-4" />
</button>
}
/>
<TooltipPopup side="bottom">
#{threadPr.number} PR {threadPr.state}: {threadPr.title}
</TooltipPopup>
</Tooltip>
)}
{!isMobileCompanion && activeProjectName && (
<GitActionsControl gitCwd={gitCwd} activeThreadId={activeThreadId} />
)}
Expand Down
Loading