mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-28 09:23:08 +08:00
feat: 添加会话关闭功能及确认对话框,更新相关国际化文本
This commit is contained in:
@@ -285,6 +285,13 @@ export const useSessionManagerStore = create<SessionManagerStore>()(
|
||||
shellKind: session.shellKind,
|
||||
};
|
||||
|
||||
// Map shellKind to preferredShell for API
|
||||
const mapShellKind = (kind: string): 'bash' | 'pwsh' | 'cmd' => {
|
||||
if (kind === 'pwsh' || kind === 'powershell') return 'pwsh';
|
||||
if (kind === 'cmd') return 'cmd';
|
||||
return 'bash'; // 'git-bash', 'wsl-bash', or fallback
|
||||
};
|
||||
|
||||
try {
|
||||
// Close existing session
|
||||
await closeCliSession(terminalId, projectPath ?? undefined);
|
||||
@@ -293,7 +300,7 @@ export const useSessionManagerStore = create<SessionManagerStore>()(
|
||||
const result = await createCliSession(
|
||||
{
|
||||
workingDir: sessionConfig.workingDir,
|
||||
preferredShell: sessionConfig.shellKind === 'powershell' ? 'pwsh' : 'bash',
|
||||
preferredShell: mapShellKind(sessionConfig.shellKind),
|
||||
tool: sessionConfig.tool,
|
||||
model: sessionConfig.model,
|
||||
resumeKey: sessionConfig.resumeKey,
|
||||
@@ -325,6 +332,35 @@ export const useSessionManagerStore = create<SessionManagerStore>()(
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
|
||||
closeSession: async (terminalId: string) => {
|
||||
const projectPath = selectProjectPath(useWorkflowStore.getState());
|
||||
const cliStore = useCliSessionStore.getState();
|
||||
|
||||
try {
|
||||
// Call backend API to terminate PTY session
|
||||
await closeCliSession(terminalId, projectPath ?? undefined);
|
||||
|
||||
// Remove session from cliSessionStore
|
||||
cliStore.removeSession(terminalId);
|
||||
|
||||
// Remove terminal meta
|
||||
set(
|
||||
(state) => {
|
||||
const nextMetas = { ...state.terminalMetas };
|
||||
delete nextMetas[terminalId];
|
||||
return { terminalMetas: nextMetas };
|
||||
},
|
||||
false,
|
||||
'closeSession'
|
||||
);
|
||||
} catch (error) {
|
||||
if (import.meta.env.DEV) {
|
||||
console.error('[SessionManager] closeSession error:', error);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
}),
|
||||
{ name: 'SessionManagerStore' }
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user