@youdie006/prodex 0.16.9 → 0.16.11
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.
- package/dist/chatgpt-browser.js +24 -2
- package/package.json +1 -1
package/dist/chatgpt-browser.js
CHANGED
|
@@ -1103,7 +1103,21 @@ async function selectProject(cdp, options) {
|
|
|
1103
1103
|
if (!options.project)
|
|
1104
1104
|
return;
|
|
1105
1105
|
const hrefBefore = await cdp.evaluate("location.href");
|
|
1106
|
-
|
|
1106
|
+
// Poll for the project row instead of a single check: right after a
|
|
1107
|
+
// --new-chat navigation the sidebar's Projects section has not hydrated yet
|
|
1108
|
+
// (measured live: "0 projects visible" on the first read, rows appear
|
|
1109
|
+
// moments later) - the same class of race as the model-selector button
|
|
1110
|
+
// after new-chat (0.15.7).
|
|
1111
|
+
let hit = { ok: false };
|
|
1112
|
+
const projectDeadline = Date.now() + 6_000;
|
|
1113
|
+
for (;;) {
|
|
1114
|
+
hit = await cdp.evaluate(projectItemRectExpression(options.project));
|
|
1115
|
+
if (hit.ok && hit.x !== undefined && hit.y !== undefined)
|
|
1116
|
+
break;
|
|
1117
|
+
if (Date.now() >= projectDeadline)
|
|
1118
|
+
break;
|
|
1119
|
+
await sleep(300);
|
|
1120
|
+
}
|
|
1107
1121
|
if (!hit.ok || hit.x === undefined || hit.y === undefined) {
|
|
1108
1122
|
const detail = hit.reason && hit.reason !== "project not found in sidebar" ? ` (${hit.reason})` : "";
|
|
1109
1123
|
throw new Error(`ChatGPT project not found in sidebar: ${options.project}${detail}`);
|
|
@@ -1164,12 +1178,20 @@ export async function sendChatGptPrompt(options) {
|
|
|
1164
1178
|
assertChatGptPageAvailable();
|
|
1165
1179
|
}
|
|
1166
1180
|
const page = pageResult.page;
|
|
1167
|
-
if (options.newChat) {
|
|
1181
|
+
if (options.newChat && !options.project && !options.projectNew) {
|
|
1168
1182
|
// Long accumulated threads eventually break acceptance detection, so
|
|
1169
1183
|
// start from a clean chat. Wait for the tab to actually reach the fresh
|
|
1170
1184
|
// empty chat (root URL, zero messages) rather than a fixed sleep: a slow
|
|
1171
1185
|
// SPA navigation could otherwise leave the old thread rendered, poisoning
|
|
1172
1186
|
// the answer-count baseline captured below and causing a false timeout.
|
|
1187
|
+
//
|
|
1188
|
+
// Skipped when a project is requested: the project home the selection step
|
|
1189
|
+
// navigates to IS the fresh composer for "a new chat in this project".
|
|
1190
|
+
// Navigating to the root new chat first leaves the SPA composer bound to
|
|
1191
|
+
// the ROOT conversation target even after entering the project, so the
|
|
1192
|
+
// thread silently lands outside the project (measured live: --new-chat
|
|
1193
|
+
// --project threads appeared in the root chat list, --project-only
|
|
1194
|
+
// threads appeared inside the project).
|
|
1173
1195
|
await evaluateOnPage(page, `location.assign("https://chatgpt.com/")`);
|
|
1174
1196
|
await waitForFreshChatGptPage(page, 8_000);
|
|
1175
1197
|
}
|