修复lint问题和错误
This commit is contained in:
@@ -645,40 +645,40 @@ function FolderLayoutInner({ children }: { children: React.ReactNode }) {
|
||||
<AlertProvider>
|
||||
<GitCredentialProvider>
|
||||
<TaskProvider>
|
||||
<AcpConnectionsProvider>
|
||||
<ConversationRuntimeProvider>
|
||||
<WorkspaceProvider key={`workspace-${normalizedFolderId}`}>
|
||||
<TabProvider>
|
||||
<SessionStatsProvider>
|
||||
<SidebarProvider
|
||||
key={`left-sidebar-${normalizedFolderId}`}
|
||||
folderId={normalizedFolderId}
|
||||
>
|
||||
<AuxPanelProvider
|
||||
key={`right-sidebar-${normalizedFolderId}`}
|
||||
<AcpConnectionsProvider>
|
||||
<ConversationRuntimeProvider>
|
||||
<WorkspaceProvider key={`workspace-${normalizedFolderId}`}>
|
||||
<TabProvider>
|
||||
<SessionStatsProvider>
|
||||
<SidebarProvider
|
||||
key={`left-sidebar-${normalizedFolderId}`}
|
||||
folderId={normalizedFolderId}
|
||||
>
|
||||
<TerminalProvider>
|
||||
<div className="flex h-screen flex-col overflow-hidden">
|
||||
<FolderTitleBar />
|
||||
<FolderWorkspaceShell>
|
||||
{children}
|
||||
</FolderWorkspaceShell>
|
||||
<StatusBar />
|
||||
<AppToaster
|
||||
position="bottom-right"
|
||||
duration={TOAST_DURATION_MS}
|
||||
closeButton
|
||||
/>
|
||||
</div>
|
||||
</TerminalProvider>
|
||||
</AuxPanelProvider>
|
||||
</SidebarProvider>
|
||||
</SessionStatsProvider>
|
||||
</TabProvider>
|
||||
</WorkspaceProvider>
|
||||
</ConversationRuntimeProvider>
|
||||
</AcpConnectionsProvider>
|
||||
<AuxPanelProvider
|
||||
key={`right-sidebar-${normalizedFolderId}`}
|
||||
folderId={normalizedFolderId}
|
||||
>
|
||||
<TerminalProvider>
|
||||
<div className="flex h-screen flex-col overflow-hidden">
|
||||
<FolderTitleBar />
|
||||
<FolderWorkspaceShell>
|
||||
{children}
|
||||
</FolderWorkspaceShell>
|
||||
<StatusBar />
|
||||
<AppToaster
|
||||
position="bottom-right"
|
||||
duration={TOAST_DURATION_MS}
|
||||
closeButton
|
||||
/>
|
||||
</div>
|
||||
</TerminalProvider>
|
||||
</AuxPanelProvider>
|
||||
</SidebarProvider>
|
||||
</SessionStatsProvider>
|
||||
</TabProvider>
|
||||
</WorkspaceProvider>
|
||||
</ConversationRuntimeProvider>
|
||||
</AcpConnectionsProvider>
|
||||
</TaskProvider>
|
||||
</GitCredentialProvider>
|
||||
</AlertProvider>
|
||||
|
||||
@@ -698,10 +698,9 @@ export function BranchDropdown({
|
||||
runGitTask(
|
||||
t("tasks.pullCode"),
|
||||
() =>
|
||||
withCredentialRetry(
|
||||
(creds) => gitPull(folderPath, creds),
|
||||
{ folderPath }
|
||||
),
|
||||
withCredentialRetry((creds) => gitPull(folderPath, creds), {
|
||||
folderPath,
|
||||
}),
|
||||
(result) => {
|
||||
if (result.conflict?.has_conflicts) {
|
||||
setConflictInfo(result.conflict)
|
||||
@@ -724,10 +723,9 @@ export function BranchDropdown({
|
||||
disabled={loading}
|
||||
onSelect={() =>
|
||||
runGitTask(t("tasks.fetchInfo"), () =>
|
||||
withCredentialRetry(
|
||||
(creds) => gitFetch(folderPath, creds),
|
||||
{ folderPath }
|
||||
)
|
||||
withCredentialRetry((creds) => gitFetch(folderPath, creds), {
|
||||
folderPath,
|
||||
})
|
||||
)
|
||||
}
|
||||
>
|
||||
|
||||
@@ -83,7 +83,15 @@ export function AddGitAccountDialog({
|
||||
|
||||
onAccountAdded(account)
|
||||
handleOpenChange(false)
|
||||
}, [serverUrl, username, password, isFirstAccount, onAccountAdded, handleOpenChange, t])
|
||||
}, [
|
||||
serverUrl,
|
||||
username,
|
||||
password,
|
||||
isFirstAccount,
|
||||
onAccountAdded,
|
||||
handleOpenChange,
|
||||
t,
|
||||
])
|
||||
|
||||
const canSubmit =
|
||||
serverUrl.trim().length > 0 &&
|
||||
|
||||
@@ -186,10 +186,7 @@ export function AddGitHubAccountDialog({
|
||||
</div>
|
||||
|
||||
<DialogFooter>
|
||||
<Button
|
||||
onClick={handleSubmit}
|
||||
disabled={validating || !token.trim()}
|
||||
>
|
||||
<Button onClick={handleSubmit} disabled={validating || !token.trim()}>
|
||||
{validating ? (
|
||||
<>
|
||||
<Loader2 className="h-3.5 w-3.5 animate-spin" />
|
||||
|
||||
@@ -205,7 +205,9 @@ export function VersionControlSettings() {
|
||||
if (trimmed) {
|
||||
const result = await testGitPath(trimmed)
|
||||
if (!result.installed) {
|
||||
toast.error(t("testFailed", { message: "not a valid git executable" }))
|
||||
toast.error(
|
||||
t("testFailed", { message: "not a valid git executable" })
|
||||
)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -415,11 +417,7 @@ export function VersionControlSettings() {
|
||||
>
|
||||
{t("removeCancel")}
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={handleSaveGit}
|
||||
disabled={savingGit}
|
||||
>
|
||||
<Button size="sm" onClick={handleSaveGit} disabled={savingGit}>
|
||||
{savingGit ? (
|
||||
<Loader2 className="h-3.5 w-3.5 animate-spin" />
|
||||
) : (
|
||||
|
||||
@@ -4,11 +4,19 @@ import {
|
||||
createContext,
|
||||
useCallback,
|
||||
useContext,
|
||||
useEffect,
|
||||
useRef,
|
||||
useState,
|
||||
type ReactNode,
|
||||
} from "react"
|
||||
import { ExternalLink, Eye, EyeOff, Github, KeyRound, Loader2 } from "lucide-react"
|
||||
import {
|
||||
ExternalLink,
|
||||
Eye,
|
||||
EyeOff,
|
||||
Github,
|
||||
KeyRound,
|
||||
Loader2,
|
||||
} from "lucide-react"
|
||||
import { openUrl } from "@tauri-apps/plugin-opener"
|
||||
import { useTranslations } from "next-intl"
|
||||
import { Button } from "@/components/ui/button"
|
||||
@@ -39,9 +47,7 @@ import {
|
||||
* - `folderPath`: detect remote from an existing repo's origin URL.
|
||||
* - `remoteUrl`: use this URL directly (e.g. for clone operations).
|
||||
*/
|
||||
export type GitRemoteHint =
|
||||
| { folderPath: string }
|
||||
| { remoteUrl: string }
|
||||
export type GitRemoteHint = { folderPath: string } | { remoteUrl: string }
|
||||
|
||||
interface GitCredentialContextValue {
|
||||
/**
|
||||
@@ -57,8 +63,9 @@ interface GitCredentialContextValue {
|
||||
) => Promise<T>
|
||||
}
|
||||
|
||||
const GitCredentialContext =
|
||||
createContext<GitCredentialContextValue | null>(null)
|
||||
const GitCredentialContext = createContext<GitCredentialContextValue | null>(
|
||||
null
|
||||
)
|
||||
|
||||
export function useGitCredential(): GitCredentialContextValue {
|
||||
const ctx = useContext(GitCredentialContext)
|
||||
@@ -136,9 +143,7 @@ async function saveGenericAccount(
|
||||
try {
|
||||
const existing = await getGitHubAccounts()
|
||||
const isDuplicate = existing.accounts.some(
|
||||
(a) =>
|
||||
a.username === creds.username &&
|
||||
extractHost(a.server_url) === host
|
||||
(a) => a.username === creds.username && extractHost(a.server_url) === host
|
||||
)
|
||||
if (!isDuplicate) {
|
||||
await updateGitHubAccounts({
|
||||
@@ -162,11 +167,7 @@ async function saveGenericAccount(
|
||||
}
|
||||
}
|
||||
|
||||
export function GitCredentialProvider({
|
||||
children,
|
||||
}: {
|
||||
children: ReactNode
|
||||
}) {
|
||||
export function GitCredentialProvider({ children }: { children: ReactNode }) {
|
||||
const t = useTranslations("GitCredentialDialog")
|
||||
|
||||
const [open, setOpen] = useState(false)
|
||||
@@ -204,11 +205,18 @@ export function GitCredentialProvider({
|
||||
|
||||
const pendingRef = useRef<PendingRequest | null>(null)
|
||||
const saveCredentialsRef = useRef(saveCredentials)
|
||||
saveCredentialsRef.current = saveCredentials
|
||||
const remoteHostRef = useRef(remoteHost)
|
||||
remoteHostRef.current = remoteHost
|
||||
const modeRef = useRef(mode)
|
||||
modeRef.current = mode
|
||||
|
||||
useEffect(() => {
|
||||
saveCredentialsRef.current = saveCredentials
|
||||
}, [saveCredentials])
|
||||
useEffect(() => {
|
||||
remoteHostRef.current = remoteHost
|
||||
}, [remoteHost])
|
||||
useEffect(() => {
|
||||
modeRef.current = mode
|
||||
}, [mode])
|
||||
|
||||
const resetForm = useCallback(() => {
|
||||
setUsername("")
|
||||
@@ -222,7 +230,10 @@ export function GitCredentialProvider({
|
||||
}, [])
|
||||
|
||||
const requestCredentials = useCallback(
|
||||
(dialogMode: DialogMode, host: string | null): Promise<GitCredentials | null> => {
|
||||
(
|
||||
dialogMode: DialogMode,
|
||||
host: string | null
|
||||
): Promise<GitCredentials | null> => {
|
||||
return new Promise((resolve) => {
|
||||
pendingRef.current = { resolve }
|
||||
resetForm()
|
||||
@@ -333,9 +344,7 @@ export function GitCredentialProvider({
|
||||
|
||||
// Detect remote host to decide dialog mode
|
||||
const host = await resolveRemoteHost(hint)
|
||||
const dialogMode: DialogMode = isGitHubHost(host)
|
||||
? "github"
|
||||
: "generic"
|
||||
const dialogMode: DialogMode = isGitHubHost(host) ? "github" : "generic"
|
||||
|
||||
// Helper: save credentials after successful operation
|
||||
const maybeSave = async (c: GitCredentials) => {
|
||||
@@ -354,7 +363,7 @@ export function GitCredentialProvider({
|
||||
|
||||
// Retry loop — keep trying until success or user cancels
|
||||
let lastError: unknown = firstError
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
const result = await operation(creds)
|
||||
@@ -389,7 +398,8 @@ export function GitCredentialProvider({
|
||||
)
|
||||
|
||||
const canSubmitGitHub = token.trim().length > 0
|
||||
const canSubmitGeneric = username.trim().length > 0 && password.trim().length > 0
|
||||
const canSubmitGeneric =
|
||||
username.trim().length > 0 && password.trim().length > 0
|
||||
const canSubmit = mode === "github" ? canSubmitGitHub : canSubmitGeneric
|
||||
|
||||
return (
|
||||
|
||||
@@ -168,9 +168,7 @@ export function TabProvider({ children }: TabProviderProps) {
|
||||
}, [conversations])
|
||||
|
||||
// Callback set for preview tab replacement notifications
|
||||
const previewReplacedCallbacksRef = useRef(
|
||||
new Set<(tabId: string) => void>()
|
||||
)
|
||||
const previewReplacedCallbacksRef = useRef(new Set<(tabId: string) => void>())
|
||||
const onPreviewTabReplaced = useCallback(
|
||||
(callback: (tabId: string) => void) => {
|
||||
previewReplacedCallbacksRef.current.add(callback)
|
||||
|
||||
Reference in New Issue
Block a user