mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-04 15:10:06 +00:00
## Summary Code-splits the ~400KB xterm bundle and excludes terminal features from cloud distribution where they are not needed. ### Changes - **bottomPanelStore.ts**: Gate terminal tab registration behind `__DISTRIBUTION__ !== 'cloud'` check with dynamic import, enabling tree-shaking - **keybindingService.ts**: Skip logs-terminal keybinding registration for cloud distribution - **vite.config.mts**: Add `vendor-xterm` code splitting group ### Bundle Impact | Distribution | xterm in bundle | Terminal tabs | |--------------|-----------------|---------------| | cloud | ❌ No (~400KB saved) | None | | localhost | ✅ Yes (vendor-xterm chunk) | Logs terminal | | desktop | ✅ Yes (vendor-xterm chunk) | Logs + Command terminal | ### Verification Script Run locally to verify xterm exclusion works correctly: ```bash #!/bin/bash set -e echo "=== Verifying xterm bundle exclusion ===" echo # Clear Nx cache to ensure fresh builds pnpm nx reset 2>/dev/null # Build cloud distribution echo "Building CLOUD distribution..." rm -rf dist DISTRIBUTION=cloud pnpm build --mode production 2>/dev/null echo "Cloud build - checking for xterm:" if grep -r "xterm" dist/assets/*.js >/dev/null 2>&1; then echo " ❌ FAIL: xterm found in cloud bundle" grep -l "xterm" dist/assets/*.js | head -5 else echo " ✅ PASS: xterm NOT in cloud bundle" fi echo # Build localhost distribution echo "Building LOCALHOST distribution..." pnpm nx reset 2>/dev/null rm -rf dist DISTRIBUTION=localhost pnpm build --mode production 2>/dev/null echo "Localhost build - checking for xterm:" if grep -r "xterm" dist/assets/*.js >/dev/null 2>&1; then echo " ✅ PASS: xterm found in localhost bundle" echo " Files containing xterm:" grep -l "xterm" dist/assets/*.js | while read f; do size=$(wc -c < "$f") echo " $(basename $f) ($(numfmt --to=iec $size))" done else echo " ❌ FAIL: xterm NOT in localhost bundle" fi echo echo "=== Verification complete ===" ``` **Note**: Nx cache must be reset between builds with different `DISTRIBUTION` values or it may return stale results. ## Test Plan - [x] Quality gates pass (typecheck, lint, format, tests) - [x] Cloud build verified: xterm NOT present - [x] Localhost build verified: xterm present as vendor-xterm chunk Fixes COM-14129 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8528-perf-code-split-xterm-bundle-and-gate-terminal-features-for-cloud-2fa6d73d365081a093ecc74ca7ce6e7c) by [Unito](https://www.unito.io) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Terminal tab declarations adjusted (no user-visible behavior change). * Bottom panel tabs now load asynchronously; panel toggle falls back to shortcuts when terminal tabs aren’t loaded. * **Chores** * Terminal tabs and related keybindings suppressed in cloud deployments. * Core commands wired to a new utility to support widget promotion. * **Tests** * E2E tests updated to handle async terminal-tab loading and minor test cleanup. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Alexander Brown <drjkl@comfy.org>
235 lines
7.2 KiB
TypeScript
235 lines
7.2 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import { comfyPageFixture as test } from '../fixtures/ComfyPage'
|
|
|
|
test.describe('Bottom Panel Shortcuts', { tag: '@ui' }, () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Top')
|
|
})
|
|
|
|
test('should toggle shortcuts panel visibility', async ({ comfyPage }) => {
|
|
const { bottomPanel } = comfyPage
|
|
|
|
await expect(bottomPanel.root).not.toBeVisible()
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
await expect(bottomPanel.root).toBeVisible()
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
await expect(bottomPanel.root).not.toBeVisible()
|
|
})
|
|
|
|
test('should display essentials shortcuts tab', async ({ comfyPage }) => {
|
|
const { bottomPanel } = comfyPage
|
|
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
|
|
await expect(bottomPanel.shortcuts.essentialsTab).toBeVisible()
|
|
await expect(bottomPanel.shortcuts.essentialsTab).toHaveAttribute(
|
|
'aria-selected',
|
|
'true'
|
|
)
|
|
|
|
await expect(bottomPanel.shortcuts.subcategoryTitles.first()).toBeVisible()
|
|
await expect(bottomPanel.shortcuts.keyBadges.first()).toBeVisible()
|
|
|
|
await expect(
|
|
comfyPage.page.getByRole('heading', { name: 'Workflow' })
|
|
).toBeVisible()
|
|
await expect(
|
|
comfyPage.page.getByRole('heading', { name: 'Node' })
|
|
).toBeVisible()
|
|
await expect(
|
|
comfyPage.page.getByRole('heading', { name: 'Queue' })
|
|
).toBeVisible()
|
|
})
|
|
|
|
test('should display view controls shortcuts tab', async ({ comfyPage }) => {
|
|
const { bottomPanel } = comfyPage
|
|
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
await bottomPanel.shortcuts.viewControlsTab.click()
|
|
|
|
await expect(bottomPanel.shortcuts.viewControlsTab).toHaveAttribute(
|
|
'aria-selected',
|
|
'true'
|
|
)
|
|
|
|
await expect(bottomPanel.shortcuts.keyBadges.first()).toBeVisible()
|
|
|
|
await expect(
|
|
comfyPage.page.getByRole('heading', { name: 'View' })
|
|
).toBeVisible()
|
|
await expect(
|
|
comfyPage.page.getByRole('heading', { name: 'Panel Controls' })
|
|
).toBeVisible()
|
|
})
|
|
|
|
test('should switch between shortcuts tabs', async ({ comfyPage }) => {
|
|
const { bottomPanel } = comfyPage
|
|
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
|
|
await expect(bottomPanel.shortcuts.essentialsTab).toHaveAttribute(
|
|
'aria-selected',
|
|
'true'
|
|
)
|
|
|
|
await bottomPanel.shortcuts.viewControlsTab.click()
|
|
|
|
await expect(bottomPanel.shortcuts.viewControlsTab).toHaveAttribute(
|
|
'aria-selected',
|
|
'true'
|
|
)
|
|
await expect(bottomPanel.shortcuts.essentialsTab).not.toHaveAttribute(
|
|
'aria-selected',
|
|
'true'
|
|
)
|
|
|
|
await bottomPanel.shortcuts.essentialsTab.click()
|
|
|
|
await expect(bottomPanel.shortcuts.essentialsTab).toHaveAttribute(
|
|
'aria-selected',
|
|
'true'
|
|
)
|
|
await expect(bottomPanel.shortcuts.viewControlsTab).not.toHaveAttribute(
|
|
'aria-selected',
|
|
'true'
|
|
)
|
|
})
|
|
|
|
test('should display formatted keyboard shortcuts', async ({ comfyPage }) => {
|
|
const { bottomPanel } = comfyPage
|
|
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
|
|
const keyBadges = bottomPanel.shortcuts.keyBadges
|
|
await keyBadges.first().waitFor({ state: 'visible' })
|
|
const count = await keyBadges.count()
|
|
expect(count).toBeGreaterThanOrEqual(1)
|
|
|
|
const badgeText = await keyBadges.allTextContents()
|
|
const hasModifiers = badgeText.some((text) =>
|
|
['Ctrl', 'Cmd', 'Shift', 'Alt'].includes(text)
|
|
)
|
|
expect(hasModifiers).toBeTruthy()
|
|
})
|
|
|
|
test('should maintain panel state when switching between panels', async ({
|
|
comfyPage
|
|
}) => {
|
|
const { bottomPanel } = comfyPage
|
|
|
|
// Open shortcuts panel first
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
await expect(bottomPanel.root).toBeVisible()
|
|
await expect(
|
|
comfyPage.page.locator('[id*="tab_shortcuts-essentials"]')
|
|
).toBeVisible()
|
|
|
|
// Try to open terminal panel - may show terminal OR close shortcuts
|
|
// depending on whether terminal tabs have loaded (async loading)
|
|
await bottomPanel.toggleButton.click()
|
|
|
|
// Check if terminal tabs loaded (Logs tab visible) or fell back to shortcuts toggle
|
|
const logsTab = comfyPage.page.getByRole('tab', { name: /Logs/i })
|
|
const hasTerminalTabs = await logsTab.isVisible().catch(() => false)
|
|
|
|
if (hasTerminalTabs) {
|
|
// Terminal panel is visible - verify we can switch back to shortcuts
|
|
await expect(bottomPanel.root).toBeVisible()
|
|
|
|
// Switch back to shortcuts
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
|
|
// Should show shortcuts content again
|
|
await expect(
|
|
comfyPage.page.locator('[id*="tab_shortcuts-essentials"]')
|
|
).toBeVisible()
|
|
} else {
|
|
// Terminal tabs not loaded - button toggled shortcuts off, reopen for verification
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
await expect(bottomPanel.root).toBeVisible()
|
|
await expect(
|
|
comfyPage.page.locator('[id*="tab_shortcuts-essentials"]')
|
|
).toBeVisible()
|
|
}
|
|
})
|
|
|
|
test('should handle keyboard navigation', async ({ comfyPage }) => {
|
|
const { bottomPanel } = comfyPage
|
|
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
await bottomPanel.shortcuts.essentialsTab.focus()
|
|
|
|
await comfyPage.page.keyboard.press('ArrowRight')
|
|
|
|
await expect(bottomPanel.shortcuts.viewControlsTab).toBeFocused()
|
|
|
|
await comfyPage.page.keyboard.press('Enter')
|
|
|
|
await expect(bottomPanel.shortcuts.viewControlsTab).toHaveAttribute(
|
|
'aria-selected',
|
|
'true'
|
|
)
|
|
})
|
|
|
|
test('should close panel by clicking shortcuts button again', async ({
|
|
comfyPage
|
|
}) => {
|
|
const { bottomPanel } = comfyPage
|
|
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
await expect(bottomPanel.root).toBeVisible()
|
|
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
await expect(bottomPanel.root).not.toBeVisible()
|
|
})
|
|
|
|
test('should display shortcuts in organized columns', async ({
|
|
comfyPage
|
|
}) => {
|
|
const { bottomPanel } = comfyPage
|
|
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
|
|
await expect(
|
|
comfyPage.page.locator('[data-testid="shortcuts-columns"]')
|
|
).toBeVisible()
|
|
|
|
const subcategoryTitles = bottomPanel.shortcuts.subcategoryTitles
|
|
const titleCount = await subcategoryTitles.count()
|
|
expect(titleCount).toBeGreaterThanOrEqual(2)
|
|
})
|
|
|
|
test('should open shortcuts panel with Ctrl+Shift+K', async ({
|
|
comfyPage
|
|
}) => {
|
|
const { bottomPanel } = comfyPage
|
|
|
|
await expect(bottomPanel.root).not.toBeVisible()
|
|
|
|
await comfyPage.page.keyboard.press('Control+Shift+KeyK')
|
|
|
|
await expect(bottomPanel.root).toBeVisible()
|
|
await expect(bottomPanel.shortcuts.essentialsTab).toHaveAttribute(
|
|
'aria-selected',
|
|
'true'
|
|
)
|
|
})
|
|
|
|
test('should open settings dialog when clicking manage shortcuts button', async ({
|
|
comfyPage
|
|
}) => {
|
|
const { bottomPanel } = comfyPage
|
|
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
|
|
await expect(bottomPanel.shortcuts.manageButton).toBeVisible()
|
|
await bottomPanel.shortcuts.manageButton.click()
|
|
|
|
await expect(comfyPage.page.getByRole('dialog')).toBeVisible()
|
|
await expect(
|
|
comfyPage.page.getByRole('option', { name: 'Keybinding' })
|
|
).toBeVisible()
|
|
})
|
|
})
|