feat(quiz): toggle the anchor panel + link the filename to GitHub - #30
Merged
Conversation
Two refinements to the inline code context: - The anchored hunk is collapsible again (a closed-by-default disclosure that lazy-loads on first expand) rather than always-on, so a multi-question quiz isn't a wall of code. The clip-to-anchor + line highlighting is unchanged. - The filename in the panel header is now a link to that file on the PR's head branch in GitHub, deep-linked to the anchored line range (`…/blob/<branch>/<path>#L<start>-L<end>`, opens in a new tab). Clicking the link doesn't toggle the panel. Wiring: the PR head branch is threaded from the CLI through `COGNIT_BRANCH` into the web app and templated onto `<body data-branch=...>` (alongside the existing pr-url) so the browser can build blob URLs. Falls back to plain text when no branch is available (tests/demos). Tested: `COGNIT_BRANCH` in the launch env; branch templated into the page; mcp/engine suite green; ruff + mypy clean. Verified in a real browser: panel collapsed by default, expands + lazy-loads the highlighted hunk, and the filename links to the correct branch + line range on GitHub. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Guards against a 404: the anchor filename now upgrades to a GitHub blob link only after confirming the path is one of the PR's changed files (the list the coverage map already fetches). A hallucinated or non-diff anchor path stays plain text instead of linking to a file that doesn't exist on the branch. Verified in a browser: an in-diff anchor renders as a link to the file on the branch; an anchor whose path isn't in the diff stays plain text. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two refinements to the inline code context, per feedback:
…/blob/<branch>/<path>#L<start>-L<end>, new tab). Clicking the link doesn't toggle the panel (stopPropagation).Wiring
The PR's head branch (already known to the CLI as
info.branch) is threaded through a newCOGNIT_BRANCHenv var →build_web_app(branch=...)→ templated onto<body data-branch=...>(next to the existing pr-url). The browser derives the repo blob base from the PR url and builds the link. Falls back to plain text when there's no branch (tests/demos).Testing
COGNIT_BRANCHpresent in the launch env (test_launch); branch templated into the page and placeholder substituted (test_web). Fullmcp/enginesuite green;ruff+ruff format --check+mypy --strictclean.<details>closed by default; expanding lazy-loads the highlighted hunk; the filename is an<a>to…/blob/<branch>/<path>#L42-L46withtarget=_blank; following it doesn't toggle the panel.🤖 Generated with Claude Code