@youdie006/prodex 0.16.23 → 0.16.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1244,6 +1244,20 @@ async function selectProject(cdp, options) {
1244
1244
  throw new Error(`Clicking project "${options.project}" did not navigate the visible tab. If the tab is already inside this project, omit --project and retry.`);
1245
1245
  }
1246
1246
  }
1247
+ if (navigated) {
1248
+ // A sidebar SPA navigation moves the URL to the target project while the
1249
+ // composer can stay bound to the PREVIOUS project's conversation target, so
1250
+ // the send silently creates the thread in the OLD project (reproduced live
1251
+ // via PRODEX_DEBUG_SEND: baseline URL on the requested project, yet the
1252
+ // prompt posted into the project the tab came from). A hard reload of the
1253
+ // project home rebinds the composer to THIS project before we send.
1254
+ const projectHome = await cdp.evaluate("location.href");
1255
+ await cdp.evaluate("location.reload()");
1256
+ const rebound = await waitForExpressionTrue(cdp, `location.href === ${JSON.stringify(projectHome)} && Boolean(document.querySelector('#prompt-textarea,[contenteditable="true"],textarea'))`, PROJECT_NAVIGATION_TIMEOUT_MS);
1257
+ if (!rebound) {
1258
+ throw new Error(`ChatGPT composer did not rebind after entering project "${options.project}"`);
1259
+ }
1260
+ }
1247
1261
  const composerReady = await waitForExpressionTrue(cdp, `Boolean(document.querySelector('#prompt-textarea,[contenteditable="true"],textarea'))`, PROJECT_NAVIGATION_TIMEOUT_MS);
1248
1262
  if (!composerReady) {
1249
1263
  throw new Error(`ChatGPT composer did not appear after entering project "${options.project}"`);
@@ -1362,6 +1376,15 @@ export async function sendChatGptPrompt(options) {
1362
1376
  beforeSubmit = await evaluateOnPage(page, answerExpression());
1363
1377
  dbgSend(`baseline url=${beforeSubmit.url} user=${beforeSubmit.userMessageCount} assistant=${beforeSubmit.assistantMessageCount}`);
1364
1378
  await insertComposerTextViaCdp(cdp, options.prompt);
1379
+ // The send button renders asynchronously after the prompt lands. Poll for it
1380
+ // BEFORE submitting so (a) submitButtonFound reflects whether the control
1381
+ // actually EXISTS - otherwise a successful Enter-key submit skips the fallback
1382
+ // loop below, leaves submitButtonFound false, and a slow/undetected answer
1383
+ // gets mislabeled "ChatGPT web UI may have changed, update prodex" (measured
1384
+ // live: submitExpression finds data-testid="send-button" fine, yet the
1385
+ // timeout error blamed a UI change) - and (b) we never press Enter before the
1386
+ // composer is submit-ready.
1387
+ submitButtonFound = await waitForExpressionTrue(cdp, `(${submitExpression()}).ok === true`, 3_000);
1365
1388
  // Submit. Prefer the Enter key: it goes to the focused composer and does
1366
1389
  // not depend on coordinates, whereas the send button moves ~100px as the
1367
1390
  // composer grows after the prompt lands, so a click at captured coordinates
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@youdie006/prodex",
3
- "version": "0.16.23",
3
+ "version": "0.16.25",
4
4
  "description": "Local receipt bus for coordinating Codex execution with ChatGPT Pro/Projects consultation.",
5
5
  "author": "youdie006",
6
6
  "license": "MIT",