Skip to content

The studio opens from a link, and takes a text from the page that opened it - #27

Merged
ddehilster merged 1 commit into
mainfrom
feat/open-by-link-with-a-handed-in-text
Sep 26, 2026
Merged

ddehilster merged 1 commit into
mainfrom
feat/open-by-link-with-a-handed-in-text

Conversation

@ddehilster

Copy link
Copy Markdown
Member

This lets a page that lists real documents open the studio on one of them, in the analyzer that reads it, ready to run and edit. The first user is TEG's NLP console: its Workbench has a button on every résumé.

The link names the analyzer: ?repo=owner/name&ref=branch&folder=path&handoff=1. It opens that analyzer from GitHub the way Open from GitHub does. If the person isn't signed in, the link is kept in sessionStorage across the sign-in round trip.

The text is never in the link. With handoff=1:

  1. The studio posts nlp-studio:ready to window.opener.
  2. It accepts {type: "nlp-studio:input", name, text} only if all of these hold:
    • it comes from the opener;
    • it comes from an origin listed in NLP_STUDIO_OPENERS (reported by /api/health; none by default);
    • it is at most 2 MB.
  3. The name is reduced to safe characters, as input/<name>.txt.

A handed-in text is never kept. It is an input file while the page is open, and it is what a run reads. It is never:

  • a browser draft;
  • among the changed files;
  • committed;
  • in the Download zip.

The file list says so beside it. A reload (signing in is one) loses it, and the studio says ready again so the opener can hand it over again.

Changes

  • src/handoff.ts: parsing the link, keeping it across sign-in, the name rule, and message acceptance.
  • main.ts:
    • openLink;
    • handed-in inputs, excluded from drafts, changedPaths, the zip and the file list's normal Input rows.
  • server/app.py: NLP_STUDIO_OPENERS → /api/health openers.
  • docs/ARCHITECTURE.md: a new section. deploy/env.example: the new variable.

Tests

  • tsc --noEmit is clean.
  • vitest: 52 pass, 8 of them new for the hand-off (link parsing, sign-in round trip, the name rule, refusal from other windows and origins, the size limit).
  • Server unittest: 68 pass.
  • Not yet tried in a browser against a running studio.

🤖 Generated with Claude Code

…ned it

A page that lists real documents can now open the studio on one of them:
?repo=owner/name&ref=branch&folder=path&handoff=1 opens that analyzer from
GitHub (kept across the sign-in round trip), and the text arrives by
postMessage from window.opener -- never in the URL, only from an origin
listed in NLP_STUDIO_OPENERS (none by default), at most 2 MB.

A handed-in text is input/<name>.txt for as long as the page is open and is
what a run reads. It is never a draft, never among the changed files, never
committed and never in the Download zip; the file list says so beside it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ddehilster
ddehilster merged commit aa7a0a5 into main Sep 26, 2026
2 checks passed
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