Add auth reload handler and improve number input formatting - #1
Add auth reload handler and improve number input formatting#1sherrmann wants to merge 12 commits into
Conversation
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
There was a problem hiding this comment.
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.
- 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
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
|
Superseded by #2 (claude/merge-upstream-features), which contains all of this branch's commits and is now merged to master. Closing as delivered. |
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
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
formatNumberOnUserInputandnumberParser/numberParserAllowEmptyutilities:Backend Improvements
BUILD_INFOmetric to expose build information (version, commit, build date)allow_archivedquery parameter to spool export endpoint to control inclusion of archived spoolssync_intervalinstead ofDEFAULT_SYNC_INTERVALInfrastructure & DevOps
docker-compose.ymlfor easy local deploymentUI/UX Fixes
overflow-y: scrollthat could cause layout issuesInputNumberRangecomponent with proper type conversionDependencies
uuidfrom ^13.0.0 to ^14.0.0Implementation Details
https://claude.ai/code/session_01JqPtZvXQkraNt9ttEhLsBt