Spaces:
Running on Zero
Running on Zero
fix: clear stale build paths on idea changes
Browse filesCo-authored-by: Codex <noreply@openai.com>
- hackathon_advisor/agent.py +2 -0
- static/app.js +5 -2
- tests/test_agent.py +14 -0
hackathon_advisor/agent.py
CHANGED
|
@@ -419,6 +419,8 @@ class AdvisorEngine:
|
|
| 419 |
state["trace"] = trace[-12:]
|
| 420 |
if plan:
|
| 421 |
state["last_plan"] = list(plan)
|
|
|
|
|
|
|
| 422 |
if artifact:
|
| 423 |
state["last_artifact"] = artifact
|
| 424 |
|
|
|
|
| 419 |
state["trace"] = trace[-12:]
|
| 420 |
if plan:
|
| 421 |
state["last_plan"] = list(plan)
|
| 422 |
+
else:
|
| 423 |
+
state.pop("last_plan", None)
|
| 424 |
if artifact:
|
| 425 |
state["last_artifact"] = artifact
|
| 426 |
|
static/app.js
CHANGED
|
@@ -427,7 +427,8 @@ function renderRestoredSession(data) {
|
|
| 427 |
renderProjectReferenceState();
|
| 428 |
renderProjects(session.last_projects || [], "No project page matched this request.");
|
| 429 |
renderIdeas(session.ideas || []);
|
| 430 |
-
|
|
|
|
| 431 |
setCommandDisabled(false);
|
| 432 |
restoreSessionCopy();
|
| 433 |
return;
|
|
@@ -713,6 +714,7 @@ function selectIdea(ideaId) {
|
|
| 713 |
if (!ideaId || !Array.isArray(session.ideas)) return;
|
| 714 |
const idea = session.ideas.find((item) => item.id === ideaId);
|
| 715 |
if (!idea) return;
|
|
|
|
| 716 |
bumpSessionRevision();
|
| 717 |
session.current_idea_id = idea.id;
|
| 718 |
if (Array.isArray(idea.goals) && idea.goals.length) {
|
|
@@ -722,7 +724,8 @@ function selectIdea(ideaId) {
|
|
| 722 |
renderSelectedIdeaArtifact(idea);
|
| 723 |
renderGoals(session.goals || []);
|
| 724 |
renderIdeas(session.ideas);
|
| 725 |
-
|
|
|
|
| 726 |
session.ui_status = `selected: ${idea.title}`;
|
| 727 |
corrections.textContent = session.ui_status;
|
| 728 |
saveSession();
|
|
|
|
| 427 |
renderProjectReferenceState();
|
| 428 |
renderProjects(session.last_projects || [], "No project page matched this request.");
|
| 429 |
renderIdeas(session.ideas || []);
|
| 430 |
+
delete session.last_plan;
|
| 431 |
+
renderPlan([]);
|
| 432 |
setCommandDisabled(false);
|
| 433 |
restoreSessionCopy();
|
| 434 |
return;
|
|
|
|
| 714 |
if (!ideaId || !Array.isArray(session.ideas)) return;
|
| 715 |
const idea = session.ideas.find((item) => item.id === ideaId);
|
| 716 |
if (!idea) return;
|
| 717 |
+
const changedIdea = idea.id !== session.current_idea_id;
|
| 718 |
bumpSessionRevision();
|
| 719 |
session.current_idea_id = idea.id;
|
| 720 |
if (Array.isArray(idea.goals) && idea.goals.length) {
|
|
|
|
| 724 |
renderSelectedIdeaArtifact(idea);
|
| 725 |
renderGoals(session.goals || []);
|
| 726 |
renderIdeas(session.ideas);
|
| 727 |
+
if (changedIdea) delete session.last_plan;
|
| 728 |
+
renderPlan(changedIdea ? [] : session.last_plan || []);
|
| 729 |
session.ui_status = `selected: ${idea.title}`;
|
| 730 |
corrections.textContent = session.ui_status;
|
| 731 |
saveSession();
|
tests/test_agent.py
CHANGED
|
@@ -88,6 +88,20 @@ def test_plan_command_uses_current_idea() -> None:
|
|
| 88 |
assert planned.state["ideas"][0]["title"] == first.artifact["title"]
|
| 89 |
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
def test_plan_and_rank_do_not_create_placeholder_ideas() -> None:
|
| 92 |
index = ProjectIndex.from_files(Path("data/projects.json"), Path("data/project_index.json"))
|
| 93 |
engine = AdvisorEngine(index)
|
|
|
|
| 88 |
assert planned.state["ideas"][0]["title"] == first.artifact["title"]
|
| 89 |
|
| 90 |
|
| 91 |
+
def test_non_plan_turns_clear_stale_build_plan() -> None:
|
| 92 |
+
index = ProjectIndex.from_files(Path("data/projects.json"), Path("data/project_index.json"))
|
| 93 |
+
engine = AdvisorEngine(index)
|
| 94 |
+
|
| 95 |
+
first = engine.turn("A local-first archive cartographer for family photos", {})
|
| 96 |
+
planned = engine.turn("make a build plan", first.state)
|
| 97 |
+
project = engine.turn("read project lolaby", planned.state)
|
| 98 |
+
second = engine.turn("A hands-on science coach for kitchen experiments", planned.state)
|
| 99 |
+
|
| 100 |
+
assert planned.state["last_plan"]
|
| 101 |
+
assert "last_plan" not in project.state
|
| 102 |
+
assert "last_plan" not in second.state
|
| 103 |
+
|
| 104 |
+
|
| 105 |
def test_plan_and_rank_do_not_create_placeholder_ideas() -> None:
|
| 106 |
index = ProjectIndex.from_files(Path("data/projects.json"), Path("data/project_index.json"))
|
| 107 |
engine = AdvisorEngine(index)
|