Commit Graph
3662 Commits
Author SHA1 Message Date
maziggy 914cbffdcd Show the Print Log's per-run cost and energy, and let users pick columns (#2636)
The list and update endpoints serialised field by field and never named
    cost / energy_kwh / energy_cost, so values Bambuddy had been recording
    all along went out as nulls. Both now validate from the ORM row, which
    removes the chance to omit a field rather than patching the three that
    were missing.

    Adds a Filament Used column plus a Columns picker for Cost, Energy,
    Energy Cost and Finished, persisted per browser.

    Also fixes the log view being unreachable with zero archives: the empty
    state ran before the view check, hiding a log that outlives the archives
    it refers to.

    ---

    Sort the Print Log by any column (#2636)

    Adds sort_by / sort_dir to the print-log endpoint, driven by clickable
    column headers. Server-side because paging is: ordering the rows the
    client holds would sort one page rather than the log.

    Empty values are held last in both directions — Postgres sorts NULLs
    high and SQLite low, so the same click would otherwise open on blanks
    on one backend and values on the other. id DESC breaks ties so paging
    through a low-cardinality sort can't repeat or skip a row.
2026-08-15 14:03:18 +02:00
maziggy 67e8a78cb8 Add auto-orient and auto-arrange to server-side slicing (#2548)
Both are per-slice checkboxes, off by default, forwarded as the sidecar's
    orient / arrange form fields. An unticked box is sent by omission: the
    sidecar treats any present value as truthy, so a literal "false" would
    have arranged every slice.

    Arrange unions with the #1493 cross-class decision rather than replacing
    it, and the per-plate slice-all loop is now keyed on the arrange flag
    itself — the project-wide collapse belongs to --arrange, not to the
    cross-class case. The loop also covers the embedded-settings path, whose
    crash-retry is suppressed there since a single --slice 0 retry would
    return one consolidated plate.
2026-08-15 14:02:31 +02:00
maziggy bbc2e9d0b8 Merge pull request #2610 from Person2099/feature/upload-prefer-filename-for-name
Expose prefer_filename_for_name on manual archive upload endpoint
2026-08-15 14:01:29 +02:00
maziggy 06d898f0a9 Document prefer_filename_for_name in the OpenAPI schema
The param was a bare bool, so /docs showed an undocumented boolean on
    both upload routes. #2609 is about external integrations, and the
    interactive docs are where those callers look — a docstring only reaches
    someone reading the source. Wraps both in Query(False, description=...),
    matching how this file documents its other query params.

    Also records why these two routes take the flag per-request while the FTP
    review flow and virtual-printer dispatch derive it from the VP-scoped
    virtual_printer_archive_name_source setting, and drops the db_session
    fixture the four new tests requested but never used.
2026-08-15 14:01:14 +02:00
maziggy f38a278f65 Merge branch 'dev' into feature/upload-prefer-filename-for-name 2026-08-15 14:00:59 +02:00
maziggy 7ecd190f8b Raise the chamber-temperature ceiling from 60 to 65 C
Every field that takes a chamber target stopped at 60: the per-filament
    chamber map and per-print override in Preheat & Heat Soak, the chamber
    quick-select presets, and the printer-card chamber control. 60 is the
    X1E's ceiling and the X1E was the only heated-chamber model when that
    limit was written; the H2 series and X2D heat to 65, so the top of their
    range was unreachable.

    The ceiling now lives in one constant per side (MAX_CHAMBER_TEMP_C in
    backend/app/utils/printer_models.py and frontend/src/utils/printer.ts)
    rather than as a literal at each call site. X1E firmware clamps a higher
    request to its own maximum, so a shared ceiling is safe.

    Also fixes a live bug at PrintersPage.tsx:7985: parsePresetTriple was
    bounded to 60 there, and it rejects the whole triple on any out-of-range
    entry, so a saved 65 preset would have silently reverted the printer
    card to the defaults while Settings still showed 65.
2026-08-15 14:00:43 +02:00
maziggy a8378b0e0e Merge remote-tracking branch 'upstream/dev' into feature/upload-prefer-filename-for-name 2026-08-15 14:00:15 +02:00
maziggy be090f4e26 Merge remote-tracking branch 'origin/feature/upload-prefer-filename-for-name' into feature/upload-prefer-filename-for-name 2026-08-15 13:59:19 +02:00
maziggy bd6ad1a338 feat: expose prefer_filename_for_name on bulk archive upload too
Maintainer review on #2610 flagged that upload-bulk would diverge from
    upload if only the single-file route got the flag. Applies to every
    file in the batch, same default-off behavior.
2026-08-15 13:59:07 +02:00
maziggy a08d3e62f3 Show the Print Log's per-run cost and energy, and let users pick columns (#2636)
The list and update endpoints serialised field by field and never named
cost / energy_kwh / energy_cost, so values Bambuddy had been recording
all along went out as nulls. Both now validate from the ORM row, which
removes the chance to omit a field rather than patching the three that
were missing.

Adds a Filament Used column plus a Columns picker for Cost, Energy,
Energy Cost and Finished, persisted per browser.

Also fixes the log view being unreachable with zero archives: the empty
state ran before the view check, hiding a log that outlives the archives
it refers to.

---

Sort the Print Log by any column (#2636)

Adds sort_by / sort_dir to the print-log endpoint, driven by clickable
column headers. Server-side because paging is: ordering the rows the
client holds would sort one page rather than the log.

Empty values are held last in both directions — Postgres sorts NULLs
high and SQLite low, so the same click would otherwise open on blanks
on one backend and values on the other. id DESC breaks ties so paging
through a low-cardinality sort can't repeat or skip a row.
2026-08-03 14:53:21 +02:00
maziggy e95c42c021 Add auto-orient and auto-arrange to server-side slicing (#2548)
Both are per-slice checkboxes, off by default, forwarded as the sidecar's
orient / arrange form fields. An unticked box is sent by omission: the
sidecar treats any present value as truthy, so a literal "false" would
have arranged every slice.

Arrange unions with the #1493 cross-class decision rather than replacing
it, and the per-plate slice-all loop is now keyed on the arrange flag
itself — the project-wide collapse belongs to --arrange, not to the
cross-class case. The loop also covers the embedded-settings path, whose
crash-retry is suppressed there since a single --slice 0 retry would
return one consolidated plate.
2026-08-03 14:10:02 +02:00
maziggy 78fc5aab75 Updated CHANGELOG 2026-08-03 12:41:38 +02:00
maziggy ea63355fde Fix cross-model queue items being misrepresented and editable into a broken state (#671)
The edit dialog offered a printer picker and target-model dropdown for
an item with alternatives. Saving left a row with variants AND a
printer_id, and the scheduler's fixed-printer branch wins that race, so
it dispatched a row whose library_file_id is still null and failed in
the upload. PATCH now refuses printer/model changes on such an item —
comparing against the current value, since the dialog re-sends
target_model unchanged — and the route eager-loads variants, without
which the guard could not see them and every PATCH response dropped the
alternatives from its payload.

Names come from a shared helper now. A cross-model item holds neither
archive_id nor library_file_id until dispatch, so five separate inlined
fallbacks all rendered "File #null"; they now read "x1c.gcode.3mf +1
more".

The queue also grouped these under "Any H2D" — the first candidate
mirrored onto the row — filing a job under a printer it might never run
on. It groups as "Any H2D / X1C", matching the row beneath it.
2026-08-03 12:33:19 +02:00
maziggy ef7c1b21f1 Add cross-model print alternatives to the File Manager and print modal (#671, #2570)
Selecting several sliced files and pressing Print now creates one queue
item carrying all of them, instead of hiding the Print button the moment
a second file is selected. The printer picker is replaced by the ordered
candidate list, since choosing these files is already the answer to
"which printer" and the only question left is which is preferred.

Per-candidate configuration is the plate only. Model-based assignment
sends no AMS mapping — the printer is unknown until dispatch, where the
scheduler derives it — so a per-candidate mapping editor would collect
choices it then discards. Filament overrides stay shared: "this job
needs PETG" holds for every slice of the same job.

Adds Group as versions for durable grouping, a versions badge counting
the whole group rather than the rows on screen, and a queue card label
naming every model a pending item is waiting on.
2026-08-03 11:33:39 +02:00
maziggy a9b57ccd3c Add variant-group endpoints and cross-model queue creation (#671, #2570)
Adds /library/variant-groups for declaring that several sliced files are
the same job for different printers, and a variants payload on queue
creation that turns such a set into one queue item with a candidate per
file.

The candidate set is validated as a set: one file per printer model, each
file sliced for the model it is offered as, and at least one model with
an active printer. A cross-model item deliberately holds no file of its
own, because print_queue.library_file_id is ON DELETE CASCADE and would
destroy the whole job when a single alternative is deleted.

Fixes internal printer-model codes never being resolved on queue create
and update: normalize_printer_model returns unknown input unchanged, so
the or-chain never reached the code map and a "C13" target matched no
printer and waited forever.

Skips candidates whose file is trashed or missing. Library deletes are
soft, and SQLite runs with PRAGMA foreign_keys off, so neither case is
covered by the schema; the hard-delete paths now also drop the rows.

Adds library_files.variant_target_model so a user can say which printer
a file without slicer metadata is for, kept out of file_metadata so the
assertion is never mistaken for parsed data.
2026-08-03 11:10:11 +02:00
maziggy 752e345d1a Add cross-model variant resolution to the queue scheduler (#671)
Adds print_queue_variants: the candidate files a queue item may run, each
with its own model, plate, AMS mapping and nozzle mapping. The scheduler
walks them in priority order and takes the first whose model has an idle
printer, then folds that candidate onto the queue row before the
selection commit — so upload, archive creation, print history and reprint
keep seeing an ordinary single-file item.

Candidates are ordered least-attempted first, so a printer that accepts
the file and never starts hands the job to the alternative on the next
lap instead of spending the item's whole retry budget on the machine
that is wedged. The item-level DISPATCH_MAX_ATTEMPTS bound is unchanged.

An item whose candidate files have all been deleted is held pending with
an actionable reason rather than failing deep in the upload, and waiting
notifications name the job and every model it is waiting on.
2026-08-03 10:54:45 +02:00
maziggy da07c5884b Add variant-group data model for cross-model queue alternatives (#671)
Adds file_variant_groups plus variant_group_id / variant_position on
library_files, so a set of files that are the same job sliced for
different printers can be resolved to whichever printer frees up first.

Backfills groups from the sliced_from_library_file_id provenance that
slice_and_persist and the pipeline runner have been writing into
file_metadata since they shipped, and which nothing has ever read.
Only sources with two or more children carrying distinct
sliced_for_model values are grouped: a single candidate is not a
choice, and two slices for the same printer give the resolver no basis
to prefer one.
2026-08-03 10:17:28 +02:00
maziggy b2f84cd37f Updated CHANGELOG 2026-08-03 09:07:03 +02:00
MartinNYHC 797856bcf9 Merge pull request #2610 from Person2099/feature/upload-prefer-filename-for-name
Expose prefer_filename_for_name on manual archive upload endpoint
2026-08-03 09:04:56 +02:00
maziggy dd541b20a8 Document prefer_filename_for_name in the OpenAPI schema
The param was a bare bool, so /docs showed an undocumented boolean on
both upload routes. #2609 is about external integrations, and the
interactive docs are where those callers look — a docstring only reaches
someone reading the source. Wraps both in Query(False, description=...),
matching how this file documents its other query params.

Also records why these two routes take the flag per-request while the FTP
review flow and virtual-printer dispatch derive it from the VP-scoped
virtual_printer_archive_name_source setting, and drops the db_session
fixture the four new tests requested but never used.
2026-08-03 09:04:29 +02:00
MartinNYHC 5d1cd943fd Merge branch 'dev' into feature/upload-prefer-filename-for-name 2026-08-03 08:54:09 +02:00
maziggy b04664c64a Raise the chamber-temperature ceiling from 60 to 65 C
Every field that takes a chamber target stopped at 60: the per-filament
chamber map and per-print override in Preheat & Heat Soak, the chamber
quick-select presets, and the printer-card chamber control. 60 is the
X1E's ceiling and the X1E was the only heated-chamber model when that
limit was written; the H2 series and X2D heat to 65, so the top of their
range was unreachable.

The ceiling now lives in one constant per side (MAX_CHAMBER_TEMP_C in
backend/app/utils/printer_models.py and frontend/src/utils/printer.ts)
rather than as a literal at each call site. X1E firmware clamps a higher
request to its own maximum, so a shared ceiling is safe.

Also fixes a live bug at PrintersPage.tsx:7985: parsePresetTriple was
bounded to 60 there, and it rejects the whole triple on any out-of-range
entry, so a saved 65 preset would have silently reverted the printer
card to the defaults while Settings still showed 65.
2026-08-03 08:52:23 +02:00
Sebastian Keet 492d7f27c7 Merge remote-tracking branch 'upstream/dev' into feature/upload-prefer-filename-for-name 2026-08-02 23:14:07 +10:00
Sebastian Keet 0905e374db Merge remote-tracking branch 'origin/feature/upload-prefer-filename-for-name' into feature/upload-prefer-filename-for-name 2026-08-02 23:09:28 +10:00
Sebastian Keet 93443ed7c6 feat: expose prefer_filename_for_name on bulk archive upload too
Maintainer review on #2610 flagged that upload-bulk would diverge from
upload if only the single-file route got the flag. Applies to every
file in the batch, same default-off behavior.
2026-08-02 23:06:50 +10:00
maziggy ad375f6ca7 Housekeeping 2026-08-02 12:29:32 +02:00
maziggy 6484fddc1a Stop the Bambu Cloud TOTP tests reaching the network
verify_totp fetches a CSRF token from the bambulab.com web origin before
posting the code (#2696) and returns early when it cannot get one. These
tests patch only post, so the pre-flight GET went out for real: it succeeded
wherever bambulab.com was reachable and returned a tokenless 403 on a CI
runner, where six tests then asserted on a post that never happened.

Stub the handshake for the module. It is covered end to end, no-token path
included, in tests/unit/test_cloud_totp_csrf.py.
2026-08-02 11:46:03 +02:00
maziggy e52b73e21f Stop the Bambu Cloud TOTP tests reaching the network
verify_totp fetches a CSRF token from the bambulab.com web origin before
posting the code (#2696) and returns early when it cannot get one. These
tests patch only post, so the pre-flight GET went out for real: it succeeded
wherever bambulab.com was reachable and returned a tokenless 403 on a CI
runner, where six tests then asserted on a post that never happened.

Stub the handshake for the module. It is covered end to end, no-token path
included, in tests/unit/test_cloud_totp_csrf.py.
2026-08-02 11:45:53 +02:00
maziggy bbbb9d35c7 Bound the scheme repetition in the log credential-redaction pattern. As an
unbounded repetition the match was quadratic in the subject length: on a run
of scheme-legal characters the engine restarted at every offset and consumed
to the end before failing to find "://". ffmpeg echoes the configured camera
URL into its stderr and the whole blob reaches the pattern before any
truncation, so the subject length is attacker-influenced.
2026-08-02 11:17:49 +02:00
maziggy 3da4eee16e Bound the scheme repetition in the log credential-redaction pattern. As an
unbounded repetition the match was quadratic in the subject length: on a run
of scheme-legal characters the engine restarted at every offset and consumed
to the end before failing to find "://". ffmpeg echoes the configured camera
URL into its stderr and the whole blob reaches the pattern before any
truncation, so the subject length is attacker-influenced.
2026-08-02 11:17:24 +02:00
MartinNYHC 8be3413fbd Merge branch 'main' into dev 2026-08-02 11:10:25 +02:00
maziggy bf424493ba Suppress Bandit B104 false positive in the SSRF guard tests
The parametrize list feeds "0.0.0.0" to TasmotaService._validate_ip and
asserts it is refused. B104 matches the literal wherever it occurs and
cannot distinguish a rejection fixture from a bind address.

Split the list across lines so the token carries its own nosec with the
reason; the single-line form was 117 chars against a 120 limit.
2026-08-02 11:09:32 +02:00
maziggy 3b5d219860 Suppress Bandit B104 false positive in the SSRF guard tests
The parametrize list feeds "0.0.0.0" to TasmotaService._validate_ip and
asserts it is refused. B104 matches the literal wherever it occurs and
cannot distinguish a rejection fixture from a bind address.

Split the list across lines so the token carries its own nosec with the
reason; the single-line form was 117 chars against a 120 limit.
2026-08-02 11:09:08 +02:00
MartinNYHC 81ee7658f5 Merge branch 'main' into 1.2.5.2 2026-08-02 11:04:26 +02:00
maziggy d3770b5463 Updated CHANGELOG 2026-08-02 11:01:19 +02:00
maziggy 9e18ff7fa0 Updated CHANGELOG 2026-08-02 10:56:51 +02:00
maziggy f5580914af Updated CHANGELOG 2026-08-02 10:52:21 +02:00
maziggy ab4b34e203 Updated CHANGELOG 2026-08-02 10:51:32 +02:00
maziggy f52cebd319 yyUpdated CHANGELOG 2026-08-02 10:50:01 +02:00
maziggy feec283c2a Updated CHANGELOG 2026-08-02 10:46:27 +02:00
maziggy 77135aaf8f Fix unawaited coroutine warning in printer offline notification tests
on_printer_status_change builds reconcile_stale_active_prints(...) as a
call argument, so the coroutine is constructed even when the spawn helper
is mocked out. A bare MagicMock retained it in call_args and it finalised
unawaited during a later test's GC, surfacing as a
PytestUnraisableExceptionWarning attributed to test_printer_sensor_history.

Patch spawn_background_task with a side_effect that closes the coroutine,
and correct the _state() docstring, which claimed state="IDLE" kept the
reconcile-edge branch quiescent when it does the opposite.
2026-08-02 10:23:09 +02:00
maziggy 4cf3235fde Fix unawaited coroutine warning in printer offline notification tests
on_printer_status_change builds reconcile_stale_active_prints(...) as a
call argument, so the coroutine is constructed even when the spawn helper
is mocked out. A bare MagicMock retained it in call_args and it finalised
unawaited during a later test's GC, surfacing as a
PytestUnraisableExceptionWarning attributed to test_printer_sensor_history.

Patch spawn_background_task with a side_effect that closes the coroutine,
and correct the _state() docstring, which claimed state="IDLE" kept the
reconcile-edge branch quiescent when it does the opposite.
2026-08-02 10:22:26 +02:00
maziggy 11184b4fd0 Post work PR #2740 2026-08-02 09:55:07 +02:00
maziggy 6c573589b5 Merge pull request #2740 from mpl1337/feature/queue-item-eta
Add per-job ETA to print queue
2026-08-02 09:54:54 +02:00
maziggy 4ff6377050 Fix per-job queue ETA showing for jobs that cannot start now
The scheduler only writes waiting_reason on the model-based assignment
    path, so a job pinned to a specific printer sits behind a running print
    with no marker at all. Every such job rendered an identical "starts now"
    ETA that was wrong by the length of everything ahead of it.

    Decide eligibility on the page instead: an item gets an ETA only when its
    printer is idle and it is the item the scheduler would dispatch next,
    following the same ordering the scheduler uses. Staged and future-
    scheduled items do not block the item behind them, matching the
    scheduler, and items conditional on a previous print are excluded.

    The value also froze at first render, since react-query's structural
    sharing keeps the queue reference stable and nothing re-rendered the row.
    formatETA now accepts a base instant and the page drives it from a 30s
    clock shared by every visible row.

    Retire the borrowed printers.estimatedCompletion tooltip for a queue key
    that says what the number means, translated into all 13 locales.
2026-08-02 09:54:41 +02:00
maziggy 234809fad1 Fix queued ETA visibility and add rendering tests 2026-08-02 09:54:29 +02:00
maziggy ab768a469f fix(settings): stop the Settings page reverting changes made elsewhere (issue #2716)
While the Settings page was mounted it held its own copy of every
    setting and synced it from the server exactly once, on first load
    (:887-900). A debounced effect then diffed the live ['settings']
    cache against that copy and PUT all 77 keys it manages on any
    difference, with no way to tell a user edit from a value that had
    changed on the server. Anything written server-side while the page
    sat open was silently reverted ~500ms later (#2716, reporter
    @jmoore-skild).

    No interaction was needed to trigger it. The query inherits a 60s
    staleTime and react-query's default refetchOnWindowFocus, and ~30
    other observers share the key, so a window refocus or a refetch from
    any of them moved the cache and the page wrote its page-load snapshot
    back over all 77 keys -- showing "Settings saved" while doing it.

    The page now tracks the last server snapshot it reconciled with. A
    field still equal to that baseline has not been touched since, so a
    newer server value is adopted; a field the user has edited keeps
    their value and is saved over the top, so the newer of the two writes
    wins either way. Typing into a text field while a refetch lands stays
    safe, which is what the previous behaviour was protecting -- an
    in-progress edit is by definition different from the baseline.

    The baseline is seeded from the raw server row rather than from the
    copy the page patches a browser-detected external_url into, so that
    detection still reads as a local change and is still persisted.

    The payload builder and the comparison key lists are unchanged. The
    diff simply measures against the baseline instead of the live cache,
    so no field can silently stop saving.

    Removing the adoption step was verified to reintroduce the revert,
    and removing the post-save baseline advance to reintroduce a resend
    loop; both are covered by frontend tests asserting on the request
    bodies rather than on rendered values.
2026-08-02 09:54:13 +02:00
maziggy c765d2f2fb fix(kprofiles): stop reporting rejected K-profile writes as saved
Saving a K-profile was fire-and-forget. set_kprofiles_batch published
    and returned True, and the printer's extrusion_cali_set answer was
    logged at DEBUG and dropped, so a write the printer refused was
    reported to the user as saved (#2718, reporter @jmoore-skild).

    The reason it could not simply be gated on: the answer itself was
    wrong. Single-nozzle firmware returned result:"fail" with
    reason:"invalid tray_id" on writes that demonstrably applied.
    Measured against an X1C and an H2D over MQTT, the cause is the
    tray_id:-1 Bambuddy itself put in the payload. Sending three
    otherwise identical writes isolated it: tray_id:-1 fails, tray_id:0
    succeeds, and cali_idx:-1 is accepted either way, so only that one
    field is at fault. The H2D ignores the value entirely; the X1C
    validates it, complains, and applies the write anyway. BambuStudio
    always sends a real tray_id and defaults it to 0 for a manually
    entered profile.

    With tray_id:0 the acknowledgement is honest, and the printer echoes
    back the sequence_id we sent -- confirmed for extrusion_cali_get,
    _set and _del on both printer classes -- so it can be matched to the
    write that caused it. Writes now return their sequence_id and the
    routes await the verdict, turning a real failure into an error that
    carries the printer's own reason. A printer that stays silent is
    still treated as success: no answer is not evidence of refusal, and
    firmware that never answers must not turn every save into an error.

    Raises the ack to INFO. It sat at DEBUG, so the one line that
    explains a failed save was absent from every support bundle -- the
    same reasoning that put ams_filament_drying at INFO for #1447.

    Also fixes extrusion_cali_set building its payload from
    str(self._sequence_id) without incrementing first, reusing the
    previous command's id. Harmless while nothing correlated on it,
    fatal now that the write path does.

    Adds supports_nozzle_flow_type() for the Standard / High Flow choice,
    which the K-Profiles UI previously showed as "Not reported by
    printer" -- not a value anyone can save. Most printers omit the
    nozzle identity from their calibration table entirely, and the slicer
    treats that as Standard rather than unknown; Bambuddy now does the
    same and keeps the choice editable. The field is hidden only where
    the model ships a single nozzle variant, using the slicer's own rule
    (len(nozzle_volume) // len(nozzle_diameter) > 1 over the machine
    preset) evaluated across every bundled Bambu profile. That puts only
    A1, A1 Mini and A2L on the hidden side -- it is not the single-
    versus-dual-nozzle split, since P1P, P1S, P2S, X1, X1C, X1E and H2S
    are all single-nozzle and all carry two variants. Editing a profile
    also no longer writes back an empty nozzle_id.

    Wiki records that on printers which omit the field the chosen flow
    type is discarded by the firmware and reads back as Standard, in
    Bambu Studio as well, so it does not get filed as a bug again.
2026-08-02 09:53:51 +02:00
maziggy 5bbb6a73cc fix(kprofiles): populate the filament picker from all preset tiers (issue #2719)
Add K-Profile built its Filament dropdown from the profiles already on
    the printer, so on a printer with none the field was empty, required
    and unsatisfiable (#2719, reporter @jmoore-skild). The modal's own
    hint described the dead end: create the profile in Bambu Studio first.

    The dropdown now uses the app-wide lookup order -- local imported,
    Orca Cloud, Bambu Cloud, hardcoded built-in table -- same as the AMS
    slot picker and the SliceModal tier groups. The built-in table is
    compiled into the backend, so the list can never be empty: a new
    printer with no cloud account and nothing imported still gets a first
    profile.

    Not fixed the way the report suggested. Seeding from
    /printers/available-filaments would have offered only what happens to
    be in an AMS right now, which on the reported printer is nothing; its
    tray_info_idx is empty or a cloud user preset rather than a filament
    id; it aggregates across every printer of the same model; and it is
    gated on QUEUE_CREATE, which the K-Profiles page does not hold.

    The printer indexes its calibration table by filament_id, so the
    picked preset is reduced to one before anything is sent. Built-in
    entries and Bambu official cloud presets carry one; a cloud user
    preset needs its detail fetched (never base_id -- that collapses a
    custom preset onto its inherited generic, #1053); imported and Orca
    presets have no Bambu id at all and take the closest generic for
    their material, via the same table the AMS slot configure flow uses
    so the two agree. A filament that resolves to nothing is refused with
    a named error rather than written under a wrong id.

    Collapses duplicates from two separate causes. A cloud account
    carries one copy of each filament per printer model, and with the
    "@BBL <model>" suffix stripped for display those rows are
    indistinguishable -- deduped within each tier by resolved filament id,
    by display name for user presets that have none. Cloud setting_ids
    also carry a "_NN" variant suffix, so the built-in tier's
    already-covered check never matched and listed the same filament
    again; the bare id is now recorded alongside.

    Groups the options by source with an optgroup per tier, styled in
    index.css: browsers render optgroup labels small, grey and italic,
    which buries the one thing distinguishing a "Bambu PLA Basic" you
    imported from the one the built-in table ships.

    Drops the second getKProfiles(printer, "0.4") query that existed only
    to seed the old dropdown. It ran concurrently with the main fetch
    whenever a non-0.4mm nozzle was selected -- the two-requests-in-flight
    case that made K-profile fetches time out.

    ---

    fix(ui): cancel a dialog's deferred close when it unmounts

    The AMS slot configure and K-Profile dialogs hold a success state
    briefly and then close themselves -- 1.5s to 4s after the command
    goes out, so the printer has time to process it before the list
    refetches. Each did that with a bare setTimeout closing over setState
    and the parent's onClose, and nothing cancelled it.

    The timer therefore ran whether or not the dialog was still there.
    Dismissing it inside that window, or the printer card re-rendering
    underneath it, left a pending close that fired later and dismissed
    whatever dialog was open by then. It also threw outright when the
    surrounding environment was gone first: a test tearing down its DOM
    before the 1.5s elapsed produced "ReferenceError: window is not
    defined" out of react-dom's resolveUpdatePriority, reported as an
    unhandled error against a suite that otherwise passed.

    Routes all five through a useCancellableTimeout hook -- two in
    ConfigureAmsSlotModal, three in KProfileModal, the latter with the
    longest windows and so the widest exposure. Scheduling replaces any
    pending timer and unmounting clears it.
2026-08-02 09:53:27 +02:00
maziggy 6b2c888a8b Add per-job ETA to print queue 2026-08-02 09:53:14 +02:00