Files
superwork/vscode/src/panel/messages.ts
T

230 lines
11 KiB
TypeScript

import type { Issue, IssueColumn } from '../gitea/types'
import type { LogEntry } from '../logging/logger'
import type { ProfilesData } from '../profiles/store'
import type { ManagedSession } from '../sessions/managedStore'
export type { LogEntry } from '../logging/logger'
export type { ProfileRow, ProfilesData } from '../profiles/store'
/**
* `managed-sessions/show` 的 payload 类型:在持久化的 ManagedSession 基础上
* 附加 transient 字段 `tabOpen`(该会话的终端是否正开着)。
* `tabOpen` 只在构造 show payload 时附加,不写进 .spx/session-names.json。
*/
export interface ManagedSessionShowItem extends ManagedSession {
tabOpen?: boolean
}
export interface SessionHandoffPendingItem {
attachmentId: number
sid: string
from: string
to: string
name: string
}
export interface ManagedSessionsShowData {
sessions: ManagedSessionShowItem[]
}
/**
* PR 改动里的一个文件:status 取 added/modified/deleted/renamed/copied 等,
* additions/deletions 求和成统计条,previousFilename 在改名时给出旧路径。
*/
export interface PrFile {
path: string
status: string
additions: number
deletions: number
previousFilename?: string
}
export interface ToastLink {
label: string
url: string
}
export type ToastLevel = 'info' | 'success' | 'error'
export type ExtensionToWebview
= | { type: 'issues/loading' }
| { type: 'issues/update', issues: Issue[], scope: 'mine' | 'all', globalAutoReview: boolean, youtrackConfigured: boolean, me?: string }
| { type: 'issues/error', message: string }
| { type: 'issue/patch', issueNumber: number, patch: { autoReview?: boolean, specFile?: string, planFile?: string, prDiffFile?: string | null, sessionId?: string | null, implementSessionId?: string | null, reviewSessionId?: string | null, reviewSessionFileExists?: boolean, testSessionId?: string | null, pr?: string | null, implementStatus?: 'running' | 'done' | 'failed' | null, column?: IssueColumn, worktreePath?: string | null, prMerged?: boolean, prMergedAt?: string | null, branch?: string | null, color?: string, worktreeExists?: boolean, brainstormTabOpen?: boolean, implementTabOpen?: boolean, reviewTabOpen?: boolean, testTabOpen?: boolean, profilePath?: string | null, brainstormProfilePath?: string | null, testProfilePath?: string | null, assignees?: string[], handoffAttachmentId?: string | null, handoffFrom?: string | null } }
| { type: 'issue/pr-diff-summary-done', issueNumber: number }
| { type: 'handoff/users-result', issueNumber: number, users: string[] }
| { type: 'handoff/done', issueNumber: number }
| { type: 'session-handoff/users-result', users: string[] }
| { type: 'session-handoff/pending', items: SessionHandoffPendingItem[] }
| { type: 'session-handoff/done', sessionId: string }
| { type: 'issue/append', issue: Issue, select?: boolean }
| { type: 'issue/select-by-number', issueNumber: number }
| {
type: 'settings/show'
host: string
errorMessage?: string
canCancel?: boolean
tokenSaved: boolean
webhookPort: number
webhookSecret: string
brainstormPrompt: string
brainstormContinuePrompt: string
implementPlanPrompt: string
autoReview: boolean
reviewPrompt: string
devBranch: string
autoBuildBranch: string
worktreeDirectory: string
worktreeOpenWith: 'vscode' | 'pycharm'
pycharmCommand: string
worktreePostCreateScript: string
worktreePreRemoveScript: string
implTabPreCreateScript: string
implTabPostCloseScript: string
conflictResolutionProfilePath: string
commitProfilePath: string
prDiffSummaryProfilePath: string
codexModel: string
codexReasoningEffort: string
profilesDirectory: string
youtrackBaseUrl?: string
youtrackProjectShortName?: string
youtrackCloseCommand?: string
youtrackTokenSaved?: boolean
}
| { type: 'youtrack/projects', projects: Array<{ id: string, name: string, shortName: string }>, error?: string }
| {
type: 'toast/show'
id: string
level: ToastLevel
message: string
spinner?: boolean
link?: ToastLink
dismissOnTimer?: number
}
| { type: 'toast/dismiss', id: string }
| { type: 'profiles/update', profiles: Array<{ name: string, path: string }> }
| { type: 'logs/snapshot', entries: LogEntry[] }
| { type: 'logs/append', entry: LogEntry }
| { type: 'logs/cleared' }
| { type: 'commit/state', running: boolean }
| { type: 'commit/has-changes', value: boolean }
| {
type: 'branch-sync/status'
behind: number
devBranch: string
autoBuildBranch: string
unavailable?: boolean
reason?: string
}
| { type: 'env-lock/status', locked: boolean, fileCount: number, failedCount?: number }
| { type: 'issue/remove', issueNumber: number }
| { type: 'profiles/show', data: ProfilesData }
| { type: 'managed-sessions/show', data: ManagedSessionsShowData }
| { type: 'managed-sessions/importable', sessions: Array<{ id: string, name: string, mtimeMs: number }> }
| { 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 }
export type WebviewToExtension
= | { type: 'issues/refresh' }
| { type: 'issues/set-scope', scope: 'mine' | 'all' }
| {
type: 'settings/save'
host: string
token: string
webhookPort: number
webhookSecret: string
brainstormPrompt: string
brainstormContinuePrompt: string
implementPlanPrompt: string
autoReview: boolean
reviewPrompt: string
devBranch: string
autoBuildBranch: string
worktreeDirectory: string
worktreeOpenWith: 'vscode' | 'pycharm'
pycharmCommand: string
worktreePostCreateScript: string
worktreePreRemoveScript: string
implTabPreCreateScript: string
implTabPostCloseScript: string
conflictResolutionProfilePath: string
commitProfilePath: string
prDiffSummaryProfilePath: string
codexModel: string
codexReasoningEffort: string
profilesDirectory: string
youtrackBaseUrl: string
youtrackProjectShortName: string
youtrackCloseCommand: string
youtrackToken: string
}
| { type: 'settings/edit-request' }
| { type: 'youtrack/list-projects', baseUrl: string, token: string }
| { type: 'youtrack/import' }
| { type: 'issue/create', userRequest: string, images?: Array<{ mediaType: string, base64: string }>, brainstormProfilePath?: string }
| { type: 'toast/open-url', url: string }
| { type: 'session/resume', sessionId: string, profilePath?: string, cwd?: string, issueNumber?: number }
| { type: 'session/focus', issueNumber: number }
| { type: 'session/resume-review', sessionId: string, issueNumber: number, cwd?: string }
| { type: 'session/resume-test', sessionId: string, issueNumber: number, cwd?: string }
| { type: 'session/start-test', issueNumber: number }
| { type: 'editor/open-file', path: string }
| { type: 'profiles/list' }
| { type: 'issue/implement', issueNumber: number, planFile: string, profilePath?: string, sessionId?: string }
| { type: 'issue/generate-pr-diff-summary', issueNumber: number }
| { type: 'pr/open', pr: string }
| { type: 'worktree/open', path: string }
| { type: 'worktree/delete', issueNumber: number, path: string }
| { type: 'git/merge-preview', issueNumber: number, branch: string }
| { type: 'column/change', issueNumber: number, toColumn: IssueColumn, source?: 'gitea' | 'youtrack', externalId?: string }
| { type: 'handoff/users', issueNumber: number }
| { type: 'handoff/start', issueNumber: number, to: string }
| { type: 'handoff/accept', issueNumber: number }
| { type: 'session-handoff/users' }
| { type: 'session-handoff/start', sessionId: string, to: string }
| { type: 'session-handoff/accept', attachmentId: number }
| { type: 'session-handoff/refresh' }
| { type: 'dependency/set', issueNumber: number, prerequisiteNumber: number }
| { type: 'dependency/clear', issueNumber: number, prerequisiteNumber: number }
| { type: 'issue/update-auto-review', issueNumber: number, value: boolean }
| { type: 'issue/update-profile-path', issueNumber: number, profilePath: string }
| { type: 'issue/update-brainstorm-profile-path', issueNumber: number, brainstormProfilePath: string }
| { type: 'issue/update-test-profile-path', issueNumber: number, testProfilePath: string }
| { type: 'logs/fetch' }
| { type: 'logs/clear' }
| { type: 'commit/run' }
| { type: 'session/close-tab', issueNumber: number, kind: 'brainstorm' | 'implement' | 'review' | 'test' }
| { type: 'branch-sync/check' }
| { type: 'branch-sync/run' }
| { type: 'env-lock/check' }
| { type: 'env-lock/toggle' }
| { type: 'issue/delete', issueNumber: number }
| { type: 'issue/close', issueNumber: number }
| { type: 'brainstorm/start', issueNumber: number }
| { type: 'profiles/get' }
| { type: 'profiles/save', data: ProfilesData }
| { type: 'profiles/open', value: string }
| { type: 'managed-sessions/get' }
| { type: 'managed-sessions/create', profilePath: string, name?: string, prompt?: string }
| { type: 'managed-sessions/rename', sessionId: string, name: string }
| { type: 'managed-sessions/resume', sessionId: string, profilePath?: string }
| { type: 'managed-sessions/delete', sessionId: string }
| { type: 'managed-sessions/close-tab', sessionId: string }
| { type: 'managed-sessions/list-importable' }
| { type: 'managed-sessions/import', sessionId: string, name: string }
| { type: 'pr-files/get', issueNumber: number }
| { 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 }