Skip to content

feat(view): links open the viewer's /view page - #67

Merged
jfrench9 merged 1 commit into
mainfrom
feature/viewer-link-path
Sep 16, 2026
Merged

jfrench9 merged 1 commit into
mainfrom
feature/viewer-link-path

Conversation

@jfrench9

Copy link
Copy Markdown
Member

Summary

xbrlkit view and the MCP view_filing tool now open https://xbrlkit.com/view?url=… instead of https://xbrlkit.com/?url=…. The viewer reads both paths the same way, so the person opening the link sees no difference.

The reason is measurement. xbrlkit.com now carries Cloudflare Web Analytics, and its beacon records the page path but drops the query string. A query marker such as &src=cli would never be seen. A distinct path is seen, so opens from xbrlkit become countable apart from report links on the web, which keep using /?url=.

Changes

  • xbrlkit/view.py: viewer_url builds the link on a new VIEWER_PAGE = "view" constant. The module docstring says what the path is for and that earlier releases' /?url= links keep working. ReportServer, ViewerHost, and so both the CLI and view_filing, all go through this one function.
  • Tests: the link assertions in tests/test_view.py and tests/test_serve.py now expect /view?url=, plus a test that pins the path and its reason.
  • README: the view section names the new link and notes that earlier releases' /?url= keeps working.

The CORS header is unchanged. It names the viewer's origin, and the path plays no part in it.

Output Impact

CHANGED OUTPUT, narrowly. The URL that xbrlkit view prints and opens, and the viewer_url that view_filing returns, now use the /view path. Anything that opens the link sees the same report.

Two edge cases:

  • A script that pattern-matches the printed URL against /?url= would need updating.
  • A --viewer pointed at a host without a single-page-app fallback would now 404 on /view. The hosted viewer, its CloudFront distribution, and npm run preview all serve it.

No filing's serialization changes.

Testing

just test-all green: ruff, format, basedpyright, and pytest with 530 passed and 2 skipped.

End to end against production on this branch:

  • uv run xbrlkit view <a tavi.json> --as tavi --no-open printed https://xbrlkit.com/view?url=http://127.0.0.1:<port>/<token>/….tavi.json.
  • Opened in a clean headless Chromium, the live viewer fetched the document from loopback (200, CORS satisfied) and rendered NVIDIA's 10-Q in the File lane.
  • The canonical stayed https://xbrlkit.com/.
  • Cloudflare's beacon reported "location": "https://xbrlkit.com/view" with a 204. An earlier probe of /?src=probe reported plain https://xbrlkit.com/, which is why a path rather than a query.

No viewer deploy is needed first. The live viewer already opens /view?url= correctly. A companion viewer PR makes the path explicit and tested there.

🤖 Generated with Claude Code

`xbrlkit view` and the MCP `view_filing` tool now open
`https://xbrlkit.com/view?url=…` instead of `/?url=…`. The viewer reads
both paths the same way, so nothing changes for the person opening it.

The path is what lets the viewer count opens from xbrlkit apart from
report links on the web: its page-view analytics record the path and
drop the query string, so a query-string marker would never be seen.

Earlier releases keep opening `/?url=`, which the viewer serves for
good. The CORS header is unchanged: it names the viewer's origin, and
the path does not enter into it.
jfrench9 added a commit to RoboFinSystems/xbrlkit-viewer that referenced this pull request Sep 16, 2026
xbrlkit's `view` command and its MCP `view_filing` tool now open
`/view?url=…` (RoboFinSystems/xbrlkit#67), so the analytics, which
record the path and drop the query string, can count those opens apart
from report links on the web.

The viewer already opened that link, but only by accident: an unknown
path serves the apex page after a bucket miss, and a `?url=` there
shows the File lane. This names the path so a later routing change
cannot quietly break installed releases:
- `VIEW_PATH` in the route module documents it as the apex page under a
  second name, with the apex head and canonical.
- The CloudFront function maps `/view` to the apex index.html directly.
- Tests pin that `/view?url=` opens the File lane with the apex head,
  and that the app renders it.
@jfrench9
jfrench9 merged commit eaa4216 into main Sep 16, 2026
4 checks passed
@jfrench9
jfrench9 deleted the feature/viewer-link-path branch September 16, 2026 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant