JacobLinCool Codex commited on
Commit
a685195
·
verified ·
1 Parent(s): 92ccffa

fix: preserve draft idea before command actions

Browse files

Co-authored-by: Codex <noreply@openai.com>

Files changed (1) hide show
  1. static/app.js +14 -1
static/app.js CHANGED
@@ -68,7 +68,7 @@ document.querySelectorAll(".mobile-nav [data-tab]").forEach((button) => {
68
 
69
  document.querySelectorAll("[data-command]").forEach((button) => {
70
  button.addEventListener("click", async () => {
71
- await runTurn(button.dataset.command);
72
  });
73
  });
74
 
@@ -144,6 +144,7 @@ async function runTurn(message) {
144
  delete session.ui_status;
145
  startTurnWatchdog();
146
 
 
147
  try {
148
  const client = await clientPromise;
149
  const submission = client.submit("/agent_turn", {
@@ -158,6 +159,7 @@ async function runTurn(message) {
158
  handleEvent(JSON.parse(raw));
159
  }
160
  }
 
161
  } catch (error) {
162
  clearTurnWatchdog();
163
  ink.textContent = `The page tore before it could answer: ${error.message}`;
@@ -170,6 +172,17 @@ async function runTurn(message) {
170
  setSessionControlsDisabled(false);
171
  input.focus();
172
  }
 
 
 
 
 
 
 
 
 
 
 
173
  }
174
 
175
  async function bootstrap() {
 
68
 
69
  document.querySelectorAll("[data-command]").forEach((button) => {
70
  button.addEventListener("click", async () => {
71
+ await runCommand(button.dataset.command || "");
72
  });
73
  });
74
 
 
144
  delete session.ui_status;
145
  startTurnWatchdog();
146
 
147
+ let completed = false;
148
  try {
149
  const client = await clientPromise;
150
  const submission = client.submit("/agent_turn", {
 
159
  handleEvent(JSON.parse(raw));
160
  }
161
  }
162
+ completed = true;
163
  } catch (error) {
164
  clearTurnWatchdog();
165
  ink.textContent = `The page tore before it could answer: ${error.message}`;
 
172
  setSessionControlsDisabled(false);
173
  input.focus();
174
  }
175
+ return completed;
176
+ }
177
+
178
+ async function runCommand(command) {
179
+ if (!command) return;
180
+ const draft = input.value.trim();
181
+ if (draft) {
182
+ const savedDraft = await runTurn(draft);
183
+ if (!savedDraft) return;
184
+ }
185
+ await runTurn(command);
186
  }
187
 
188
  async function bootstrap() {