Skip to content

feat: add Custom resolution mode#2

Merged
Zhen-Bo merged 8 commits into
masterfrom
feat/custom-resolution
Jul 3, 2026
Merged

feat: add Custom resolution mode#2
Zhen-Bo merged 8 commits into
masterfrom
feat/custom-resolution

Conversation

@Zhen-Bo

@Zhen-Bo Zhen-Bo commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

Add Custom resolution mode to QuickLatent so users can enter explicit output dimensions while keeping backend and frontend calculations aligned.

Changes

  • Add Custom resolution handling in the Python node, including validation, clamping, and latent-size calculation.
  • Add frontend custom width/height controls and inline editing behavior for the Size row.
  • Mirror backend custom-size behavior in client-side preview/layout calculations.
  • Add Python and Node test coverage for custom resolution behavior and layout edge cases.

Verification

  • python -m pytest - 514 passed
  • npm test - 21 passed

Impact

Breaking changes: None
User-facing changes: Adds Custom resolution mode and editable custom Size controls
Migration required: None

Zhen-Bo added 8 commits July 3, 2026 23:46
- Add "Custom" as a 4th resolution combo value (D-02)
- Add custom_width/custom_height INT inputs (default 1024, min 512,
  max 4096, step 8), appended at the END of required for saved-workflow
  back-compat (D-03/D-04)
- Add calculate_custom_dimensions() helper: clamp to [512, 4096] then
  round8(value / scale_factor) per axis, no orientation swap (D-01/D-05/D-06)
- Add CUSTOM_DIMENSION_MIN/MAX module constants shared by INPUT_TYPES and
  the helper so widget bounds and clamp bounds cannot drift
- generate() gains defaulted custom_width/custom_height params and dispatches
  to the custom helper when resolution == "Custom"; preset path unchanged
- Update test_resolution_combo assertion for the new Custom value
Add tests/test_custom_resolution.py covering the locked D-01..D-06 decisions:
- D-01: round8(custom / scale_factor) per axis (target -> scale-divided)
- D-05: clamp to [512, 4096] then round up to 8; below-min/zero/above-max and
  non-8 inputs never raise; parametric divisible-by-8 spread
- D-06: Custom generate() output identical under Landscape and Portrait (no swap)
- Integration: 5-tuple outputs + LATENT tensor shape (1, 4, 64, 128)
- D-02/D-03/D-04: preset back-compat without custom args + INPUT_TYPES widget config
- calculateCustomDimensions parity with nodes.py (clamp [512,4096], round8(value/scale), no swap)
- getCustomTargetDimensions achievable-target math (output x scale, D-09)
- getSizeBoxClickAction W/H box hit-test incl. central-gap null
- config.js: add "Custom" to RESOLUTIONS; CUSTOM_MIN/MAX; calculateCustomDimensions
  + getCustomTargetDimensions mirroring nodes.py exactly (clamp [512,4096], round8,
  no orientation swap)
- draw.js: drawSize renders two 26px W/H boxes + central × and registers
  controls.sizeW/sizeH
- layout.js: getSizeBoxClickAction hit-test; CUSTOM_CONTROLS_HEIGHT stays 294
- new js/size_input.js exports openSizeInput({ node, box, localPos, event, value, min, max, onCommit })
- positions a fixed <input> over the box via the VERIFIED transform
  (rect + (node.pos + box + ds.offset) * ds.scale; no devicePixelRatio term)
- built with createElement + .value/.style only (ASVS V5; no innerHTML interpolation)
- deferred focus in setTimeout(0) to beat LiteGraph's canvas.focus()
- integer-only keydown filter + stopPropagation; Enter/blur/wheel commit idempotently
  (done guard) with [min,max] clamp; Esc cancels
- find + hide custom_width/custom_height widgets; customWidthVal/customHeightVal
  state that persists across preset<->Custom switches (D-12)
- recalculate() custom branch drives live Target panel + output-port labels (D-09)
- onDrawForeground swaps the Aspect-Ratio row for a Size row (label + drawSize) at
  the identical y-cadence -> no vertical jump (CUST-02/CUST-03)
- onMouseDown: Size-box hit-test opens openSizeInput; ratio hit-test guarded to
  preset mode; Portrait/Landscape swaps custom W/H (CUST-04/D-06)
- syncToHidden serializes custom_width/custom_height; onConfigure restores them for
  workflow save/load (CUST-05)
Custom width/height are now the raw output (latent) size: the node emits
exactly the entered dimensions (8-aligned) and scale is display-only
(UI target = output x scale). Reverses the earlier target-then-divide
semantics after Phase 5 UAT. Backend calculate_custom_dimensions drops the
scale divide; the config.js client mirror and both test suites are updated.
Inset the transient inline input symmetrically (both sides) so it stays
centred on the box: its centre matches the drawn value's centre, so the
number no longer shifts when the editor opens, while the left strip keeps
the faint W/H hint visible.
@Zhen-Bo
Zhen-Bo merged commit 1f26f70 into master Jul 3, 2026
1 check passed
@Zhen-Bo
Zhen-Bo deleted the feat/custom-resolution branch July 3, 2026 18:26
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.

1 participant