🐛 fix(vscode): 改动 tab 默认统一视图并保留阅读位置
This commit is contained in:
@@ -588,6 +588,14 @@ export class KanbanWebviewPanel {
|
||||
void prFiles.handleSetPrReviewConfirmed(this, msg)
|
||||
return
|
||||
}
|
||||
if (msg.type === 'pr-diff-mode/get') {
|
||||
prFiles.handleGetPrDiffMode(this)
|
||||
return
|
||||
}
|
||||
if (msg.type === 'pr-diff-mode/set') {
|
||||
void prFiles.handleSetPrDiffMode(this, msg.mode)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// internal: handler 模块访问
|
||||
|
||||
@@ -19,6 +19,7 @@ import { getPullRequest, getRawFile, listPullRequestFiles } from '../../gitea/ap
|
||||
import { readStateJsonComment } from '../../gitea/stateJson'
|
||||
import { readFileSummaries, readSummarySession, writeFileSummary, writeSummarySession } from '../../sessions/prFileSummaryStore'
|
||||
import { readConfirmedSigs, writeConfirmedSigs } from '../../sessions/prReviewStore'
|
||||
import { parsePrDiffMode, type PrDiffMode } from '../../cc/prDiffMode'
|
||||
import { makeNonce } from '../KanbanPanel'
|
||||
|
||||
/**
|
||||
@@ -351,3 +352,22 @@ export async function handleGeneratePrFileSummary(
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const PR_DIFF_MODE_KEY = 'prDiffMode'
|
||||
|
||||
/** 读 workspace 级 diff 模式(缺省 unified),回推 webview。 */
|
||||
export function handleGetPrDiffMode(panel: KanbanWebviewPanel): void {
|
||||
const stored = panel.context.workspaceState.get<unknown>(PR_DIFF_MODE_KEY)
|
||||
const mode = parsePrDiffMode(stored)
|
||||
panel.postMessage({ type: 'pr-diff-mode/show', mode })
|
||||
}
|
||||
|
||||
/** 写 workspace 级 diff 模式;非法值按 unified 落盘。 */
|
||||
export async function handleSetPrDiffMode(
|
||||
panel: KanbanWebviewPanel,
|
||||
mode: unknown,
|
||||
): Promise<void> {
|
||||
const next: PrDiffMode = parsePrDiffMode(mode)
|
||||
await panel.context.workspaceState.update(PR_DIFF_MODE_KEY, next)
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +109,7 @@ export type ExtensionToWebview
|
||||
| { type: 'pr-files/show', issueNumber: number, files: PrFile[], confirmed: string[], summaries: Record<string, string>, error?: string }
|
||||
| { type: 'pr-file-diff/show', issueNumber: number, path: string, oldContent: string, newContent: string, oldLang?: string, newLang?: string, error?: string }
|
||||
| { type: 'pr-file-summary/show', issueNumber: number, path: string, summary?: string, error?: string }
|
||||
| { type: 'pr-diff-mode/show', mode: 'unified' | 'split' }
|
||||
// profile 值编辑器粘贴的图片:存盘/读盘的回执,requestId 关联并发请求。
|
||||
| { type: 'profile-asset/saved', requestId: string, assetPath?: string, error?: string }
|
||||
| { type: 'profile-asset/loaded', requestId: string, dataUrl?: string, error?: string }
|
||||
@@ -194,6 +195,8 @@ export type WebviewToExtension
|
||||
| { type: 'pr-file-diff/get', issueNumber: number, path: string, previousPath?: string }
|
||||
| { type: 'pr-file-summary/generate', issueNumber: number, path: string, previousPath?: string }
|
||||
| { type: 'pr-review/set', issueNumber: number, confirmed: Record<string, string> }
|
||||
| { type: 'pr-diff-mode/get' }
|
||||
| { type: 'pr-diff-mode/set', mode: 'unified' | 'split' }
|
||||
// profile 值编辑器:图片存盘(base64→磁盘)与读盘(磁盘→dataUrl)请求。
|
||||
| { type: 'profile-asset/save', requestId: string, base64: string, mediaType: string }
|
||||
| { type: 'profile-asset/load', requestId: string, assetPath: string }
|
||||
|
||||
Reference in New Issue
Block a user