🐛 fix(vscode): 选工单不再重新加载整个看板,直接列看板上摆着的「审查」列工单,文件数一项项补上,每一步记进日志
This commit is contained in:
1 parent
4ec38cff12
commit
b3a829e658
10 files changed
+310
-112
No files matched your search
@@ -10,6 +10,7 @@ import type { IssueRef } from '../issues/stateRouter'
|
||||
import type { SessionTabKind } from './handlers/terminals'
|
||||
import type { IssueOwnershipFacts } from './issueOwnership'
|
||||
import type { KanbanScope } from './kanbanScope'
|
||||
import type { BoardIssues } from './kanbanSnapshot'
|
||||
import type { ExtensionToWebview, WebviewToExtension } from './messages'
|
||||
import { env, TabInputTerminal, ThemeColor, Uri, ViewColumn, window, workspace } from 'vscode'
|
||||
import { deleteToken, getToken } from '../auth/secrets'
|
||||
@@ -44,7 +45,7 @@ import * as youtrackIssues from './handlers/youtrackIssues'
|
||||
import { PALETTE, resolveIssueColor, themeColorIdToIconUri } from './issueColor'
|
||||
import { isIssueMine } from './issueOwnership'
|
||||
import { DEFAULT_KANBAN_SCOPE, KANBAN_SCOPE_KEY } from './kanbanScope'
|
||||
import { KANBAN_SNAPSHOT_KEY, parseKanbanSnapshot, snapshotScriptTag } from './kanbanSnapshot'
|
||||
import { boardIssues, KANBAN_SNAPSHOT_KEY, parseKanbanSnapshot, snapshotScriptTag } from './kanbanSnapshot'
|
||||
import { isOwnerOnlyMessage } from './readOnlyGuard'
|
||||
|
||||
/** Resolved at runtime via getProfilesDir() — do not hardcode user paths. */
|
||||
@@ -357,6 +358,11 @@ export class KanbanWebviewPanel {
|
||||
KanbanWebviewPanel.current?.loadAndPush().catch(() => {})
|
||||
}
|
||||
|
||||
/** 看板上现在摆着的工单(见 boardIssues),给别处(代码阅读的「选工单」)直接用,不再加载一遍。 */
|
||||
static issuesOnBoard(context: ExtensionContext): BoardIssues | undefined {
|
||||
return boardIssues(KanbanWebviewPanel.current?.snapshotIssues(), context.workspaceState.get(KANBAN_SNAPSHOT_KEY))
|
||||
}
|
||||
|
||||
/**
|
||||
* 同事工单的写操作最终拦截点。前端已按归属藏掉按钮,这里兜住快照过期
|
||||
* 或工单刚被重新指派的竞态:不是我的工单就丢消息 + 提示,不落任何副作用。
|
||||
|
||||
@@ -34,6 +34,23 @@ export function parseKanbanSnapshot(raw: unknown): KanbanSnapshot | null {
|
||||
}
|
||||
}
|
||||
|
||||
/** 看板上现在摆着的工单,和它从哪来:面板这次会话里加载好的(loaded)、上次存下的快照(saved)。 */
|
||||
export interface BoardIssues {
|
||||
issues: Issue[]
|
||||
from: 'loaded' | 'saved'
|
||||
}
|
||||
|
||||
/**
|
||||
* 看板上现在摆着的工单:面板这次会话里加载好了就用它最近一次加载的,否则用上次存下的快照
|
||||
* (重开窗口时看板先画的也是它);都没有时 undefined,看板还没加载过。
|
||||
*/
|
||||
export function boardIssues(loaded: Issue[] | undefined, persisted: unknown): BoardIssues | undefined {
|
||||
if (loaded)
|
||||
return { issues: loaded, from: 'loaded' }
|
||||
const snapshot = parseKanbanSnapshot(persisted)
|
||||
return snapshot ? { issues: snapshot.issues, from: 'saved' } : undefined
|
||||
}
|
||||
|
||||
/** 写入 HTML 的 JSON:小于号换成 \\u003c,避免 script 标签被提前关掉。 */
|
||||
export function snapshotToScriptJson(snapshot: KanbanSnapshot): string {
|
||||
return JSON.stringify(snapshot).replace(/</g, '\\u003c')
|
||||
|
||||
Reference in new issue
Block a user