Franknoirot/adhoc/improve e2e (#6265)
* fix: increasing timeout to reduce failures..? * fix: removing debugging code * Remove unnecessary pixel color check * Only close the command palette on disconnection events This code closes the palette on *any* network event, including it getting established. This made tests like "Create a few projects using the default project name" unreliable. Also adds a block comment about how we should do something more sophisticated than bail out in the future. * Show a toast to explain why the user just lost their command flow * Remove unnecessary click in test. `fill` focuses already * Oop don't spam this disconnection toast if the palette isn't open Honoring exhausting hook dependency checks * Skip circle snapshot test, it's being weird * Disable the export button if engine connection is unavailable * Refactor useDemoCode to hopefully be more reliable * allow weak connections to receive demo code * revert Refactor useDemoCode to hopefully be more reliable Commit:2625c14783
[2625c1478
] --------- Co-authored-by: Kevin Nadro <kevin@zoo.dev> Co-authored-by: Jace Browning <jacebrowning@gmail.com> Co-authored-by: Andrew Varga <grizzly33@gmail.com>
This commit is contained in:
@ -14,6 +14,7 @@ import {
|
||||
commandBarActor,
|
||||
useCommandBarState,
|
||||
} from '@src/machines/commandBarMachine'
|
||||
import toast from 'react-hot-toast'
|
||||
|
||||
export const COMMAND_PALETTE_HOTKEY = 'mod+k'
|
||||
|
||||
@ -35,13 +36,23 @@ export const CommandBar = () => {
|
||||
commandBarActor.send({ type: 'Close' })
|
||||
}, [pathname])
|
||||
|
||||
/**
|
||||
* if the engine connection is about to end, we don't want users
|
||||
* to be able to perform commands that might require that connection,
|
||||
* so we just close the command palette.
|
||||
* TODO: instead, let each command control whether it is disabled, and
|
||||
* don't just bail out
|
||||
*/
|
||||
useEffect(() => {
|
||||
if (
|
||||
immediateState.type !== EngineConnectionStateType.ConnectionEstablished
|
||||
!commandBarActor.getSnapshot().matches('Closed') &&
|
||||
(immediateState.type === EngineConnectionStateType.Disconnecting ||
|
||||
immediateState.type === EngineConnectionStateType.Disconnected)
|
||||
) {
|
||||
commandBarActor.send({ type: 'Close' })
|
||||
toast.error('Exiting command flow because engine disconnected')
|
||||
}
|
||||
}, [immediateState])
|
||||
}, [immediateState, commandBarActor])
|
||||
|
||||
// Hook up keyboard shortcuts
|
||||
useHotkeyWrapper([COMMAND_PALETTE_HOTKEY], () => {
|
||||
|
@ -4,6 +4,7 @@ import type { MouseEventHandler } from 'react'
|
||||
import { useCallback, useContext, useEffect, useMemo } from 'react'
|
||||
import { useHotkeys } from 'react-hotkeys-hook'
|
||||
|
||||
import { useAppState } from '@src/AppState'
|
||||
import { ActionIcon } from '@src/components/ActionIcon'
|
||||
import type { CustomIconName } from '@src/components/CustomIcon'
|
||||
import { MachineManagerContext } from '@src/components/MachineManagerProvider'
|
||||
@ -16,7 +17,10 @@ import { sidebarPanes } from '@src/components/ModelingSidebar/ModelingPanes'
|
||||
import Tooltip from '@src/components/Tooltip'
|
||||
import { DEV } from '@src/env'
|
||||
import { useModelingContext } from '@src/hooks/useModelingContext'
|
||||
import { useNetworkContext } from '@src/hooks/useNetworkContext'
|
||||
import { NetworkHealthState } from '@src/hooks/useNetworkStatus'
|
||||
import { useKclContext } from '@src/lang/KclProvider'
|
||||
import { EngineConnectionStateType } from '@src/lang/std/engineConnection'
|
||||
import { SIDEBAR_BUTTON_SUFFIX } from '@src/lib/constants'
|
||||
import { isDesktop } from '@src/lib/isDesktop'
|
||||
import { useSettings } from '@src/machines/appMachine'
|
||||
@ -52,6 +56,16 @@ export function ModelingSidebar({ paneOpacity }: ModelingSidebarProps) {
|
||||
: 'pointer-events-auto '
|
||||
const showDebugPanel = settings.app.showDebugPanel
|
||||
|
||||
const { overallState, immediateState } = useNetworkContext()
|
||||
const { isExecuting } = useKclContext()
|
||||
const { isStreamReady } = useAppState()
|
||||
const reliesOnEngine =
|
||||
(overallState !== NetworkHealthState.Ok &&
|
||||
overallState !== NetworkHealthState.Weak) ||
|
||||
isExecuting ||
|
||||
immediateState.type !== EngineConnectionStateType.ConnectionEstablished ||
|
||||
!isStreamReady
|
||||
|
||||
const paneCallbackProps = useMemo(
|
||||
() => ({
|
||||
kclContext,
|
||||
@ -93,6 +107,8 @@ export function ModelingSidebar({ paneOpacity }: ModelingSidebarProps) {
|
||||
sidebarName: 'Export part',
|
||||
icon: 'floppyDiskArrow',
|
||||
keybinding: 'Ctrl + Shift + E',
|
||||
disable: () =>
|
||||
reliesOnEngine ? 'Need engine connection to export' : undefined,
|
||||
action: () =>
|
||||
commandBarActor.send({
|
||||
type: 'Find and select command',
|
||||
|
Reference in New Issue
Block a user