Skip to content

Load remote features.json via ?features=URL(URL 分享:远程 features.json) #6

@Kaka-cheaper

Description

@Kaka-cheaper

Goal

Let the viewer load any URL-accessible features.json via a query parameter, so people can share a link instead of cloning a repo.

Why

Roadmap top item: "Share via URL". Current viewer only loads bundled examples or local files. Adding ?features=<url> and ?repo=<owner>/<repo> makes codeSee viable for showcasing OSS projects, code review sharing, blog embeds.

Scope (what is in)

  • Parse ?features=<url> from location.search
  • Parse ?repo=<owner>/<repo> shorthand → expand to https://raw.githubusercontent.com/{owner}/{repo}/main/.codesee/features.json
  • ?repo=owner/repo@branch for non-main branches
  • Fetch with timeout (10s), validate as a FeaturesFile before rendering
  • Show source label in TopBar (the host of the URL)
  • Error UI: clear message on CORS / 404 / parse failure (don't white-screen)
  • Read-only mode: dragging works but layout writes go to localStorage only (no FSA save)
  • When ?features= is set, ?example= is ignored

Out of scope

  • Authenticated fetches (private repos): user can drag-drop the file instead
  • ?layout=URL for layout (do in follow-up issue)
  • Embed mode (?embed=1): separate issue

Files likely involved

  • viewer/src/App.tsx (parse URL, dispatch to loader)
  • viewer/src/fcg/loader.ts (loadFromUrl already exists, may need polish)
  • viewer/src/app/TopBar.tsx (source label)

Acceptance criteria

  • ?features=https://raw.githubusercontent.com/Kaka-cheaper/codeSee/main/viewer/public/features.json loads and renders
  • ?repo=Kaka-cheaper/codeSee does the same via shorthand
  • Invalid URL → user-readable error, no white screen
  • CORS-blocked URL → message suggests dragging the file instead
  • Layout drags persist to localStorage, not FSA

Estimated effort

~3-4 hours / ~3 files

Hints

fetchFromUrl in loader.ts does most of the work. Main delta is URL parsing + the ?repo= expansion + safe error rendering.

Security check

  • Don't execute anything from the JSON
  • Treat the URL hostname as untrusted
  • Validate response < 5MB before parsing

Want to take this?

Comment "I'd like to take this" and I'll confirm within 24h.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is neededviewerViewer (frontend canvas, interaction, layout)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions