From c9eaca29041c507690b52b5458453c88d612f874 Mon Sep 17 00:00:00 2001 From: cruldra Date: Wed, 19 Aug 2026 17:01:05 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(vscode):=20=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E5=88=86=E5=B1=82=E8=AF=BB=E4=BE=A7=E8=A1=A5=E6=BC=8F?= =?UTF-8?q?=E2=80=94=E2=80=94=E5=9B=9B=E5=A4=84=20handler=20=E6=94=B9?= =?UTF-8?q?=E8=B5=B0=20readIssueState=20=E5=8F=A0=E5=8A=A0=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vscode/src/panel/handlers/issues.ts | 50 ++++++++--------------------- 1 file changed, 13 insertions(+), 37 deletions(-) diff --git a/vscode/src/panel/handlers/issues.ts b/vscode/src/panel/handlers/issues.ts index f1e69f7..f7f6fb4 100644 --- a/vscode/src/panel/handlers/issues.ts +++ b/vscode/src/panel/handlers/issues.ts @@ -27,7 +27,7 @@ import { removeDependency, } from '../../gitea/api' import { isValidSpxFilePath, loadIssues } from '../../gitea/issueLoader' -import { mergeStateJsonComment, readStateJsonComment } from '../../gitea/stateJson' +import { mergeStateJsonComment } from '../../gitea/stateJson' import { logger } from '../../logging/logger' import { getSettings } from '../../settings/store' import { webhookCoordinator } from '../../webhook/coordinator' @@ -100,7 +100,7 @@ export async function handleColumnChange(panel: KanbanWebviewPanel, issueNumber: return } - // 1. 读最新 state JSON(从尾往前找已知字段,避免普通评论盖住 branch)。 + // 1. 读工单状态(共享评论叠加本机 workspaceState 记录)。 let prStr: string | undefined let worktreePath: string | undefined let fromColumn: IssueColumn | undefined @@ -108,13 +108,7 @@ export async function handleColumnChange(panel: KanbanWebviewPanel, issueNumber: let testSessionId: string | undefined let featureBranchFromState: string | undefined try { - const stateObj = await readStateJsonComment({ - host: remote.host, - token, - owner: remote.owner, - repo: remote.repo, - issueNumber, - }) + const stateObj = await panel.readIssueState(issueNumber) if (typeof stateObj.pr === 'string' && stateObj.pr.length > 0) prStr = stateObj.pr if (typeof stateObj.worktreePath === 'string' && stateObj.worktreePath.length > 0) @@ -563,10 +557,10 @@ export async function handleColumnChange(panel: KanbanWebviewPanel, issueNumber: /** * Handle a "drag to in-progress" kanban move. * - * Validates the issue has a valid `planFile` recorded in its state JSON, + * Validates the issue has a valid `planFile` recorded in its state, * and that the file actually exists on disk, then delegates the full * implementation pipeline to `handleImplement` (which owns issue locking, - * tab reuse, state JSON column/branch/worktreePath writes, gitea webhook + * tab reuse, column/branch/worktreePath state writes, gitea webhook * registration, cc spawn). On any pre-flight failure, rolls the optimistic * column move back to the source column. */ @@ -621,17 +615,11 @@ export async function handleDropToInProgress(panel: KanbanWebviewPanel, issueNum return } - // Read latest state JSON to obtain source column + planFile + optional - // profilePath / sessionId. + // 读工单状态(共享评论叠加本机记录)拿 source column + planFile + + // 可选的 profilePath / sessionId。 let stateObj: Record = {} try { - stateObj = await readStateJsonComment({ - host: remote.host, - owner: remote.owner, - repo: remote.repo, - token, - issueNumber, - }) + stateObj = await panel.readIssueState(issueNumber) } catch (err) { const message = err instanceof Error ? err.message : String(err) @@ -695,8 +683,8 @@ export async function handleDropToInProgress(panel: KanbanWebviewPanel, issueNum return } - const profilePath = typeof stateObj.profilePath === 'string' ? stateObj.profilePath : undefined - const sessionId = typeof stateObj.sessionId === 'string' ? stateObj.sessionId : undefined + const profilePath = typeof stateObj.profilePath === 'string' && stateObj.profilePath.length > 0 ? stateObj.profilePath : undefined + const sessionId = typeof stateObj.sessionId === 'string' && stateObj.sessionId.length > 0 ? stateObj.sessionId : undefined try { await panel.handleImplement(issueNumber, planFile, profilePath, sessionId) } @@ -864,16 +852,10 @@ export async function handleDeleteIssue(panel: KanbanWebviewPanel, issueNumber: return } - // 3. 读 state JSON 拿 pr / branch / worktreePath + // 3. 读工单状态(共享评论叠加本机记录)拿 pr / branch / worktreePath let stateObj: Record = {} try { - stateObj = await readStateJsonComment({ - host: remote.host, - owner: remote.owner, - repo: remote.repo, - token, - issueNumber, - }) + stateObj = await panel.readIssueState(issueNumber) } catch (err) { const message = err instanceof Error ? err.message : String(err) @@ -1945,13 +1927,7 @@ export async function handleGeneratePrDiffSummary(panel: KanbanWebviewPanel, iss } try { - const state = await readStateJsonComment({ - host: remote.host, - owner: remote.owner, - repo: remote.repo, - token, - issueNumber, - }) + const state = await panel.readIssueState(issueNumber) const pr = typeof state.pr === 'string' && /^\d+$/.test(state.pr) ? state.pr : undefined if (!pr) { panel.postMessage({