mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-24 06:35:10 +00:00
## Summary With a previously saved workflow, selecting "Save as" in app mode would not correctly change the file extension to the chosen mode, and would require an additional save after to persist the actual mode change. Recreation: - Build app - Save as worklow X, app mode - Select Save as from builder footer [Save | v] chevron button - Select node graph - Save - Check workflow on disk - it's still called X.app.json and doesn't have linearMode: false <-- bug ## Changes - **What**: - pass isApp to save workflow - ensure active graph & initialMode are correctly set when calling saveAs BEFORE the actual saveWorkflow call - add linearMode to workflowShema to prevent casts - tests ## Review Focus e2e tests coming in a follow up PR along with some refactoring of the browser tests (left this PR focused to the actual fix) ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-10679-fix-App-mode-Save-as-not-using-correct-extension-or-persisting-mode-on-change-3316d73d365081ef985cf57c91c34299) by [Unito](https://www.unito.io)
57 lines
1.4 KiB
TypeScript
57 lines
1.4 KiB
TypeScript
import { computed, ref } from 'vue'
|
|
|
|
import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore'
|
|
|
|
export type AppMode =
|
|
| 'graph'
|
|
| 'app'
|
|
| 'builder:inputs'
|
|
| 'builder:outputs'
|
|
| 'builder:arrange'
|
|
|
|
const enableAppBuilder = ref(true)
|
|
|
|
export function useAppMode() {
|
|
const workflowStore = useWorkflowStore()
|
|
const mode = computed(
|
|
() =>
|
|
workflowStore.activeWorkflow?.activeMode ??
|
|
workflowStore.activeWorkflow?.initialMode ??
|
|
'graph'
|
|
)
|
|
|
|
const isBuilderMode = computed(
|
|
() => isSelectMode.value || isArrangeMode.value
|
|
)
|
|
const isSelectInputsMode = computed(() => mode.value === 'builder:inputs')
|
|
const isSelectOutputsMode = computed(() => mode.value === 'builder:outputs')
|
|
const isSelectMode = computed(
|
|
() => isSelectInputsMode.value || isSelectOutputsMode.value
|
|
)
|
|
const isArrangeMode = computed(() => mode.value === 'builder:arrange')
|
|
const isAppMode = computed(
|
|
() => mode.value === 'app' || mode.value === 'builder:arrange'
|
|
)
|
|
const isGraphMode = computed(
|
|
() => mode.value === 'graph' || isSelectMode.value
|
|
)
|
|
|
|
function setMode(newMode: AppMode) {
|
|
const workflow = workflowStore.activeWorkflow
|
|
if (workflow) workflow.activeMode = newMode
|
|
}
|
|
|
|
return {
|
|
mode,
|
|
enableAppBuilder,
|
|
isBuilderMode,
|
|
isSelectMode,
|
|
isSelectInputsMode,
|
|
isSelectOutputsMode,
|
|
isArrangeMode,
|
|
isAppMode,
|
|
isGraphMode,
|
|
setMode
|
|
}
|
|
}
|