Skip to content

Commit 2b52bc2

Browse files
authored
Merge pull request #120 from MLAI-AUS-Inc/codex/domain-scan-routing-fix
bugfix article directory
2 parents cd0c9d1 + d8902e9 commit 2b52bc2

File tree

3 files changed

+119
-13
lines changed

3 files changed

+119
-13
lines changed

roo-standalone/roo/main.py

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,30 +1664,40 @@ async def content_factory_callback(request: Request):
16641664
_remember_content_thread_context(channel_id, thread_ts, domain, "scaffold")
16651665

16661666
if already_exists:
1667+
detail_lines = []
1668+
if pr_url:
1669+
detail_lines.append(f"• PR: <{pr_url}|View pull request>")
1670+
if preview_url:
1671+
detail_lines.append(f"• Preview: <{preview_url}|View live preview> :eyes:")
1672+
details = f"\n\n" + "\n".join(detail_lines) if detail_lines else ""
16671673
blocks = [
16681674
{
16691675
"type": "section",
16701676
"text": {
16711677
"type": "mrkdwn",
1672-
"text": "ℹ️ Articles directory already exists - no changes needed."
1678+
"text": f"ℹ️ Articles directory already exists - no changes needed.{details}"
16731679
}
16741680
}
16751681
]
16761682
elif pr_url:
1677-
details = f"• {files_created} files created ({component_count} components, {pillar_count} content pillars)"
1683+
details = (
1684+
f"• {files_created} files created ({component_count} components, {pillar_count} content pillars)"
1685+
if files_created
1686+
else f"• Reused the existing scaffold branch/PR ({component_count} components, {pillar_count} content pillars)"
1687+
)
16781688
details += f"\n• PR: <{pr_url}|View pull request>"
1689+
details += (
1690+
"\n• Build: Passed :white_check_mark:"
1691+
if build_verified
1692+
else "\n• Build: Not verified"
1693+
)
16791694

16801695
if preview_url:
16811696
preview_label = "View live preview"
16821697
if "stackblitz.com" in preview_url:
16831698
preview_label += " (may take a moment to load)"
16841699
details += f"\n• Preview: <{preview_url}|{preview_label}> :eyes:"
16851700

1686-
if build_verified:
1687-
details += "\n• Build: Passed :white_check_mark:"
1688-
else:
1689-
details += "\n• Build: Not verified"
1690-
16911701
extra_sections = []
16921702
if preview_url:
16931703
extra_sections.append({
@@ -2277,11 +2287,17 @@ async def slack_actions(request: Request):
22772287
elif status_code == 200:
22782288
# Already scaffolded
22792289
pr_url = data.get("pr_url", "")
2280-
pr_text = f" PR: {pr_url}" if pr_url else ""
2290+
preview_url = data.get("preview_url", "")
2291+
details = []
2292+
if pr_url:
2293+
details.append(f"PR: {pr_url}")
2294+
if preview_url:
2295+
details.append(f"Preview: {preview_url}")
2296+
detail_text = f" {' | '.join(details)}" if details else ""
22812297
post_message(
22822298
channel=reply_channel,
22832299
thread_ts=reply_thread_ts,
2284-
text=f"📁 Articles directory already exists for *{domain}*.{pr_text}"
2300+
text=f"📁 Articles directory already exists for *{domain}*.{detail_text}"
22852301
)
22862302
elif status_code == 400:
22872303
error = data.get("error", "Unknown error")
@@ -3156,7 +3172,6 @@ async def slack_actions(request: Request):
31563172

31573173
if status_code == 200:
31583174
pr_url = data.get("pr_url", "")
3159-
pr_text = f" PR: {pr_url}" if pr_url else ""
31603175
if original_intent and original_intent.get("action") == "write":
31613176
await _trigger_article_generation_from_pending(
31623177
{
@@ -3170,10 +3185,17 @@ async def slack_actions(request: Request):
31703185
fallback_thread_ts=reply_thread_ts,
31713186
)
31723187
else:
3188+
preview_url = data.get("preview_url", "")
3189+
details = []
3190+
if pr_url:
3191+
details.append(f"PR: {pr_url}")
3192+
if preview_url:
3193+
details.append(f"Preview: {preview_url}")
3194+
detail_text = f" {' | '.join(details)}" if details else ""
31733195
post_message(
31743196
channel=reply_channel,
31753197
thread_ts=reply_thread_ts,
3176-
text=f"📁 Articles directory already exists for *{domain}*.{pr_text}"
3198+
text=f"📁 Articles directory already exists for *{domain}*.{detail_text}"
31773199
)
31783200
elif status_code == 400:
31793201
error = data.get("error", "Unknown error")

roo-standalone/roo/skills/executor.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,8 +1817,14 @@ async def _execute_content_factory(
18171817

18181818
if status_code == 200:
18191819
pr_url = data.get("pr_url", "")
1820-
pr_text = f" <{pr_url}|View PR>" if pr_url else ""
1821-
return f"📁 Articles directory already exists for *{domain}*.{pr_text}"
1820+
preview_url = data.get("preview_url", "")
1821+
detail_parts = []
1822+
if pr_url:
1823+
detail_parts.append(f"<{pr_url}|View PR>")
1824+
if preview_url:
1825+
detail_parts.append(f"<{preview_url}|View Preview>")
1826+
detail_text = f" {' | '.join(detail_parts)}" if detail_parts else ""
1827+
return f"📁 Articles directory already exists for *{domain}*.{detail_text}"
18221828
elif status_code == 202:
18231829
return "Scaffolding is underway! I'll reply here when it's done. 🏗️"
18241830
elif status_code == 412:

roo-standalone/roo/tests/test_content_factory_article_flow.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,44 @@ async def test_explicit_github_scan_with_existing_scan_prompts_for_confirmation(
765765
assert FakeContentFactoryClient.last_instance.repo_scan_calls == []
766766

767767

768+
@pytest.mark.asyncio
769+
async def test_explicit_scaffold_returns_existing_pr_and_preview(monkeypatch):
770+
executor = SkillExecutor()
771+
posted_messages = []
772+
_patch_content_factory(monkeypatch)
773+
774+
async def fake_scaffold_articles(self, **kwargs):
775+
return {
776+
"status_code": 200,
777+
"data": {
778+
"status": "already_scaffolded",
779+
"pr_url": "https://github.test/pr/123",
780+
"preview_url": "https://preview.test/articles",
781+
},
782+
}
783+
784+
monkeypatch.setattr(FakeContentFactoryClient, "scaffold_articles", fake_scaffold_articles, raising=False)
785+
monkeypatch.setattr(
786+
executor_module,
787+
"post_message",
788+
lambda *args, **kwargs: posted_messages.append({"args": args, "kwargs": kwargs}) or {"ts": "111.222"},
789+
)
790+
791+
result = await executor._execute_content_factory(
792+
skill=None,
793+
text="please scaffold an articles directory for mlai.au",
794+
params={"domain": "mlai.au", "action": "scaffold", "confirmed": True},
795+
user_id="U05QPB483K9",
796+
channel_id="C123",
797+
thread_ts="111.222",
798+
)
799+
800+
assert "Articles directory already exists" in result
801+
assert "<https://github.test/pr/123|View PR>" in result
802+
assert "<https://preview.test/articles|View Preview>" in result
803+
assert posted_messages[0]["args"][1] == "📁 Creating articles directory for *mlai.au*..."
804+
805+
768806
@pytest.mark.asyncio
769807
async def test_explicit_research_request_starts_generation(monkeypatch):
770808
executor = SkillExecutor()
@@ -2048,6 +2086,46 @@ async def json(self):
20482086
assert "fresh scan result" in posted_messages[-1][1]["text"]
20492087

20502088

2089+
def test_scaffold_complete_callback_reused_pr_shows_build_and_preview(monkeypatch):
2090+
posted_messages = []
2091+
2092+
monkeypatch.setattr(
2093+
main_module,
2094+
"post_message",
2095+
lambda *args, **kwargs: posted_messages.append((args, kwargs)),
2096+
)
2097+
monkeypatch.setattr(main_module, "_remember_content_thread_context", lambda *args, **kwargs: None)
2098+
2099+
payload = {
2100+
"event_type": "scaffold_complete",
2101+
"slack_user_id": "U05QPB483K9",
2102+
"job_id": "scaffold-job-123",
2103+
"domain": "mlai.au",
2104+
"channel_id": "C123",
2105+
"thread_ts": "111.222",
2106+
"pr_url": "https://github.test/pr/456",
2107+
"preview_url": "https://preview.test/articles",
2108+
"files_created": 0,
2109+
"pillar_count": 4,
2110+
"component_count": 18,
2111+
"build_verified": True,
2112+
}
2113+
2114+
class FakeRequest:
2115+
async def json(self):
2116+
return payload
2117+
2118+
response = asyncio.run(main_module.content_factory_callback(FakeRequest()))
2119+
2120+
assert response == {"status": "ok"}
2121+
assert len(posted_messages) == 1
2122+
blocks = posted_messages[0][1]["blocks"]
2123+
text = blocks[0]["text"]["text"]
2124+
assert "Reused the existing scaffold branch/PR" in text
2125+
assert "Build: Passed" in text
2126+
assert "https://preview.test/articles" in text
2127+
2128+
20512129
def test_confirm_content_factory_action_resumes_original_request(monkeypatch):
20522130
resumed_events = []
20532131
posted_messages = []

0 commit comments

Comments
 (0)