Skip to content

Commit e6c617f

Browse files
Link wiki reproductions to the agent wiki explorer
Point agent wiki reproduction links at the in-app agent wiki explorer (?file=<path>) instead of the issue explorer, so they load reliably. Also remove the non-working "Open asset" link buttons and add a "Raw markdown" expander for easy copy-paste of the source document. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 0579e74 commit e6c617f

5 files changed

Lines changed: 36 additions & 12 deletions

File tree

app/agent_wiki_explorer.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ def _render_markdown_document(document: WikiDocument, markdown_content: str) ->
5353
else:
5454
st.info("This document is empty.")
5555

56+
with st.expander("Raw markdown"):
57+
st.code(markdown_content, language="markdown")
58+
5659

5760
def _render_image_asset(document: WikiDocument) -> None:
5861
local_path, local_path_error = get_wiki_document_local_path(document["path"])
@@ -75,12 +78,10 @@ def _render_code_asset(document: WikiDocument, language: str) -> None:
7578
return
7679
st.caption(document["path"])
7780
st.code(document_text, language=language)
78-
st.link_button("Open asset", document["raw_url"], width="content")
7981

8082

81-
def _render_other_asset(document: WikiDocument) -> None:
83+
def _render_other_asset() -> None:
8284
st.info("This asset is not rendered inline.")
83-
st.link_button("Open asset", document["raw_url"], width="content")
8485

8586

8687
title_row = st.container(horizontal=True, horizontal_alignment="distribute", vertical_alignment="center")
@@ -134,4 +135,4 @@ def _render_other_asset(document: WikiDocument) -> None:
134135
elif selected_document["extension"] in CODE_LANGUAGE_BY_EXTENSION:
135136
_render_code_asset(selected_document, CODE_LANGUAGE_BY_EXTENSION[selected_document["extension"]])
136137
else:
137-
_render_other_asset(selected_document)
138+
_render_other_asset()

app/issue_explorer.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
import streamlit as st
77
import streamlit.components.v1 as components
88

9-
from app.utils.agent_wiki import WikiIssueRepro, fetch_wiki_document_text, fetch_wiki_issue_repros
9+
from app.utils.agent_wiki import (
10+
WikiIssueRepro,
11+
build_wiki_explorer_url,
12+
fetch_wiki_document_text,
13+
fetch_wiki_issue_repros,
14+
)
1015
from app.utils.github_utils import get_issue_data
1116

1217
st.set_page_config(page_title="Issue explorer", page_icon="🚧")
@@ -225,7 +230,8 @@ def get_case_source_code(case: IssueCase) -> tuple[str | None, str | None]:
225230
st.info(
226231
f"This reproduction is loaded from the "
227232
f"[agent wiki]({wiki_repro['folder_url']}) and has not been reviewed. "
228-
f"[View `repro_app.py`]({wiki_repro['repro_app_source_url']}).{verify_suffix}",
233+
f"[Open `repro_app.py` in the wiki explorer]"
234+
f"({build_wiki_explorer_url(wiki_repro['repro_app_path'])}).{verify_suffix}",
229235
icon=":material/menu_book:",
230236
)
231237

app/open_issues.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pandas as pd
88
import streamlit as st
99

10-
from app.utils.agent_wiki import fetch_wiki_issue_repros, get_synced_wiki_repo_path
10+
from app.utils.agent_wiki import build_wiki_explorer_url, fetch_wiki_issue_repros, get_synced_wiki_repo_path
1111
from app.utils.github_utils import fetch_issue_reactions, fetch_issue_view_counts, get_all_github_issues
1212
from app.utils.issue_formatting import labels_to_type_emoji, reactions_to_str
1313

@@ -171,18 +171,22 @@ def initial_query_params(key: str) -> list[str]:
171171
wiki_repros, wiki_repros_error = fetch_wiki_issue_repros()
172172
if wiki_repros_error:
173173
print("Failed to load agent wiki reproductions:", wiki_repros_error, flush=True)
174-
wiki_repro_issue_numbers = set(wiki_repros)
175174

176175

177176
def get_reproducible_example(issue_number: int) -> str | None:
178-
"""Return a link to the issue explorer if a reproduction is available.
177+
"""Return a link to the available reproduction for an issue, if any.
179178
180-
Local reproductions take priority, but issues that only have a reproduction
181-
in the agent wiki are linked as well (the issue explorer resolves both).
179+
Local reproductions take priority and link to the issue explorer, where they
180+
can be run. Issues that only have a reproduction in the agent wiki link to
181+
the agent wiki explorer so the repro document can be viewed.
182182
"""
183183
issue_folder_name = f"gh-{issue_number}"
184-
if PATH_TO_ISSUES.joinpath(issue_folder_name).is_dir() or issue_number in wiki_repro_issue_numbers:
184+
if PATH_TO_ISSUES.joinpath(issue_folder_name).is_dir():
185185
return "/?issue=" + issue_folder_name
186+
187+
wiki_repro = wiki_repros.get(issue_number)
188+
if wiki_repro is not None:
189+
return build_wiki_explorer_url(wiki_repro["repro_app_path"])
186190
return None
187191

188192

app/utils/agent_wiki.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
WIKI_RAW_URL_PREFIX = "https://raw.githubusercontent.com/wiki/streamlit/streamlit"
2121
WIKI_SOURCE_URL_PREFIX = f"https://github.com/{WIKI_REPO}/blob/{WIKI_BRANCH}"
2222
WIKI_TREE_URL_PREFIX = f"https://github.com/{WIKI_REPO}/tree/{WIKI_BRANCH}"
23+
# In-app route of the agent wiki explorer page. The explorer selects a document
24+
# via the `file` query parameter (bound to its selectbox).
25+
WIKI_EXPLORER_URL_PATH = "/agent_wiki_explorer"
2326

2427
ALLOWED_TOP_LEVEL_SECTIONS = {"issues", "pull-requests", "references"}
2528
# Top-level sections whose direct children group artifacts by a numeric entity
@@ -158,6 +161,11 @@ def build_wiki_document_query_url(path: str) -> str:
158161
return f"?doc={quote(path, safe='')}"
159162

160163

164+
def build_wiki_explorer_url(path: str) -> str:
165+
"""Build an in-app link that opens a document in the agent wiki explorer."""
166+
return f"{WIKI_EXPLORER_URL_PATH}?file={quote(path, safe='/')}"
167+
168+
161169
def get_wiki_section(path: str) -> str:
162170
return path.split("/", 1)[0] if "/" in path else "(root)"
163171

tests/test_agent_wiki.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from app.utils.agent_wiki import (
22
build_wiki_documents,
3+
build_wiki_explorer_url,
34
build_wiki_raw_url,
45
build_wiki_tree_url,
56
get_wiki_folder,
@@ -56,6 +57,10 @@ def test_build_wiki_tree_url_points_to_folder_on_master() -> None:
5657
assert build_wiki_tree_url("issues/12345") == "https://github.com/streamlit/streamlit.wiki/tree/master/issues/12345"
5758

5859

60+
def test_build_wiki_explorer_url_links_to_explorer_page_with_file_param() -> None:
61+
assert build_wiki_explorer_url("issues/12345/repro_app.py") == "/agent_wiki_explorer?file=issues/12345/repro_app.py"
62+
63+
5964
def test_resolve_wiki_relative_path_handles_parent_and_root_relative_targets() -> None:
6065
assert (
6166
resolve_wiki_relative_path(

0 commit comments

Comments
 (0)