open-swe/tests/test_dashboard_repo_optional.py
Johannes du Plessis dee78e7e84
fix: make repository optional when starting a dashboard run (#1397)
* fix: make repository optional when starting a dashboard run

The agent infers and clones the target repo from the task itself, so a
default repo is never actually required to run — but the dashboard 400'd
("no default repository configured") when a user had none set.

Treat repo as optional: _resolve_repo_config returns {} instead of
raising, repo metadata/config are only written when a repo is present,
and the "missing repository metadata" gate on follow-up messages is
dropped. UI hides the repo chip when absent.

* feat: add repo picker to the run prompt bar

Adds an optional, searchable repository selector next to the model picker
on the Agents home prompt bar (Cursor-style). It pre-fills the user's saved
default repo and can be cleared to "No repository" for a repo-less run.

Because the picker now resolves the default on the client, the create
endpoint honors the request value verbatim: _resolve_repo_config just parses
what's sent ({} when empty) instead of falling back to the saved default,
so an explicit "No repository" is respected.

* refactor: match Cursor layout for repo placement

Move the repo selector out of the prompt-box footer to a pill row above
the input (folder + caret, dropdown opens downward); the model picker
stays inside the box. In the thread view, show the thread title and repo
in a header at the top of the chat, with the follow-up input pinned to
the bottom as before.
2026-06-03 14:24:08 -07:00

38 lines
1.2 KiB
Python

from __future__ import annotations
from agent.dashboard import thread_api
def test_resolve_repo_config_parses_request_repo() -> None:
assert thread_api._resolve_repo_config("octo/repo") == {"owner": "octo", "name": "repo"}
def test_resolve_repo_config_returns_empty_when_no_repo_given() -> None:
# None / blank / malformed all mean an intentionally repo-less run — never an error.
assert thread_api._resolve_repo_config(None) == {}
assert thread_api._resolve_repo_config("") == {}
assert thread_api._resolve_repo_config("not-a-repo") == {}
def test_thread_summary_blanks_repo_when_absent() -> None:
summary = thread_api._thread_summary(
{"thread_id": "t1", "metadata": {"source": "dashboard", "title": "no repo run"}}
)
assert summary["repo"] == ""
assert summary["repoFullName"] == ""
def test_thread_summary_keeps_repo_when_present() -> None:
summary = thread_api._thread_summary(
{
"thread_id": "t2",
"metadata": {
"source": "dashboard",
"title": "repo run",
"repo_owner": "octo",
"repo_name": "repo",
},
}
)
assert summary["repo"] == "repo"
assert summary["repoFullName"] == "octo/repo"