mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-12-04 00:15:41 -08:00
Sync upstream v3.2.4: slim install refs, a crash-safe installer, Change project restarts the agent (v3.2.4)
AI Assisted
This commit is contained in:
1 parent
50319aa332
commit
f997a82c4d
45 files changed
+7851
-306
No files matched your search
+36
-4
@@ -2101,7 +2101,7 @@ function afterProjectKnown() {
|
||||
// tears the old project's agent and console down before the new one is
|
||||
// remembered, so nothing from it carries over. Cancel (or Escape) leaves
|
||||
// the current project as it was; the folder already open is not listed.
|
||||
async function doChangeProject() {
|
||||
async function doChangeProject(prior = null) {
|
||||
try {
|
||||
const dir = await showFolderPicker({ dialog: true });
|
||||
if (!dir) {
|
||||
@@ -2117,13 +2117,45 @@ async function doChangeProject() {
|
||||
restarting = false;
|
||||
currentUrl = null;
|
||||
frameReady = false;
|
||||
afterProjectKnown();
|
||||
// An agent was in use: start the same one (agent, model, effort and
|
||||
// permission mode) in the new folder, rather than leaving the launch card
|
||||
// and an empty terminal. Nothing to carry over: the launch card as before.
|
||||
if (prior) await startPriorAgent(prior);
|
||||
else afterProjectKnown();
|
||||
} catch (error) {
|
||||
showErrorState(error, 'switch project', 'Try again', doChangeProject);
|
||||
showErrorState(error, 'switch project', 'Try again', () => doChangeProject(prior));
|
||||
}
|
||||
}
|
||||
|
||||
// What the agent in use was started with, kept before a project switch tears
|
||||
// it down: null when none was started (a bare start), or its kind is unknown.
|
||||
function priorAgentSettings() {
|
||||
if (!agent.kind || (agent.state !== 'running' && agent.state !== 'ended')) return null;
|
||||
return {
|
||||
kind: agent.kind,
|
||||
model: agent.model || null,
|
||||
effort: agent.effort || null,
|
||||
mode: agent.mode === 'bypass' ? 'bypass' : 'checked',
|
||||
};
|
||||
}
|
||||
|
||||
async function startPriorAgent({ kind, model, effort, mode }) {
|
||||
launchAgentEl.value = kind;
|
||||
setAgentStatus('');
|
||||
beginWait('Starting the agent in the new project...');
|
||||
const { cols, rows } = terminal.size();
|
||||
try {
|
||||
await invoke('agent_start', { kind, model, effort, mode, cols, rows });
|
||||
terminal.focus();
|
||||
} catch (error) {
|
||||
endWait();
|
||||
setAgentError(error, 'start the agent');
|
||||
showLaunchCard();
|
||||
}
|
||||
}
|
||||
|
||||
async function changeProject() {
|
||||
const prior = priorAgentSettings();
|
||||
if (agentActive()) {
|
||||
const yes = await confirmModal({
|
||||
title: 'Stop the running agent and switch to a different project?',
|
||||
@@ -2133,7 +2165,7 @@ async function changeProject() {
|
||||
});
|
||||
if (!yes) return;
|
||||
}
|
||||
doChangeProject();
|
||||
doChangeProject(prior);
|
||||
}
|
||||
|
||||
changeProjectBtn.onclick = () => {
|
||||
|
||||
Reference in new issue
Block a user