mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-09-30 12:43:16 +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(() => {
|
||||
const baseBranch =
|
||||
stream.values.targetRepository?.branch ??
|
||||
stream.values.targetRepository?.baseCommit ??
|
||||
stream.values?.targetRepository?.branch ??
|
||||
stream.values?.targetRepository?.baseCommit ??
|
||||
branch;
|
||||
if (
|
||||
!stream.values ||
|
||||
!stream.values.branchName ||
|
||||
!stream.values.targetRepository ||
|
||||
!baseBranch
|
||||
|
|
@ -49,7 +50,7 @@ export function OpenPRButton() {
|
|||
setPrState(pr.state);
|
||||
}
|
||||
});
|
||||
}, [stream.values?.branchName, stream.values.targetRepository, branch]);
|
||||
}, [stream.values?.branchName, stream.values?.targetRepository, branch]);
|
||||
|
||||
if (!pullRequest) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -86,12 +86,12 @@ export const ThreadItem = memo(function ThreadItem({
|
|||
className="flex-shrink-0"
|
||||
/>
|
||||
<span className="max-w-[90px] truncate">
|
||||
{thread.values.targetRepository.repo}
|
||||
{thread.values?.targetRepository?.repo || "x"}
|
||||
</span>
|
||||
<span>/</span>
|
||||
<GitBranch className="size-2.5 flex-shrink-0" />
|
||||
<span className="max-w-[70px] truncate">
|
||||
{thread.values.targetRepository.branch}
|
||||
{thread.values?.targetRepository?.branch || "x"}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@ function ThreadList({
|
|||
typeof t.values === "object" &&
|
||||
t.values &&
|
||||
"messages" in t.values &&
|
||||
Array.isArray(t.values.messages) &&
|
||||
t.values.messages?.length > 0
|
||||
Array.isArray(t.values?.messages) &&
|
||||
t.values?.messages?.length > 0
|
||||
) {
|
||||
const firstMessage = t.values.messages[0];
|
||||
const firstMessage = t.values?.messages[0];
|
||||
itemText = getContentString(firstMessage.content);
|
||||
}
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { GraphState } from "@open-swe/shared/open-swe/types";
|
|||
import { getActivePlanItems } from "@open-swe/shared/open-swe/tasks";
|
||||
|
||||
export function getThreadTitle(thread: Thread<GraphState>): string {
|
||||
const messages = thread?.values.messages;
|
||||
const messages = thread?.values?.messages;
|
||||
if (!messages?.length || !messages[0]?.content) {
|
||||
return `Thread ${thread.thread_id.substring(0, 8)}`;
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@ export function getThreadTasks(thread: Thread<GraphState>): {
|
|||
totalTasks: number;
|
||||
completedTasks: number;
|
||||
} {
|
||||
if (!thread.values.plan) {
|
||||
if (!thread.values || !thread.values?.plan) {
|
||||
return {
|
||||
totalTasks: 0,
|
||||
completedTasks: 0,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue