mirror of
https://fastgit.cc/https://github.com/anomalyco/opencode
synced 2026-04-21 21:31:53 +08:00
deduplicate sameTab
This commit is contained in:
@@ -29,6 +29,7 @@ import {
|
||||
listSubagentQuestions,
|
||||
listSubagentTabs,
|
||||
reduceSubagentData,
|
||||
sameSubagentTab,
|
||||
snapshotSelectedSubagentData,
|
||||
snapshotSubagentData,
|
||||
SUBAGENT_BOOTSTRAP_LIMIT,
|
||||
@@ -305,30 +306,12 @@ function composeFooter(input: {
|
||||
return footer
|
||||
}
|
||||
|
||||
function sameTab(a: FooterSubagentTab | undefined, b: FooterSubagentTab | undefined) {
|
||||
if (!a || !b) {
|
||||
return false
|
||||
}
|
||||
|
||||
return (
|
||||
a.sessionID === b.sessionID &&
|
||||
a.partID === b.partID &&
|
||||
a.callID === b.callID &&
|
||||
a.label === b.label &&
|
||||
a.description === b.description &&
|
||||
a.status === b.status &&
|
||||
a.title === b.title &&
|
||||
a.toolCalls === b.toolCalls &&
|
||||
a.lastUpdatedAt === b.lastUpdatedAt
|
||||
)
|
||||
}
|
||||
|
||||
function traceTabs(trace: Trace | undefined, prev: FooterSubagentTab[], next: FooterSubagentTab[]) {
|
||||
const before = new Map(prev.map((item) => [item.sessionID, item]))
|
||||
const after = new Map(next.map((item) => [item.sessionID, item]))
|
||||
|
||||
for (const [sessionID, tab] of after) {
|
||||
if (sameTab(before.get(sessionID), tab)) {
|
||||
if (sameSubagentTab(before.get(sessionID), tab)) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -67,8 +67,8 @@ function ensureDetail(data: SubagentData, sessionID: string) {
|
||||
return next
|
||||
}
|
||||
|
||||
function sameTab(a: FooterSubagentTab | undefined, b: FooterSubagentTab) {
|
||||
if (!a) {
|
||||
export function sameSubagentTab(a: FooterSubagentTab | undefined, b: FooterSubagentTab | undefined) {
|
||||
if (!a || !b) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ function syncTaskTab(data: SubagentData, part: ToolPart, children?: Set<string>)
|
||||
}
|
||||
|
||||
const next = taskTab(part, sessionID)
|
||||
if (sameTab(data.tabs.get(sessionID), next)) {
|
||||
if (sameSubagentTab(data.tabs.get(sessionID), next)) {
|
||||
ensureDetail(data, sessionID)
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user