✨ feat(vscode): 工具栏发布按钮与下拉菜单
Claude-Session: https://claude.ai/code/session_01HTMgwaE3woqM5yvsHiuSAa
This commit is contained in:
1 parent
b363e08ef9
commit
d04048148a
6 files changed
+120
-121
No files matched your search
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
import type { ToastItem } from '../components/ToastStack'
|
||||
import type { LogEntry } from '../lib/messages'
|
||||
import type { ExtensionToWebview, LogEntry } from '../lib/messages'
|
||||
import type { Issue, IssueColumn } from '../types'
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { compareIssuesInColumn } from '../lib/issueSort'
|
||||
@@ -126,6 +126,9 @@ export interface ClaudeProfile {
|
||||
path: string
|
||||
}
|
||||
|
||||
export type ReleaseStatus = Extract<ExtensionToWebview, { type: 'release/status' }>
|
||||
export type ReleaseAction = 'cut' | 'cherry-pick' | 'deploy'
|
||||
|
||||
export interface UseIssuesResult {
|
||||
state: UseIssuesState
|
||||
settings: SettingsOverlayState | null
|
||||
@@ -239,29 +242,10 @@ export interface UseIssuesResult {
|
||||
* extension reports its first observation.
|
||||
*/
|
||||
hasChanges: boolean
|
||||
/**
|
||||
* Commits the remote auto-build branch is behind the remote dev branch
|
||||
* (per latest `branch-sync/status`). 0 ⇒ in sync ⇒ disable button.
|
||||
*/
|
||||
branchSyncBehind: number
|
||||
/**
|
||||
* True while a `branch-sync/run` request is in flight. The extension
|
||||
* doesn't echo a "running" state itself — we set this on click and clear
|
||||
* it when the next `branch-sync/status` arrives.
|
||||
*/
|
||||
branchSyncRunning: boolean
|
||||
/**
|
||||
* True when sync is structurally unavailable (same branch, missing
|
||||
* remote, fetch error, …). Disables the button regardless of behind.
|
||||
*/
|
||||
branchSyncDisabled: boolean
|
||||
/**
|
||||
* Tooltip text for the sync button (already includes branch names /
|
||||
* behind count / unavailable reason).
|
||||
*/
|
||||
branchSyncTitle: string
|
||||
/** Trigger a fast-forward push from remote dev to remote auto-build. */
|
||||
runBranchSync: () => void
|
||||
/** 最近一次 `release/status`;首次消息到达前为 undefined(按钮显示「正在检查」并禁用)。 */
|
||||
release: ReleaseStatus | undefined
|
||||
/** 发布按钮三个动作;running 由扩展侧状态决定,webview 不自置。 */
|
||||
runRelease: (action: ReleaseAction) => void
|
||||
/**
|
||||
* Whether the workspace's `.env*` files are currently chmod-locked
|
||||
* according to `workspaceState`. Persisted per-workspace.
|
||||
@@ -316,10 +300,7 @@ export function useIssues(): UseIssuesResult {
|
||||
const [pendingSelectId, setPendingSelectId] = useState<string | null>(null)
|
||||
const [commitRunning, setCommitRunning] = useState<boolean>(false)
|
||||
const [hasChanges, setHasChanges] = useState<boolean>(false)
|
||||
const [branchSyncBehind, setBranchSyncBehind] = useState<number>(0)
|
||||
const [branchSyncRunning, setBranchSyncRunning] = useState<boolean>(false)
|
||||
const [branchSyncDisabled, setBranchSyncDisabled] = useState<boolean>(true)
|
||||
const [branchSyncTitle, setBranchSyncTitle] = useState<string>('正在检查分支同步状态…')
|
||||
const [release, setRelease] = useState<ReleaseStatus>()
|
||||
const [envLocked, setEnvLocked] = useState<boolean>(false)
|
||||
const [envFileCount, setEnvFileCount] = useState<number>(0)
|
||||
const [envLockRunning, setEnvLockRunning] = useState<boolean>(false)
|
||||
@@ -350,9 +331,8 @@ export function useIssues(): UseIssuesResult {
|
||||
const refresh = useCallback((): void => {
|
||||
setState({ status: 'loading' })
|
||||
postMessage({ type: 'issues/refresh' })
|
||||
// Re-poll branch-sync state on user refresh — branches may have moved
|
||||
// on the remote since the last check.
|
||||
postMessage({ type: 'branch-sync/check' })
|
||||
// 用户刷新时重查发布状态:远端分支可能已经动了。
|
||||
postMessage({ type: 'release/check' })
|
||||
// Re-poll env-lock state so newly added .env files surface in the count.
|
||||
postMessage({ type: 'env-lock/check' })
|
||||
}, [])
|
||||
@@ -637,14 +617,9 @@ export function useIssues(): UseIssuesResult {
|
||||
postMessage({ type: 'commit/run' })
|
||||
}, [commitRunning])
|
||||
|
||||
const runBranchSync = useCallback((): void => {
|
||||
// Double-click guard. The next `branch-sync/status` message clears the
|
||||
// running flag — both on success and on failure.
|
||||
if (branchSyncRunning)
|
||||
return
|
||||
setBranchSyncRunning(true)
|
||||
postMessage({ type: 'branch-sync/run' })
|
||||
}, [branchSyncRunning])
|
||||
const runRelease = useCallback((action: ReleaseAction): void => {
|
||||
postMessage({ type: `release/${action}` })
|
||||
}, [])
|
||||
|
||||
const toggleEnvLock = useCallback((): void => {
|
||||
// Double-click guard — the next `env-lock/status` clears the running flag.
|
||||
@@ -832,27 +807,9 @@ export function useIssues(): UseIssuesResult {
|
||||
case 'commit/has-changes':
|
||||
setHasChanges(msg.value)
|
||||
break
|
||||
case 'branch-sync/status': {
|
||||
setBranchSyncBehind(msg.behind)
|
||||
setBranchSyncRunning(false)
|
||||
// Title + disabled derive purely from the status payload, so we
|
||||
// resolve them here once instead of recomputing in each render.
|
||||
if (msg.unavailable) {
|
||||
setBranchSyncDisabled(true)
|
||||
setBranchSyncTitle(msg.reason ?? '分支同步不可用')
|
||||
}
|
||||
else if (msg.behind <= 0) {
|
||||
setBranchSyncDisabled(true)
|
||||
setBranchSyncTitle(`${msg.devBranch} → ${msg.autoBuildBranch} 已同步`)
|
||||
}
|
||||
else {
|
||||
setBranchSyncDisabled(false)
|
||||
setBranchSyncTitle(
|
||||
`同步 ${msg.devBranch} → ${msg.autoBuildBranch}(落后 ${msg.behind} 个提交)`,
|
||||
)
|
||||
}
|
||||
case 'release/status':
|
||||
setRelease(msg)
|
||||
break
|
||||
}
|
||||
case 'env-lock/status': {
|
||||
setEnvLocked(msg.locked)
|
||||
setEnvFileCount(msg.fileCount)
|
||||
@@ -876,10 +833,10 @@ export function useIssues(): UseIssuesResult {
|
||||
postMessage({ type: 'issues/refresh' })
|
||||
postMessage({ type: 'profiles/list' })
|
||||
postMessage({ type: 'logs/fetch' })
|
||||
postMessage({ type: 'branch-sync/check' })
|
||||
postMessage({ type: 'release/check' })
|
||||
postMessage({ type: 'env-lock/check' })
|
||||
return cleanup
|
||||
}, [clearPrDiffSummaryRunning, markHandoffRunning])
|
||||
|
||||
return { state, settings, globalAutoReview, youtrackConfigured, importYouTrack, toasts, profiles, setIssues, refresh, scope, toggleScope, saveSettings, listYouTrackProjects, youtrackProjects, dismissSettings, requestEditAuth, createIssue, dismissToast, openUrl, resumeSession, resumeReviewSession, startTestSession, resumeTestSession, focusSession, openFile, implement, generatePrDiffSummary, isPrDiffSummaryRunning, openPr, openWorktree, deleteWorktree, mergeBranch, deleteIssue, closeIssue, closeSessionTab, startBrainstormSession, changeColumn, setDependency, clearDependency, updateIssueAutoReview, updateIssueProfilePath, updateIssueBrainstormProfilePath, updateIssueTestProfilePath, logs, fetchLogs, clearLogs, pendingSelectId, clearPendingSelect, commitRunning, runCommit, hasChanges, branchSyncBehind, branchSyncRunning, branchSyncDisabled, branchSyncTitle, runBranchSync, envLocked, envFileCount, envLockRunning, envLockTitle, toggleEnvLock, me, handoffUsers, requestHandoffUsers, startHandoff, acceptHandoff, isHandoffRunning }
|
||||
return { state, settings, globalAutoReview, youtrackConfigured, importYouTrack, toasts, profiles, setIssues, refresh, scope, toggleScope, saveSettings, listYouTrackProjects, youtrackProjects, dismissSettings, requestEditAuth, createIssue, dismissToast, openUrl, resumeSession, resumeReviewSession, startTestSession, resumeTestSession, focusSession, openFile, implement, generatePrDiffSummary, isPrDiffSummaryRunning, openPr, openWorktree, deleteWorktree, mergeBranch, deleteIssue, closeIssue, closeSessionTab, startBrainstormSession, changeColumn, setDependency, clearDependency, updateIssueAutoReview, updateIssueProfilePath, updateIssueBrainstormProfilePath, updateIssueTestProfilePath, logs, fetchLogs, clearLogs, pendingSelectId, clearPendingSelect, commitRunning, runCommit, hasChanges, release, runRelease, envLocked, envFileCount, envLockRunning, envLockTitle, toggleEnvLock, me, handoffUsers, requestHandoffUsers, startHandoff, acceptHandoff, isHandoffRunning }
|
||||
}
|
||||
Reference in new issue
Block a user