Skip to content

feat(ui): proxy legacy /print to backend (restores First-Print smoke curl)#84

Merged
strausmann merged 3 commits into
mainfrom
fix/frontend-proxy-print-jobs
May 17, 2026
Merged

feat(ui): proxy legacy /print to backend (restores First-Print smoke curl)#84
strausmann merged 3 commits into
mainfrom
fix/frontend-proxy-print-jobs

Conversation

@strausmann
Copy link
Copy Markdown
Owner

Summary

Restores the Phase 4 First-Print ad-hoc smoke-test workflow via Pangolin.

Before Phase 7, `curl -X POST http://hhdocker02:8000/print -d '...'` worked from inside the Tailscale network because the backend container exposed port 8000. After Phase 7 placed the Frontend Go proxy in front of the backend AND stopped publishing port 8000, that direct curl 404'd. The Frontend proxy mounts `/api/*`, `/docs`, `/openapi.json`, `/redoc`, `/readiness`, `/healthz` — but the legacy Phase-4 `/print` route was missed.

Adds `r.Handle("/print", prx)` so `POST https://labels.strausmann.cloud/print\` reaches the backend with the Pangolin Basic-Auth bypass.

Round 2 in this PR

Commit `805fdcd` initially also added `r.Handle("/jobs/{rest:.*}", prx)` to enable JSON-based job-status checks. This had higher chi route priority than the existing `r.Get("/jobs/{id}", ph.JobDetail)` frontend HTML page — browsers visiting `labels.strausmann.cloud/jobs/` got the backend JSON instead of the rendered page. Commit `0d06e74` reverts that `/jobs` catch-all — only `/print` is added in net.

If automated scripts later need JSON-based job status access, the upcoming Phase 7d `/api/jobs` endpoint (#80) will cover that path cleanly, or a follow-up PR could add Accept-header sniffing for `/jobs/{id}`.

Test plan

  • New `TestProxyMountsLegacyFirstPrintRoutes` subtest: POST /print → 202 with job_id
  • Existing `TestJobDetail*` frontend tests pass — confirming `/jobs/{id}` HTML page intact
  • `go vet ./...` clean
  • Production smoke after merge: `curl -u claude-automation:... -X POST https://labels.strausmann.cloud/print -d '{...}'` → 202 + job_id

Commits

SHA Was
805fdcd feat(ui): proxy legacy /print + /jobs/{id} (initial — /jobs part was UI-regression)
0d06e74 fix(ui): revert /jobs proxy — kept only /print

Refs #22

Phase 4 First-Print test uses POST http://hhdocker02:8000/print directly
against the backend. Phase 7 moved the backend behind a Frontend Go
proxy that mounts /api/*, /docs, /openapi.json, /redoc, /readiness,
/healthz — but missed /print and /jobs/{id}. Container port 8000 is no
longer published either, so the curl-based smoke from inside Tailscale
404'd post-Phase-7.

Add both routes to the proxy so the ad-hoc smoke workflow works again
via https://labels.strausmann.cloud/print with the claude-automation
Basic-Auth header. /jobs uses the chi regex wildcard {rest:.*} that
has higher route priority than the plain {id} param, preserving the
job-id path component end-to-end to the backend.

Refs #22
Commit 805fdcd added r.Handle("/jobs/{rest:.*}", prx) which had higher
chi route priority than the existing r.Get("/jobs/{id}", ph.JobDetail)
page route. Browsers visiting labels.strausmann.cloud/jobs/<id> got
the backend JSON instead of the rendered HTML page — UI regression
that was not asked for.

Keep only /print proxied (the actual user request — Phase 4 First-Print
smoke curl). /jobs/{id} stays as the frontend-rendered HTML page; if
automated scripts need JSON, they can rely on the upcoming Phase 7d
/api/print + /api/jobs endpoints, or use Accept: application/json
sniffing in a future PR.

Refs #22
Copilot AI review requested due to automatic review settings May 17, 2026 21:47
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request restores the legacy /print endpoint functionality that was lost following recent infrastructure changes. By updating the frontend proxy configuration, it ensures that automated smoke tests can successfully reach the backend while maintaining the integrity of existing browser-based routes.

Highlights

  • Route Restoration: Added the /print route to the frontend proxy to restore legacy ad-hoc smoke test functionality.
  • Regression Prevention: Implemented a new test case, TestProxyMountsLegacyFirstPrintRoutes, to ensure the /print endpoint correctly forwards requests to the backend.
  • Route Separation: Explicitly excluded /jobs/{id} from the proxy to prevent conflicts with existing HTML page rendering.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request restores the legacy /print endpoint in the Go frontend proxy to support existing smoke tests and adds a corresponding integration test. Feedback includes a high-priority security concern regarding the use of a real internal hostname in test comments, which violates the repository's privacy guidelines. Additionally, it is recommended to use the existing testRouterWithBackend helper function in the new test to reduce code duplication and redundant initialization.

Comment thread frontend/cmd/server/main_test.go Outdated
Comment thread frontend/cmd/server/main_test.go Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.98%. Comparing base (4e74a03) to head (3a0077f).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #84   +/-   ##
=======================================
  Coverage   91.98%   91.98%           
=======================================
  Files          70       70           
  Lines        3055     3055           
  Branches      261      261           
=======================================
  Hits         2810     2810           
  Misses        181      181           
  Partials       64       64           
Components Coverage Δ
Printer Backends (transport) 87.50% <ø> (ø)
Printer Models (drivers) 91.42% <ø> (ø)
Services 92.09% <ø> (ø)
REST API 91.30% <ø> (ø)
Pydantic Schemas 100.00% <ø> (ø)
Integration Plugins 100.00% <ø> (ø)
Flag Coverage Δ
backend 91.98% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4e74a03...3a0077f. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores the legacy First-Print smoke path by routing /print through the Go frontend reverse proxy to the backend.

Changes:

  • Adds /print to frontend proxy mounts.
  • Adds a Go router test verifying POST /print returns the backend 202 response.
  • Documents that /jobs/{id} remains served by the frontend HTML handler.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
frontend/cmd/server/main.go Registers /print with the backend reverse proxy.
frontend/cmd/server/main_test.go Adds coverage for the legacy /print proxy route.

Comment thread frontend/cmd/server/main_test.go Outdated
Bot reviews on PR #84 flagged:
- HIGH: hhdocker02 in a test comment tripped the Privacy / secret scan
  CI job. Replaced with a generic "backend container" reference.
- MEDIUM: the new TestProxyMountsLegacyFirstPrintRoutes built its own
  mock backend + router init inline. Refactored to use the existing
  testRouterWithBackend helper for parity with the surrounding tests.

Refs #22
@strausmann strausmann merged commit 8ef36ed into main May 17, 2026
19 checks passed
@strausmann strausmann deleted the fix/frontend-proxy-print-jobs branch May 17, 2026 22:18
github-actions Bot pushed a commit that referenced this pull request May 18, 2026
## 0.6.0 (2026-05-18)

* docs(api): address PR #79 bot-review — privacy sanitise + protocol self + consistency fixes ([61602d0](61602d0)), closes [#79](#79) [#22](#22)
* docs(api): pure-vector SVG samples for all 12 seed templates (#83) ([a066dde](a066dde)), closes [#83](#83) [#81](#81) [#22](#22)
* docs(phase-7b): foundation design spec — init-robustness + health-split + pangolin-bypass (#74) ([c5a7964](c5a7964)), closes [#74](#74) [fosrl/pangolin#3099](fosrl/pangolin#3099) [#22](#22) [#22](#22)
* docs(phase-7d): foundation design — print API + QR tab + hangar plugin (#79) ([cdaedeb](cdaedeb)), closes [#79](#79) [strausmann/hangar#63](https://github.com/strausmann/hangar/issues/63) [#22](#22)
* fix: 3 production bugs from local smoke-test + dev/ folder ([c0fc903](c0fc903)), closes [#67](#67) [#67](#67) [#67](#67) [#67](#67) [#67](#67) [#67](#67) [#67](#67) [#67](#67)
* fix: Phase 6b code-cleanup — 6 audit findings + plugin pattern wired ([f77aa44](f77aa44)), closes [#67](#67) [#67](#67) [#67](#67) [#67](#67) [#67](#67) [#67](#67) [#67](#67) [#67](#67)
* fix(api): Phase 7b.1 — upsert name-collision + /readiness proxy gap (#77) ([4e74a03](4e74a03)), closes [#77](#77) [#76](#76) [#22](#22) [#76](#76) [#22](#22) [#77](#77) [#1](#1) [#76](#76) [#22](#22)
* fix(ui): printer detail metadata + template preview + paused-bool gap (#82) ([52bab83](52bab83)), closes [#82](#82) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22)
* feat(api): Phase 7b foundation — init, datetime-TZ, /readiness, status cache, proxy widening (#75) ([784decc](784decc)), closes [#75](#75) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [#22](#22) [HI#priority](https://github.com/HI/issues/priority) [#75](#75) [#22](#22)
* feat(ui): proxy legacy /print to backend (restores First-Print smoke curl) (#84) ([8ef36ed](8ef36ed)), closes [#84](#84) [#22](#22) [#22](#22) [#84](#84) [#22](#22)

[skip ci]
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.

2 participants