mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-06 04:12:16 +00:00
feat: display stream targetRepository data in disabled selectors (#131)
* Apply patch * Apply patch * Apply patch * format * fix import type
This commit is contained in:
parent
0709d9fe98
commit
4c29af3849
3 changed files with 28 additions and 2 deletions
|
|
@ -17,12 +17,14 @@ import { cn } from "@/lib/utils";
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { useGitHubAppProvider } from "@/providers/GitHubApp";
|
import { useGitHubAppProvider } from "@/providers/GitHubApp";
|
||||||
import { GitBranch, Shield } from "lucide-react";
|
import { GitBranch, Shield } from "lucide-react";
|
||||||
|
import { TargetRepository } from "@open-swe/shared/open-swe/types";
|
||||||
|
|
||||||
interface BranchSelectorProps {
|
interface BranchSelectorProps {
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
buttonClassName?: string;
|
buttonClassName?: string;
|
||||||
chatStarted?: boolean;
|
chatStarted?: boolean;
|
||||||
|
streamTargetRepository?: TargetRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function BranchSelector({
|
export function BranchSelector({
|
||||||
|
|
@ -30,6 +32,7 @@ export function BranchSelector({
|
||||||
placeholder = "Select a branch...",
|
placeholder = "Select a branch...",
|
||||||
buttonClassName,
|
buttonClassName,
|
||||||
chatStarted = false,
|
chatStarted = false,
|
||||||
|
streamTargetRepository,
|
||||||
}: BranchSelectorProps) {
|
}: BranchSelectorProps) {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const {
|
const {
|
||||||
|
|
@ -147,6 +150,12 @@ export function BranchSelector({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Determine the display value - prioritize stream data when chatStarted and available
|
||||||
|
const displayValue =
|
||||||
|
chatStarted && streamTargetRepository?.branch
|
||||||
|
? streamTargetRepository.branch
|
||||||
|
: selectedBranch;
|
||||||
|
|
||||||
if (chatStarted) {
|
if (chatStarted) {
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
|
|
@ -157,7 +166,7 @@ export function BranchSelector({
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-2">
|
<div className="flex min-w-0 flex-1 items-center gap-2">
|
||||||
<GitBranch />
|
<GitBranch />
|
||||||
<span className="truncate text-left">
|
<span className="truncate text-left">
|
||||||
{selectedBranch || placeholder}
|
{displayValue || placeholder}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { BranchSelector } from "./branch-selector";
|
import { BranchSelector } from "./branch-selector";
|
||||||
import { RepositorySelector } from "./repository-selector";
|
import { RepositorySelector } from "./repository-selector";
|
||||||
import { useQueryState } from "nuqs";
|
import { useQueryState } from "nuqs";
|
||||||
|
import { useStreamContext } from "@/providers/Stream";
|
||||||
|
|
||||||
export function RepositoryBranchSelectors() {
|
export function RepositoryBranchSelectors() {
|
||||||
const [threadId] = useQueryState("threadId");
|
const [threadId] = useQueryState("threadId");
|
||||||
|
|
@ -10,6 +11,12 @@ export function RepositoryBranchSelectors() {
|
||||||
const defaultStylesChatStarted =
|
const defaultStylesChatStarted =
|
||||||
"hover:bg-inherit cursor-default hover:cursor-default hover:text-gray-500 hover:border-gray-300 hover:ring-inherit";
|
"hover:bg-inherit cursor-default hover:cursor-default hover:text-gray-500 hover:border-gray-300 hover:ring-inherit";
|
||||||
|
|
||||||
|
// Access stream context when chat has started
|
||||||
|
const stream = useStreamContext();
|
||||||
|
const streamTargetRepository = chatStarted
|
||||||
|
? stream?.values?.targetRepository
|
||||||
|
: undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<RepositorySelector
|
<RepositorySelector
|
||||||
|
|
@ -18,6 +25,7 @@ export function RepositoryBranchSelectors() {
|
||||||
defaultButtonStyles +
|
defaultButtonStyles +
|
||||||
(chatStarted ? " " + defaultStylesChatStarted : "")
|
(chatStarted ? " " + defaultStylesChatStarted : "")
|
||||||
}
|
}
|
||||||
|
streamTargetRepository={streamTargetRepository}
|
||||||
/>
|
/>
|
||||||
<BranchSelector
|
<BranchSelector
|
||||||
chatStarted={chatStarted}
|
chatStarted={chatStarted}
|
||||||
|
|
@ -25,6 +33,7 @@ export function RepositoryBranchSelectors() {
|
||||||
defaultButtonStyles +
|
defaultButtonStyles +
|
||||||
(chatStarted ? " " + defaultStylesChatStarted : "")
|
(chatStarted ? " " + defaultStylesChatStarted : "")
|
||||||
}
|
}
|
||||||
|
streamTargetRepository={streamTargetRepository}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ interface RepositorySelectorProps {
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
buttonClassName?: string;
|
buttonClassName?: string;
|
||||||
chatStarted?: boolean;
|
chatStarted?: boolean;
|
||||||
|
streamTargetRepository?: TargetRepository;
|
||||||
}
|
}
|
||||||
// TODO: remove this, we should use the TargetRepository type from the open-swe package
|
// TODO: remove this, we should use the TargetRepository type from the open-swe package
|
||||||
// Convert GitHub Repository to TargetRepository format
|
// Convert GitHub Repository to TargetRepository format
|
||||||
|
|
@ -41,6 +42,7 @@ export function RepositorySelector({
|
||||||
placeholder = "Select a repository...",
|
placeholder = "Select a repository...",
|
||||||
buttonClassName,
|
buttonClassName,
|
||||||
chatStarted = false,
|
chatStarted = false,
|
||||||
|
streamTargetRepository,
|
||||||
}: RepositorySelectorProps) {
|
}: RepositorySelectorProps) {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const {
|
const {
|
||||||
|
|
@ -69,6 +71,12 @@ export function RepositorySelector({
|
||||||
? `${selectedRepository.owner}/${selectedRepository.repo}`
|
? `${selectedRepository.owner}/${selectedRepository.repo}`
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
// When chatStarted and streamTargetRepository is available, use it for display
|
||||||
|
const displayValue =
|
||||||
|
chatStarted && streamTargetRepository
|
||||||
|
? `${streamTargetRepository.owner}/${streamTargetRepository.repo}`
|
||||||
|
: selectedValue;
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
|
|
@ -155,7 +163,7 @@ export function RepositorySelector({
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-2">
|
<div className="flex min-w-0 flex-1 items-center gap-2">
|
||||||
<GitHubSVG />
|
<GitHubSVG />
|
||||||
<span className="truncate text-left">
|
<span className="truncate text-left">
|
||||||
{selectedValue || placeholder}
|
{displayValue || placeholder}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue