Compare commits

..

2 Commits

Author SHA1 Message Date
CodeRabbit Fixer
c98a687ae5 fix: Optimize histogramToPath percentile calculation with QuickSelect algorithm (#9109)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 19:09:38 +01:00
AustinMroz
55b8236c8d Fix localization on share and hide entry (#9395)
A placeholder share entry was added in #9368, but the localization for
this share label was then removed in #9361.

This localization is re-added in a location that is less likely to be
overwritten and the menu item is set to hidden. I'll manually connect it
to the workflow sharing feature flag in a followup PR after that has
been merged.

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-9395-Fix-localization-on-share-and-hide-entry-3196d73d36508146a343f625a5327bdd)
by [Unito](https://www.unito.io)
2026-03-06 09:35:18 -08:00
4 changed files with 40 additions and 17 deletions

View File

@@ -84,6 +84,30 @@ export function createMonotoneInterpolator(
}
}
function quickSelect(arr: Uint32Array, k: number): number {
let lo = 0
let hi = arr.length - 1
while (lo < hi) {
const pivot = arr[hi]
let i = lo
for (let j = lo; j < hi; j++) {
if (arr[j] <= pivot) {
const tmp = arr[i]
arr[i] = arr[j]
arr[j] = tmp
i++
}
}
const tmp = arr[i]
arr[i] = arr[hi]
arr[hi] = tmp
if (i === k) return arr[i]
else if (i < k) lo = i + 1
else hi = i - 1
}
return arr[lo]
}
/**
* Convert a 256-bin histogram into an SVG path string.
* Normalizes using the 99.5th percentile to avoid outlier spikes.
@@ -91,8 +115,8 @@ export function createMonotoneInterpolator(
export function histogramToPath(histogram: Uint32Array): string {
if (!histogram.length) return ''
const sorted = Array.from(histogram).sort((a, b) => a - b)
const max = sorted[Math.floor(255 * 0.995)]
const copy = new Uint32Array(histogram)
const max = quickSelect(copy, Math.floor(255 * 0.995))
if (max === 0) return ''
const invMax = 1 / max

View File

@@ -12,7 +12,6 @@ interface UseCurveEditorOptions {
export function useCurveEditor({ svgRef, modelValue }: UseCurveEditorOptions) {
const dragIndex = ref(-1)
let cleanupDrag: (() => void) | null = null
let cachedInverseCTM: DOMMatrix | null = null
const curvePath = computed(() => {
const points = modelValue.value
@@ -32,14 +31,16 @@ export function useCurveEditor({ svgRef, modelValue }: UseCurveEditorOptions) {
return parts.join('')
})
function svgCoords(
e: PointerEvent,
inverseCTM?: DOMMatrix | null
): [number, number] {
const inv = inverseCTM ?? svgRef.value?.getScreenCTM()?.inverse()
if (!inv) return [0, 0]
function svgCoords(e: PointerEvent): [number, number] {
const svg = svgRef.value
if (!svg) return [0, 0]
const svgPt = new DOMPoint(e.clientX, e.clientY).matrixTransform(inv)
const ctm = svg.getScreenCTM()
if (!ctm) return [0, 0]
const svgPt = new DOMPoint(e.clientX, e.clientY).matrixTransform(
ctm.inverse()
)
return [
Math.max(0, Math.min(1, svgPt.x)),
Math.max(0, Math.min(1, 1 - svgPt.y))
@@ -99,12 +100,11 @@ export function useCurveEditor({ svgRef, modelValue }: UseCurveEditorOptions) {
const svg = svgRef.value
if (!svg) return
cachedInverseCTM = svg.getScreenCTM()?.inverse() ?? null
svg.setPointerCapture(e.pointerId)
const onMove = (ev: PointerEvent) => {
if (dragIndex.value < 0) return
const [x, y] = svgCoords(ev, cachedInverseCTM)
const [x, y] = svgCoords(ev)
const movedPoint: CurvePoint = [x, y]
const newPoints = [...modelValue.value]
newPoints[dragIndex.value] = movedPoint
@@ -116,7 +116,6 @@ export function useCurveEditor({ svgRef, modelValue }: UseCurveEditorOptions) {
const endDrag = () => {
if (dragIndex.value < 0) return
dragIndex.value = -1
cachedInverseCTM = null
svg.removeEventListener('pointermove', onMove)
svg.removeEventListener('pointerup', endDrag)
svg.removeEventListener('lostpointercapture', endDrag)

View File

@@ -189,11 +189,10 @@ export function useWorkflowActionsMenu(
addItem({
id: 'share',
label: t('menuLabels.Share'),
label: t('breadcrumbsMenu.share'),
icon: 'icon-[comfy--send]',
command: async () => {},
disabled: true,
visible: isRoot
visible: false
})
addItem({

View File

@@ -2604,7 +2604,8 @@
"deleteWorkflow": "Delete Workflow",
"deleteBlueprint": "Delete Blueprint",
"enterNewName": "Enter new name",
"missingNodesWarning": "Workflow contains unsupported nodes (highlighted red)."
"missingNodesWarning": "Workflow contains unsupported nodes (highlighted red).",
"share": "Share"
},
"shortcuts": {
"shortcuts": "Shortcuts",