HTTP Debug artifacts (HAR)
Drop a .har into an issue body. It is optimized in the browser, stored content
addressed, referenced as a link and rendered as a label. Clicking the label opens
a popup left drawer with the HTTP debug view.
Locked decisions
- File stays a spec-valid
.har, optimized as far as the schema allows. - Identical dumps dedupe: the file is named by the SHA-1 of the optimized text.
- One
HTTP Debugtab in the drawer. Opening another HAR replaces the content of
that tab, it does not add a tab. - Drawer identity lives in the URL:
?issue-id=123&issue-har=<hash>. - Secrets are redacted on store. This is not optional.
- Optimization runs on the frontend. The server stores what it receives.
- The file is written as one compact line, not pretty-printed.
Storage
flowchart LR
drop["drop .har in editor"] --> optimize["lib/har.ts optimizeHar() in browser"]
optimize --> size{"optimized <= 2 MB?"}
size -- no --> reject["reject with a message"]
size -- yes --> upload["POST /api/board/:slug/hars"]
upload --> write[".project/hars/<sha1-base64url>.har"]
write --> commit["mutate() commit"]
commit --> link["insert [HTTP Debug - example.com #1](../hars/<hash>.har)"]
- Path:
.project/hars/<hash>.har. - Ref from an issue file (which lives in
.project/issues/):../hars/<hash>.har. hashis the SHA-1 digest of the optimized text, base64url encoded with no
padding. 20 bytes becomes 27 chars, shorter than the 40 hex form. This mirrors
the image pipeline, which is content addressed with a base64url hash.- Same input dumps produce the same file, so re-dropping is a no-op.
- Written through
mutate()like images, so it commits and syncs with the
project repo.
The label still carries the domain. Only the file and the query use the hash.#n counts distinct HAR files already referenced in the document, so two
different dumps from example.com read #1 and #2.
The optimizer
New file lib/har.ts, pure and testable, and imported by the browser bundle the
same way lib/http.ts is. Input raw HAR text, output optimized text plus stats.
optimizeHar(raw: string): {
text: string; // compact JSON, one line
stats: HarStats; // { target, entries, bytes, duration }
};
Stats are returned for the label, they are never written to the file.
Spec-validity rule
HAR types request.url and response.redirectURL as absolute URLs, so those
stay absolute. Everything the spec treats as an opaque string is fair game, which
covers header values and body text. This gives most of the size win without
making the file invalid, and the file still opens in Chrome DevTools.
Target
target is the dominant host: the host with the most entries, ties broken by
first appearance. It is not written into the file. Export harTarget(har) fromlib/har.ts and call it in both places that need it, the optimizer and the
viewer, so display-time shortening uses the same definition.
Opaque values
- Header values: replace target occurrences with
[self], longest prefix first,
sohttps://target,http://target,//targetthen baretarget. - Body text:
[DataURL base64]for data URLs, andhttps://target/http://targetto[self]. request.urlandresponse.redirectURL: left absolute, untouched apart from
redaction.
Headers
Redact by name: authorization, proxy-authorization, cookie, set-cookie,
and anything matching /(^|[-_])(token|secret|api[-_]?key|auth)/i. Value becomes[redacted], which is still a valid string.
Dropped fields
Derivable or junk, safe to remove:
log.creator,log.browser(keep name and version),log.pages,pageref,pageTimings.cache(almost always empty).timingskeys whose value is-1.headersSize,bodySize.request.queryString,request.cookies,response.cookies._-prefixed vendor fields, except_resourceTypeand_priority.
Bodies
Order matters: collapse data URLs to [DataURL base64] and swap target prefixes
for [self] first, then cap. A body that is one large data URL shrinks to a
placeholder before the cap applies, so it survives intact.
- Cap any single body over 64 KB. Keep the head, append
… [truncated], set_truncated: trueon the content object. A non-standard_field is tolerated
by HAR consumers.
Compact
JSON.stringify(optimized) with no indentation. One line.
Server
POST /api/board/:slug/harsbody{ har: string }-> verify it parses as JSON
and is at most 2 MB, compute the SHA-1 base64url of the exact text, write.project/hars/<hash>.har, commit, return{ ref, id, entries }.GET /p/:slug/files/hars/:name-> member-checked likeserveImage, content
typeapplication/json,cache-control: private.storeIssueHar(text, by)on the runtime incrates/patlas-server/src/runtime.rs, mirroringstoreIssueImage. The server recomputes the hash from the exact bytes it
stores, so a client cannot claim a filename it did not produce, and the client
never needscrypto.subtle.
Client
Drop
Extend onDrop in issue-editor.tsx to accept .har files beside image/*.
Read as text, run optimizeHar, reject over 2 MB, upload, then insert the link at
the caret, built from the ref the server returns:
[HTTP Debug - example.com #1](../hars/<hash>.har)
The client does not hash. crypto.subtle is unavailable on insecure origins, and
the server has to recompute the digest anyway, so the hash arrives in the upload
response.
Markdown chip
case "link" in markdown.tsx: when href starts with ../hars/, render abutton.document-ref.har-ref chip instead of an <a>. Clicking callsctx.onOpenHar?.(id) which navigates to ?issue-id=...&issue-har=<hash>. With no
handler, fall through to a normal link to the served file.
Two props join imageBase: harBase (/p/:slug/files/hars) for the fallback
link, and onOpenHar(id). Both go on MarkdownProps and RenderContext. Note
that ChatTranscript builds its own RenderContext and currently drops the
interactive props, so harBase and onOpenHar must be threaded through there
too, or HAR links inside chat blocks lose their chip.
Sidebar of the issue popup
flowchart TB
overlay[".modal-overlay (flex row)"] --> drawer[".har-drawer sidebar"]
overlay --> modal[".modal issue popup"]
drawer --> tabs["tab strip: HTTP Debug"]
drawer --> body["single column of collapsible exchanges (wire format via lib/http.ts)"]
- The sidebar is part of the issue popup, not a global overlay.
Modalgains asidebarslot rendered as a sibling of.modalinside.modal-overlay, so
both share the popup's backdrop and appear together. IssueModalpasses<HarDrawer slug={slug}/>as that slot. NoProjectShell
involvement, no scrim of its own.- Width
min(24rem, 92vw), fixed, sticky to the top while the popup scrolls. The
popup keepsflex-shrink: 1so the pair shares one row instead of wrapping. - One column: every entry is a collapsible exchange that expands in place. No
side-by-side list/detail split, so paths keep their width. - Hidden with
display: nonewhen closed, so the popup takes the full width. - Escape closes the sidebar first, then the popup on the next press. Closing the
popup clears theissue-harquery, since the sidebar belongs to it. - Reuse
lib/http.tsfor the wire-format view and token labels.
First paint note: reactive children nested inside a jsxIf result get stringified
by this renderer, so the detail pane is inflated imperatively into a stable host,
the same pattern the issue body uses.
Display-time shortening
Since storage keeps absolute URLs, the viewer does the earlier cosmetic work when
rendering: a URL whose host equals target shows as its path, other hosts show as//host/path, and header values get target occurrences swapped for [self].
Readable output, valid file.
Router and state
- Add
har?: stringandissueId?: numbertoProjectRoute, parsed from search
params inrouter.tsx. Both are parsed independently, so?issue-id=opens the
popup on its own. - The issue popup is route-driven and lives in
ProjectShell, not in each page:openIssue(id)andcloseIssue()write?issue-id=, so reload, back/forward
and sharing restore the popup, and the sidebar rides along. - Open and close the sidebar via
navigate(), so back/forward and reload restore
it.renderContentkeys on routename, so changing only the query does not
remount the content host. openHar(id, issueId)setsissue-har, andcloseHar()drops it while keepingissue-id.closeIssue()drops both.
Tests
tests/har.test.ts: field stripping, header[self]rewrite,[DataURL base64]
in bodies, secret redaction, 64 KB body truncation with_truncated, absolute
URLs left intact, one-line output,harTargetdetection, JSON still parses.tests/markdown.test.tscurrently exerciseslib/gfm, not the renderer. Add a
pureisHarRef(href)/harRefId(href)helper inlib/har.tsand cover the../hars/parsing there, since chip rendering needs a DOM.
Milestones
lib/har.tsoptimizer plus tests.storeIssueHar, the two routes, tests.- Client drop, optimize, size gate, link insert.
- Markdown chip.
- Drawer shell, tab, router query.
- Viewer layout with display-time shortening, reuse
lib/http.ts. - Build, deploy, verify.