Open reports via a clickable http:// link (file:// won't open in chat) - #26
Merged
Conversation
…n chat) A file:// link is blocked from opening in the Claude/VSCode chat sandbox, so clicking the returned location did nothing. Serve each report over a tiny loopback web server and hand back a clickable http://127.0.0.1 link that opens the rendered report in the browser — while still surfacing the on-disk location. - export.preview_url(path): lazily start a loopback (127.0.0.1, ephemeral port) static server rooted at the report's directory, on a daemon thread, one per directory; returns an http URL that opens the rendered report on click. - export.open_file(path): OS default open (startfile/open/xdg-open), best-effort, no-op under tests/CI/INVESTO_NO_OPEN. - models: ExportedFile/ExportResult gain open_url; AnalysisReport gains html_report_open_url, alongside the existing file:// location fields. - server: analyze_company and export_report populate the http open link. - cli: --open opens the written report in the default app (a short-lived CLI can't host a persistent server); the output still prints the file location.
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 & why
The report tools returned a
file://"open" link, but clicking it does nothing in the Claude Code / VSCode chat — the sandbox blocksfile://from opening a local file. The only link a chat/webview will open ishttp(s)://. So each report is now served over a tiny loopback web server and returned as a clickablehttp://127.0.0.1:<port>/<file>link that opens the rendered report in the browser (PDF opens in the viewer). The on-disk location is still surfaced too.Changes
export.pypreview_url(path)— lazily starts a loopback (127.0.0.1, ephemeral port) static server rooted at the report's directory, on a daemon thread (one per directory), and returns anhttp://127.0.0.1/...URL that opens the rendered report on click. Loopback-only, serves just that directory, best-effort (returnsNoneif a port can't be bound).open_file(path)— OS default open (startfile/open/xdg-open), best-effort, no-op underPYTEST_CURRENT_TEST/CI/INVESTO_NO_OPEN.models.py—ExportedFile/ExportResultgainopen_url;AnalysisReportgainshtml_report_open_url(alongside the existingfile://location fields).server.py—analyze_companyandexport_reportpopulate the http open link.cli.py—--openopens the written report in the default app (a short-lived CLI can't host a persistent server); the output still prints the file location.Verification
ruff check .,mypy,pytest -q— all green (288 tests; a new test fetches a report back over the loopback link and asserts200).preview_url()returnedhttp://127.0.0.1:62056/…, and a GET returned the full rendered HTML (200).investo analyze "Sigachi Industries" --openwrote and opened the report in the browser.Note
The clickable
http://127.0.0.1link works while the long-running MCP server is up (it hosts the preview server). After merging, restart the Investo MCP server soanalyze_company/export_reportreturn the newopen_url/html_report_open_url.