Spaces:
Running on Zero
Running on Zero
fix: restore project reference sessions
Browse filesCo-authored-by: Codex <noreply@openai.com>
- static/app.js +22 -2
static/app.js
CHANGED
|
@@ -419,6 +419,17 @@ function renderProvenance(data) {
|
|
| 419 |
}
|
| 420 |
|
| 421 |
function renderRestoredSession(data) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 422 |
const idea = currentIdea();
|
| 423 |
const storedArtifact = session.last_artifact || null;
|
| 424 |
currentArtifact = !idea || storedArtifact?.title === idea.title ? storedArtifact : null;
|
|
@@ -472,6 +483,7 @@ function normalizeSession(savedSession, defaultSession) {
|
|
| 472 |
if (savedSession.current_whitespace) normalized.current_whitespace = savedSession.current_whitespace;
|
| 473 |
if (savedSession.last_tool_resolution) normalized.last_tool_resolution = savedSession.last_tool_resolution;
|
| 474 |
if (savedSession.last_artifact) normalized.last_artifact = savedSession.last_artifact;
|
|
|
|
| 475 |
if (typeof savedSession.last_response === "string") normalized.last_response = savedSession.last_response;
|
| 476 |
if (typeof savedSession.ui_status === "string") normalized.ui_status = savedSession.ui_status;
|
| 477 |
return normalized;
|
|
@@ -599,8 +611,12 @@ function handleEvent(event) {
|
|
| 599 |
session.last_response = event.response || session.last_response || "";
|
| 600 |
delete session.ui_status;
|
| 601 |
const toolName = session.last_tool_resolution?.call?.name || "";
|
| 602 |
-
const projectReferenceOnly =
|
| 603 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 604 |
if (event.score?.echoes?.length) {
|
| 605 |
renderCitations(event.score.echoes);
|
| 606 |
} else if (event.projects?.length) {
|
|
@@ -643,6 +659,10 @@ function renderProjectReferenceState() {
|
|
| 643 |
renderWoodMap(null);
|
| 644 |
}
|
| 645 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 646 |
function renderIdeas(ideas) {
|
| 647 |
if (ideaCountEl) ideaCountEl.textContent = ideas.length;
|
| 648 |
ideasEl.innerHTML = "";
|
|
|
|
| 419 |
}
|
| 420 |
|
| 421 |
function renderRestoredSession(data) {
|
| 422 |
+
const restoredProjectReference = isProjectReferenceTool(session.last_tool_resolution?.call?.name || "");
|
| 423 |
+
if (restoredProjectReference) {
|
| 424 |
+
currentArtifact = null;
|
| 425 |
+
renderProjectReferenceState();
|
| 426 |
+
renderProjects(session.last_projects || [], "No project page matched this request.");
|
| 427 |
+
renderIdeas(session.ideas || []);
|
| 428 |
+
renderPlan(session.last_plan || []);
|
| 429 |
+
setCommandDisabled(false);
|
| 430 |
+
restoreSessionCopy();
|
| 431 |
+
return;
|
| 432 |
+
}
|
| 433 |
const idea = currentIdea();
|
| 434 |
const storedArtifact = session.last_artifact || null;
|
| 435 |
currentArtifact = !idea || storedArtifact?.title === idea.title ? storedArtifact : null;
|
|
|
|
| 483 |
if (savedSession.current_whitespace) normalized.current_whitespace = savedSession.current_whitespace;
|
| 484 |
if (savedSession.last_tool_resolution) normalized.last_tool_resolution = savedSession.last_tool_resolution;
|
| 485 |
if (savedSession.last_artifact) normalized.last_artifact = savedSession.last_artifact;
|
| 486 |
+
if (Array.isArray(savedSession.last_projects)) normalized.last_projects = savedSession.last_projects;
|
| 487 |
if (typeof savedSession.last_response === "string") normalized.last_response = savedSession.last_response;
|
| 488 |
if (typeof savedSession.ui_status === "string") normalized.ui_status = savedSession.ui_status;
|
| 489 |
return normalized;
|
|
|
|
| 611 |
session.last_response = event.response || session.last_response || "";
|
| 612 |
delete session.ui_status;
|
| 613 |
const toolName = session.last_tool_resolution?.call?.name || "";
|
| 614 |
+
const projectReferenceOnly = !event.score && !event.artifact?.title && isProjectReferenceTool(toolName);
|
| 615 |
+
if (projectReferenceOnly) {
|
| 616 |
+
session.last_projects = Array.isArray(event.projects) ? event.projects : [];
|
| 617 |
+
} else {
|
| 618 |
+
delete session.last_projects;
|
| 619 |
+
}
|
| 620 |
if (event.score?.echoes?.length) {
|
| 621 |
renderCitations(event.score.echoes);
|
| 622 |
} else if (event.projects?.length) {
|
|
|
|
| 659 |
renderWoodMap(null);
|
| 660 |
}
|
| 661 |
|
| 662 |
+
function isProjectReferenceTool(toolName) {
|
| 663 |
+
return ["list_projects", "get_project"].includes(toolName);
|
| 664 |
+
}
|
| 665 |
+
|
| 666 |
function renderIdeas(ideas) {
|
| 667 |
if (ideaCountEl) ideaCountEl.textContent = ideas.length;
|
| 668 |
ideasEl.innerHTML = "";
|