mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-04 10:12:10 +00:00
fix: Type errors where thread value is undefined (#144)
This commit is contained in:
parent
f549d119ab
commit
baab1e989a
4 changed files with 11 additions and 10 deletions
|
|
@ -23,10 +23,11 @@ export function OpenPRButton() {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const baseBranch =
|
const baseBranch =
|
||||||
stream.values.targetRepository?.branch ??
|
stream.values?.targetRepository?.branch ??
|
||||||
stream.values.targetRepository?.baseCommit ??
|
stream.values?.targetRepository?.baseCommit ??
|
||||||
branch;
|
branch;
|
||||||
if (
|
if (
|
||||||
|
!stream.values ||
|
||||||
!stream.values.branchName ||
|
!stream.values.branchName ||
|
||||||
!stream.values.targetRepository ||
|
!stream.values.targetRepository ||
|
||||||
!baseBranch
|
!baseBranch
|
||||||
|
|
@ -49,7 +50,7 @@ export function OpenPRButton() {
|
||||||
setPrState(pr.state);
|
setPrState(pr.state);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [stream.values?.branchName, stream.values.targetRepository, branch]);
|
}, [stream.values?.branchName, stream.values?.targetRepository, branch]);
|
||||||
|
|
||||||
if (!pullRequest) {
|
if (!pullRequest) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -86,12 +86,12 @@ export const ThreadItem = memo(function ThreadItem({
|
||||||
className="flex-shrink-0"
|
className="flex-shrink-0"
|
||||||
/>
|
/>
|
||||||
<span className="max-w-[90px] truncate">
|
<span className="max-w-[90px] truncate">
|
||||||
{thread.values.targetRepository.repo}
|
{thread.values?.targetRepository?.repo || "x"}
|
||||||
</span>
|
</span>
|
||||||
<span>/</span>
|
<span>/</span>
|
||||||
<GitBranch className="size-2.5 flex-shrink-0" />
|
<GitBranch className="size-2.5 flex-shrink-0" />
|
||||||
<span className="max-w-[70px] truncate">
|
<span className="max-w-[70px] truncate">
|
||||||
{thread.values.targetRepository.branch}
|
{thread.values?.targetRepository?.branch || "x"}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,10 @@ function ThreadList({
|
||||||
typeof t.values === "object" &&
|
typeof t.values === "object" &&
|
||||||
t.values &&
|
t.values &&
|
||||||
"messages" in t.values &&
|
"messages" in t.values &&
|
||||||
Array.isArray(t.values.messages) &&
|
Array.isArray(t.values?.messages) &&
|
||||||
t.values.messages?.length > 0
|
t.values?.messages?.length > 0
|
||||||
) {
|
) {
|
||||||
const firstMessage = t.values.messages[0];
|
const firstMessage = t.values?.messages[0];
|
||||||
itemText = getContentString(firstMessage.content);
|
itemText = getContentString(firstMessage.content);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { GraphState } from "@open-swe/shared/open-swe/types";
|
||||||
import { getActivePlanItems } from "@open-swe/shared/open-swe/tasks";
|
import { getActivePlanItems } from "@open-swe/shared/open-swe/tasks";
|
||||||
|
|
||||||
export function getThreadTitle(thread: Thread<GraphState>): string {
|
export function getThreadTitle(thread: Thread<GraphState>): string {
|
||||||
const messages = thread?.values.messages;
|
const messages = thread?.values?.messages;
|
||||||
if (!messages?.length || !messages[0]?.content) {
|
if (!messages?.length || !messages[0]?.content) {
|
||||||
return `Thread ${thread.thread_id.substring(0, 8)}`;
|
return `Thread ${thread.thread_id.substring(0, 8)}`;
|
||||||
}
|
}
|
||||||
|
|
@ -16,7 +16,7 @@ export function getThreadTasks(thread: Thread<GraphState>): {
|
||||||
totalTasks: number;
|
totalTasks: number;
|
||||||
completedTasks: number;
|
completedTasks: number;
|
||||||
} {
|
} {
|
||||||
if (!thread.values.plan) {
|
if (!thread.values || !thread.values?.plan) {
|
||||||
return {
|
return {
|
||||||
totalTasks: 0,
|
totalTasks: 0,
|
||||||
completedTasks: 0,
|
completedTasks: 0,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue