Skip to content

Add auth reload handler and improve number input formatting - #1

Closed
sherrmann wants to merge 12 commits into
masterfrom
claude/merge-upstream-prs-pck667
Closed

Add auth reload handler and improve number input formatting#1
sherrmann wants to merge 12 commits into
masterfrom
claude/merge-upstream-prs-pck667

Conversation

@sherrmann

Copy link
Copy Markdown
Owner

Summary

This PR adds automatic page reload on 401 authentication failures for forward-auth proxy support, improves number input formatting across the application, adds Prometheus build info metrics, and includes various bug fixes and enhancements.

Key Changes

Authentication & Security

  • New auth reload handler (authReloadHandler.ts): Automatically reloads the page on 401 responses from idempotent requests (GET/HEAD) to allow forward-auth proxies to redirect through login portals. Includes cooldown mechanism to prevent reload loops and unregisters service workers to ensure the reload reaches the proxy.

Number Input Formatting

  • Applied consistent number input formatting across multiple components using formatNumberOnUserInput and numberParser/numberParserAllowEmpty utilities:
    • Printing dialog (preview scale, paper size, margins)
    • Filament create/edit forms (weight fields)
    • Spool create/edit forms (weight fields)
    • Vendor create/edit forms (weight fields)
    • Extra fields component (float type fields)
    • Input number range component
    • QR code printing dialog
    • Spool adjustment modal
    • Extra fields settings

Backend Improvements

  • Prometheus metrics: Added BUILD_INFO metric to expose build information (version, commit, build date)
  • Export API: Added allow_archived query parameter to spool export endpoint to control inclusion of archived spools
  • External DB sync: Fixed bug where custom sync interval was ignored, now correctly uses sync_interval instead of DEFAULT_SYNC_INTERVAL

Infrastructure & DevOps

  • Docker: Added HEALTHCHECK to Dockerfile to verify API responsiveness
  • Docker Compose: Added example docker-compose.yml for easy local deployment
  • Dockerfile: Improved health check with proper port and base path handling

UI/UX Fixes

  • Fixed locations CSS by removing unnecessary overflow-y: scroll that could cause layout issues
  • Improved number input value handling in InputNumberRange component with proper type conversion

Dependencies

  • Updated uuid from ^13.0.0 to ^14.0.0

Implementation Details

  • The auth reload handler uses localStorage to track reload attempts and enforce a 30-second cooldown to prevent infinite reload loops
  • Service worker unregistration is attempted before reload to ensure the proxy can intercept the request
  • Number input formatting is applied consistently to maintain user experience across all numeric input fields
  • The Prometheus BUILD_INFO metric is populated during application startup with version and build metadata

https://claude.ai/code/session_01JqPtZvXQkraNt9ttEhLsBt

claude and others added 10 commits June 29, 2026 11:38
Drops the always-on overflow-y: scroll from .loc-container .location so the locations view no longer shows a permanent scrollbar.

Ported from upstream Donkie#859 by @VeeBack.

Co-authored-by: VeeBack <VeeBack@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JqPtZvXQkraNt9ttEhLsBt
schedule_tasks scheduled the cyclic sync with DEFAULT_SYNC_INTERVAL instead of the user-configured sync_interval value, so the configured interval had no effect. Use sync_interval.

Ported from upstream Donkie#943 by @chruoss.

Co-authored-by: chruoss <chruoss@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JqPtZvXQkraNt9ttEhLsBt
Adds an allow_archived query parameter to the spool export endpoint, passed through to spool.find(allow_archived=...), which already supports it. Defaults to False to preserve existing behavior.

Ported from upstream Donkie#919 by @velzi.

Co-authored-by: velzi <velzi@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JqPtZvXQkraNt9ttEhLsBt
Adds a prometheus_client Info metric exposing version, commit and build_date so build provenance is scrapeable.

Ported from upstream Donkie#877 by @sw1nn.

Co-authored-by: sw1nn <sw1nn@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JqPtZvXQkraNt9ttEhLsBt
README documentation only.

Ported from upstream Donkie#890 by @Disane87.

Co-authored-by: Disane87 <Disane87@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JqPtZvXQkraNt9ttEhLsBt
Adds a container HEALTHCHECK that probes /api/v1/health (which exists) using the bundled Python interpreter, plus a sample docker-compose.yml.

Ported from upstream Donkie#908 by @meek2100.

Co-authored-by: meek2100 <meek2100@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JqPtZvXQkraNt9ttEhLsBt
Adds an axios response interceptor that reloads the SPA on 401 for idempotent requests (with a cooldown and service-worker unregister) so forward-auth proxies can re-run their login flow.

Ported from upstream Donkie#924 by @sherrmann.

Co-authored-by: sherrmann <sherrmann@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JqPtZvXQkraNt9ttEhLsBt
Wires the existing comma-aware formatNumberOnUserInput / numberParser(AllowEmpty) helpers into the remaining InputNumber fields across filaments, spools, vendors, printing, extra fields and settings.

Ported from upstream Donkie#948 by @nkgotcode.

Co-authored-by: nkgotcode <nkgotcode@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JqPtZvXQkraNt9ttEhLsBt
Regenerates client/package-lock.json to pull the security/patch bumps from
the upstream dependabot PRs. uuid required a major bump (only used via the
stable `v4` export). Resulting versions meet or exceed each PR's target:

  uuid 13 -> 14.0.1                              (Donkie#927)
  axios -> 1.18.1                                (Donkie#928)
  vite -> 7.3.6                                  (Donkie#906)
  i18next-http-backend -> 3.0.6                  (Donkie#920)
  qs -> 6.14.2                                   (Donkie#850)
  minimatch (transitive bump)                    (Donkie#873)
  flatted -> 3.4.2                               (Donkie#889)
  handlebars -> 4.7.9                            (Donkie#894)
  lodash-es -> 4.18.1                            (Donkie#901)
  lodash -> 4.18.1                               (Donkie#909)
  follow-redirects -> 1.16.0                     (Donkie#914)
  fast-uri -> 3.1.2                              (Donkie#930)
  @babel/plugin-transform-modules-systemjs 7.29.7 (Donkie#931)

Verified with `npm run build` (tsc typecheck + refine/vite build).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JqPtZvXQkraNt9ttEhLsBt
… bumps)

Bumps two transitive dependencies in uv.lock to the security/patch versions
targeted by the upstream dependabot PRs:

  cryptography 46.0.3 -> 46.0.7                  (Donkie#907)
  mako 1.3.10 -> 1.3.12                          (Donkie#929)

Pinned to the dependabot targets rather than the newest available
(cryptography 49.x) to keep the change to a patch-level security update.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JqPtZvXQkraNt9ttEhLsBt
Copilot AI review requested due to automatic review settings June 29, 2026 11:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances Spoolman’s resilience behind forward-auth proxies by adding an automatic reload-on-401 handler in the web client, and improves numeric input UX by applying consistent formatting/parsing across multiple UI surfaces. It also adds build metadata to Prometheus metrics, expands the export API, fixes an external DB sync scheduling bug, and includes Docker healthcheck + compose example alongside dependency updates.

Changes:

  • Add a client-side Axios 401 interceptor to reload on idempotent requests (GET/HEAD) with cooldown and service worker unregistration.
  • Standardize numeric input formatting/parsing across forms and dialogs (spools/filaments/vendors, printing, extra fields, number ranges).
  • Add Prometheus build info metric, extend spool export with allow_archived, fix external DB sync interval scheduling, and improve container operability (HEALTHCHECK + compose).

Reviewed changes

Copilot reviewed 23 out of 25 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
uv.lock Updates Python dependency lock entries (e.g., cryptography, mako).
spoolman/prometheus/metrics.py Adds BUILD_INFO Prometheus Info metric.
spoolman/main.py Logs build metadata consistently and populates BUILD_INFO at startup.
spoolman/externaldb.py Fixes scheduler to honor configured external DB sync_interval.
spoolman/api/v1/export.py Adds allow_archived query parameter to spool export endpoint.
README.md Adds link to an MCP Server integration project.
Dockerfile Adds an API responsiveness HEALTHCHECK honoring port/base path env vars.
docker-compose.yml Adds a simple example compose file for local deployment.
client/src/utils/authReloadHandler.ts New 401 reload handler via Axios interceptor with cooldown + SW unregister.
client/src/index.tsx Imports auth reload handler for global initialization.
client/src/components/inputNumberRange.tsx Improves range input handling and applies shared formatter/parser.
client/src/components/extraFields.tsx Applies number formatting/parsing for float extra fields.
client/src/pages/settings/extraFieldsSettings.tsx Applies number formatting/parsing in extra field settings editor.
client/src/pages/printing/printingDialog.tsx Applies number formatting/parsing to printing numeric inputs.
client/src/pages/printing/qrCodePrintingDialog.tsx Applies number formatting/parsing to QR printing numeric inputs.
client/src/pages/vendors/edit.tsx Applies number formatting/parsing to vendor numeric inputs.
client/src/pages/vendors/create.tsx Applies number formatting/parsing to vendor numeric inputs.
client/src/pages/spools/functions.tsx Applies number formatting/parsing to spool adjustment modal numeric input.
client/src/pages/spools/edit.tsx Applies number formatting/parsing to spool edit numeric inputs.
client/src/pages/spools/create.tsx Applies number formatting/parsing to spool create numeric inputs.
client/src/pages/filaments/edit.tsx Applies number formatting/parsing to filament edit numeric inputs.
client/src/pages/filaments/create.tsx Applies number formatting/parsing to filament create numeric inputs.
client/src/pages/locations/locations.css Removes overflow-y: scroll to avoid layout issues.
client/package.json Bumps uuid dependency to ^14.0.0.
client/package-lock.json Updates lockfile to reflect dependency upgrades (incl. transitive).
Files not reviewed (1)
  • client/package-lock.json: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread client/src/pages/printing/printingDialog.tsx
Comment thread client/src/utils/authReloadHandler.ts Outdated
Comment thread client/src/components/inputNumberRange.tsx
- numberFormatter: render a legitimate 0 as "0" instead of a blank field.
  The previous truthiness check formatted 0 as an empty string, so inputs
  where 0 is common (printing margins/spacing) looked blank / like state
  loss when not focused. Now only undefined/empty/non-finite values blank out.
- InputNumberRange.parseInputNumberValue: parse string values (antd typings
  allow them, e.g. stringMode) instead of dropping them to null, while still
  treating empty/null as a deliberate clear.
- authReloadHandler: guard the axios response interceptor against
  double-registration. Vite/React fast refresh can re-evaluate the module and
  stack duplicate interceptors, firing multiple reloads per 401; the flag now
  lives on the shared axios instance so it survives module re-evaluation.

Verified with npm run build (tsc typecheck + vite build) and prettier.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JqPtZvXQkraNt9ttEhLsBt
@sherrmann sherrmann closed this Jun 29, 2026
@sherrmann sherrmann reopened this Jun 29, 2026
The Prometheus BUILD_INFO block (ported from upstream Donkie#877)
wasn't ruff-format compliant, failing the `style` job's `ruff format --check`.
Wrap the BUILD_INFO.info({...}) dict argument per ruff's formatting. No
behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JqPtZvXQkraNt9ttEhLsBt
@sherrmann

Copy link
Copy Markdown
Owner Author

Superseded by #2 (claude/merge-upstream-features), which contains all of this branch's commits and is now merged to master. Closing as delivered.

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.

3 participants