Skip to content

View text files inline in the pod filesystem browser #1581

Closed

Description

@nadaverell

Problem

Radar’s Pod filesystem browser already lists and downloads files, but every file is forced to download. Operators cannot quickly inspect a small text configuration or log-like file in the UI.

Scope

Add an inline viewer for safe, size-bounded text files in the existing Pod filesystem browser. This is deliberately read-only; pod-file editing and upload are separate work.

Acceptance criteria

  • A user can open a supported text file in an inline viewer instead of downloading it.
  • Downloads remain available and unchanged.
  • Binary, oversized, or unreadable files show a clear fallback/error state rather than attempting to render.
  • The backend enforces a conservative size limit before buffering or returning content.
  • Preserve the existing pod-exec RBAC/capability gate.
  • Add focused backend and frontend tests for the supported, binary, oversized, and failure paths.

Pointers

  • Existing backend browse/download implementation: internal/server/copy.go
  • Existing UI: web/src/components/resources/PodFilesystemModal.tsx
  • Pod exec/capability plumbing is already shared; reuse it rather than adding a new authorization path.

Please comment before starting so we can coordinate the file-type and size-limit UX.

Activity

  1. changyonggang commented on Sep 4, 2026

    @changyonggang
    Contributor

    Interested in picking this up — coordinating on the two UX calls before writing code, as the issue asks.

    My working assumptions (happy to adjust):

    1. Size cap

    • Backend limit: 1 MiB, enforced as a hard cap on the streamed read (io.LimitReader) before buffering. HEAD-equivalent stat first so oversized files short-circuit with an explicit error instead of a truncated preview.
    • Frontend does not attempt to read past the cap.

    2. What counts as "text"

    • Layered detection, applied server-side (never trust the extension alone):
      1. Reject if stat shows size > cap.
      2. Sniff the first 8 KiB with http.DetectContentType — accept text/*, application/json, application/xml, application/x-yaml.
      3. Fallback heuristic for the unknown-MIME case (common with configs like nginx.conf that sniff as application/octet-stream): reject if any NUL byte appears in the first 8 KiB, otherwise accept as text/plain; charset=utf-8.
    • Binary or unreadable → structured error, frontend shows a "Preview not supported — download instead" fallback with the existing download action intact.

    3. Encoding

    • UTF-8 only for v1. Non-UTF-8 falls through to the binary fallback. Explicit non-goal to detect/convert Latin-1 etc.

    4. UX affordance

    • Existing row keeps its Download action; a "Preview" action opens the file in an inline read-only viewer (Monaco in read-only mode, since it's already wired up for YAML). No tail-follow in v1 — logs already have a dedicated viewer.

    5. Backend shape

    • New `GET /api/pods/{ns}/{name}/file?container=&path=` returning `{content, encoding, truncated}` or a typed error. Reuses the existing pod-exec capability gate — no new authorization path. `HEAD` on the same route for the size/type probe.

    Do these numbers/decisions match what you had in mind, or should I adjust the cap, the sniff set, or the endpoint shape before starting? Happy to change any of it.

  2. changyonggang commented on Sep 8, 2026

    @changyonggang
    Contributor

    Following up under the new CONTRIBUTING.md process — could I be assigned to this? Happy to proceed on the assumptions in my earlier comment (1 MiB cap, layered MIME + NUL-byte sniff, UTF-8 v1, Monaco read-only, GET /api/pods/{ns}/{name}/file), and equally happy to adjust any of them if you'd rather land somewhere different before I start.

  3. nadaverell commented on Sep 8, 2026

    @nadaverell
    ContributorAuthor

    yes, assigned - thanks!
    suggestion sounds like a good start. try to test it in various scenarios to see that both the good and bad cases behave as intended (e.g. if you try to read a huge file, or a non-text file, or an empty file - that the UI makes sense, shows you errors that make it clear what happened - probably want curated error message rahter than only dumping raw error)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions