-
Notifications
You must be signed in to change notification settings - Fork 374
Add node pinning functionality to Vue nodes #5772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ca9ddf8
add pinning functionality to vue nodes
christian-byrne 235eaa4
Update src/renderer/extensions/vueNodes/components/NodeHeader.vue
christian-byrne 86287ca
prevent node from being dragged while pinned
christian-byrne ce0675c
add browser test for pin drag behavior
christian-byrne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { | ||
comfyExpect as expect, | ||
comfyPageFixture as test | ||
} from '../../../fixtures/ComfyPage' | ||
|
||
const PIN_HOTKEY = 'p' | ||
const PIN_INDICATOR = '[data-testid="node-pin-indicator"]' | ||
|
||
test.describe('Vue Node Pin', () => { | ||
test.beforeEach(async ({ comfyPage }) => { | ||
await comfyPage.setSetting('Comfy.VueNodes.Enabled', true) | ||
await comfyPage.vueNodes.waitForNodes() | ||
}) | ||
|
||
test('should allow toggling pin on a selected node with hotkey', async ({ | ||
comfyPage | ||
}) => { | ||
await comfyPage.page.getByText('Load Checkpoint').click() | ||
await comfyPage.page.keyboard.press(PIN_HOTKEY) | ||
|
||
const checkpointNode = comfyPage.vueNodes.getNodeByTitle('Load Checkpoint') | ||
const pinIndicator = checkpointNode.locator(PIN_INDICATOR) | ||
|
||
await expect(pinIndicator).toBeVisible() | ||
|
||
await comfyPage.page.keyboard.press(PIN_HOTKEY) | ||
await expect(pinIndicator).not.toBeVisible() | ||
}) | ||
|
||
test('should allow toggling pin on multiple selected nodes with hotkey', async ({ | ||
comfyPage | ||
}) => { | ||
await comfyPage.page.getByText('Load Checkpoint').click() | ||
await comfyPage.page.getByText('KSampler').click({ modifiers: ['Control'] }) | ||
|
||
const checkpointNode = comfyPage.vueNodes.getNodeByTitle('Load Checkpoint') | ||
const ksamplerNode = comfyPage.vueNodes.getNodeByTitle('KSampler') | ||
|
||
await comfyPage.page.keyboard.press(PIN_HOTKEY) | ||
const pinIndicator1 = checkpointNode.locator(PIN_INDICATOR) | ||
await expect(pinIndicator1).toBeVisible() | ||
const pinIndicator2 = ksamplerNode.locator(PIN_INDICATOR) | ||
await expect(pinIndicator2).toBeVisible() | ||
|
||
await comfyPage.page.keyboard.press(PIN_HOTKEY) | ||
await expect(pinIndicator1).not.toBeVisible() | ||
await expect(pinIndicator2).not.toBeVisible() | ||
}) | ||
|
||
test('should not allow dragging pinned nodes', async ({ comfyPage }) => { | ||
const checkpointNodeHeader = comfyPage.page.getByText('Load Checkpoint') | ||
await checkpointNodeHeader.click() | ||
await comfyPage.page.keyboard.press(PIN_HOTKEY) | ||
|
||
// Try to drag the node | ||
const headerPos = await checkpointNodeHeader.boundingBox() | ||
if (!headerPos) throw new Error('Failed to get header position') | ||
await comfyPage.dragAndDrop( | ||
{ x: headerPos.x, y: headerPos.y }, | ||
{ x: headerPos.x + 256, y: headerPos.y + 256 } | ||
) | ||
|
||
// Verify the node is not dragged (same position before and after click-and-drag) | ||
const headerPosAfterDrag = await checkpointNodeHeader.boundingBox() | ||
if (!headerPosAfterDrag) | ||
throw new Error('Failed to get header position after drag') | ||
expect(headerPosAfterDrag).toEqual(headerPos) | ||
|
||
// Unpin the node with the hotkey | ||
await checkpointNodeHeader.click() | ||
await comfyPage.page.keyboard.press(PIN_HOTKEY) | ||
|
||
// Try to drag the node again | ||
await comfyPage.dragAndDrop( | ||
{ x: headerPos.x, y: headerPos.y }, | ||
{ x: headerPos.x + 256, y: headerPos.y + 256 } | ||
) | ||
|
||
// Verify the node is dragged | ||
const headerPosAfterDrag2 = await checkpointNodeHeader.boundingBox() | ||
if (!headerPosAfterDrag2) | ||
throw new Error('Failed to get header position after drag') | ||
expect(headerPosAfterDrag2).not.toEqual(headerPos) | ||
}) | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ | |
<!-- Node Title --> | ||
<div | ||
v-tooltip.top="tooltipConfig" | ||
class="text-sm font-bold truncate flex-1 lod-toggle" | ||
class="text-sm font-bold truncate flex-1 lod-toggle flex items-center gap-2" | ||
data-testid="node-title" | ||
> | ||
<EditableText | ||
|
@@ -36,6 +36,11 @@ | |
@edit="handleTitleEdit" | ||
@cancel="handleTitleCancel" | ||
/> | ||
<i-lucide:pin | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could use the class based icon, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it better? Or just for consistency? |
||
v-if="isPinned" | ||
class="w-5 h-5 text-stone-200 dark-theme:text-slate-300" | ||
data-testid="node-pin-indicator" | ||
/> | ||
</div> | ||
<LODFallback /> | ||
</div> | ||
|
@@ -141,6 +146,8 @@ watch( | |
} | ||
) | ||
|
||
const isPinned = computed(() => Boolean(nodeData?.flags?.pinned)) | ||
|
||
// Subgraph detection | ||
const isSubgraphNode = computed(() => { | ||
if (!nodeData?.id) return false | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Supremely happy that this is no longer necessary~