Feature: Traditional menu actions in desktop application part II (#6030)

* chore: skeleton for building and creating menus. Need electron to renderer interface to dynamically set the menu

* chore: skeleton typing for communication between nodes and web side

* chore: more skeleton for the different roles within the menu options, need more type safety

* chore: adding more skeleton and templates of what the menus could be

* chore: implemented first pass for helpRole links

* fix: syntax issue stopped the build step

* feature: loading different menus based on your page

* feature: Home page file role implemented

* chore: handling the build workflow for the signin page

* fix: moving edit actionst to the edit menu

* chore: adding preferences to the file role

* chore: redoing help roles based on the question mark widget

* fix: auto fmt

* chore: examples of accelerator strings for Menu.MenuItems keyboard shortcuts!

* chore: oddly specific toggle API for disabling MenuItems from JS. No rules!

* fix: do not implement a custom label disable thingy, use id on menu and use the native APIga

* fix: auto fmt

* fix: adding some typechecks and auto fmt fixes

* fix: trying to fix custom type?

* fix: nvm we back, the lsp on my editor borked for a second

* fix: adding one more level to the custom type for the labels

* chore: cleaning up type definitions to read easier

* fix: resolving yarn lint errors

* chore: adding file sign out

* chore: adding more file bar actions

* chore: ready for PR draft

* fix: preemptive GC collectoin bug fix if somehow a user interacts with a menu while it is being GCed

* fix: linking the OG source

* fix: set application menu to null to avoid default electron menu

* chore: trying to add more typescript

* chore: BIG workflow changes... better typing, less IPC junk

* fix: remapping the icp functions to the cb option select...

* chore: all og events are rehooked up with new workflow pattern

* feat: adding more options to the native bar!

* fix: todo

* chore: cleaning up some menus and adding more

* fix: desktop vs browser and lint errors

* fix: typescript did not like sample electorn JS code for the basic templates with isMac conditionals...

* fix: PR clean up

* fix: more PR cleanup

* A snapshot a day keeps the bugs away! 📷🐛

* fix: added the new help menu to the default sign in and modeling page

* fix: disabled two menu actions within sign in page since they will not do anything.

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* fix: mergining main, auto fixes

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* fix: saving off progress found an IPC on/off bug thanks electron!

* fix: fixed ipc renderer off/remove listener bug

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* chore: skeleton layout for the file menu in the modeling page.

* fix: adding types

* A snapshot a day keeps the bugs away! 📷🐛

* fix: more skeleton

* feat: adding file preferences project settings

* feat: adding share current part link to file menu

* fix: report a bug to refresha and report a bug

* fix: new type for webContents send payload that does not brick TS

* fix: removing import file from url since it is not working in the command palette for manual user input

* fix: removing old comment

* chore: adding user default units

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* fix: trying to create a new file but I don't think this the correct workflow...

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* fix: disabling create a file and folder until we get it properly implemented at the commad bar level

* fix: hooking up more commands

* fix: auto fixes

* chore: adding standard views

* chore: adding some E2E tests.

* chore: added E2E tests for each file menu

* fix: auto fixes

* chore: adding more edit role E2E tests

* chore: e2e test

* chore: adding help role e2e test

* A snapshot a day keeps the bugs away! 📷🐛

* chore: e2e test for all the menu options you can interact with in the frontend

* chore: hooking up more menu actions

* chore: adding pane actions

* fix: mac only menu fix and added start sketch

* chore: big edit for state management and command registration

* fix: auto fixes, tsc

* fix: codespell typo

* chore: implementing E2E tests for the menus since we cleared them.

* chore: file export current part e2e test

* chore: added all file role tests in modeling page

* chore: modeling page edit e2e tests

* chore: implemented view e2e test for modeling page

* chore: add all design e2e playright tests

* fix: auto linter,fmt

* chore: added modeling help role e2e tests

* fix: ugh this function isn't available in electron evalulate

* fix: new default project name

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
This commit is contained in:
Kevin Nadro
2025-04-04 08:39:02 -05:00
committed by GitHub
parent f1e95156ea
commit 449b43792b
13 changed files with 3161 additions and 33 deletions

View File

@ -19,6 +19,7 @@ import type {
import type { Node } from '@rust/kcl-lib/bindings/Node'
import type { Plane } from '@rust/kcl-lib/bindings/Plane'
import { useAppState } from '@src/AppState'
import { letEngineAnimateAndSyncCamAfter } from '@src/clientSideScene/CameraControls'
import {
SEGMENT_BODIES,
@ -26,6 +27,7 @@ import {
} from '@src/clientSideScene/sceneConstants'
import type { MachineManager } from '@src/components/MachineManagerProvider'
import { MachineManagerContext } from '@src/components/MachineManagerProvider'
import type { SidebarType } from '@src/components/ModelingSidebar/ModelingPanes'
import { applyConstraintIntersect } from '@src/components/Toolbar/Intersect'
import { applyConstraintAbsDistance } from '@src/components/Toolbar/SetAbsDistance'
import {
@ -38,8 +40,14 @@ import {
applyConstraintLength,
} from '@src/components/Toolbar/setAngleLength'
import { useFileContext } from '@src/hooks/useFileContext'
import {
useMenuListener,
useSketchModeMenuEnableDisable,
} from '@src/hooks/useMenu'
import { useNetworkContext } from '@src/hooks/useNetworkContext'
import { useSetupEngineManager } from '@src/hooks/useSetupEngineManager'
import useStateMachineCommands from '@src/hooks/useStateMachineCommands'
import { useKclContext } from '@src/lang/KclProvider'
import { updateModelingState } from '@src/lang/modelingWorkflows'
import {
insertNamedConstant,
@ -111,6 +119,7 @@ import {
modelingMachine,
modelingMachineDefaultContext,
} from '@src/machines/modelingMachine'
import type { WebContentSendPayload } from '@src/menu/channels'
export const ModelingMachineContext = createContext(
{} as {
@ -1756,6 +1765,142 @@ export const ModelingMachineProvider = ({
}
)
// Register file menu actions based off modeling send
const cb = (data: WebContentSendPayload) => {
const openPanes = modelingActor.getSnapshot().context.store.openPanes
if (data.menuLabel === 'View.Panes.Feature tree') {
const featureTree: SidebarType = 'feature-tree'
const alwaysAddFeatureTree: SidebarType[] = [
...new Set([...openPanes, featureTree]),
]
modelingSend({
type: 'Set context',
data: {
openPanes: alwaysAddFeatureTree,
},
})
} else if (data.menuLabel === 'View.Panes.KCL code') {
const code: SidebarType = 'code'
const alwaysAddCode: SidebarType[] = [...new Set([...openPanes, code])]
modelingSend({
type: 'Set context',
data: {
openPanes: alwaysAddCode,
},
})
} else if (data.menuLabel === 'View.Panes.Project files') {
const projectFiles: SidebarType = 'files'
const alwaysAddProjectFiles: SidebarType[] = [
...new Set([...openPanes, projectFiles]),
]
modelingSend({
type: 'Set context',
data: {
openPanes: alwaysAddProjectFiles,
},
})
} else if (data.menuLabel === 'View.Panes.Variables') {
const variables: SidebarType = 'variables'
const alwaysAddVariables: SidebarType[] = [
...new Set([...openPanes, variables]),
]
modelingSend({
type: 'Set context',
data: {
openPanes: alwaysAddVariables,
},
})
} else if (data.menuLabel === 'View.Panes.Logs') {
const logs: SidebarType = 'logs'
const alwaysAddLogs: SidebarType[] = [...new Set([...openPanes, logs])]
modelingSend({
type: 'Set context',
data: {
openPanes: alwaysAddLogs,
},
})
} else if (data.menuLabel === 'Design.Start sketch') {
modelingSend({
type: 'Enter sketch',
data: { forceNewSketch: true },
})
}
}
useMenuListener(cb)
const { overallState } = useNetworkContext()
const { isExecuting } = useKclContext()
const { isStreamReady } = useAppState()
// Assumes all commands are network commands
useSketchModeMenuEnableDisable(
modelingState.context.currentMode,
overallState,
isExecuting,
isStreamReady,
[
{ menuLabel: 'Edit.Modify with Zoo Text-To-CAD' },
{ menuLabel: 'View.Standard views' },
{ menuLabel: 'View.Named views' },
{ menuLabel: 'Design.Start sketch' },
{
menuLabel: 'Design.Create an offset plane',
commandName: 'Offset plane',
groupId: 'modeling',
},
{
menuLabel: 'Design.Create a helix',
commandName: 'Helix',
groupId: 'modeling',
},
{
menuLabel: 'Design.Create an additive feature.Extrude',
commandName: 'Extrude',
groupId: 'modeling',
},
{
menuLabel: 'Design.Create an additive feature.Revolve',
commandName: 'Revolve',
groupId: 'modeling',
},
{
menuLabel: 'Design.Create an additive feature.Sweep',
commandName: 'Sweep',
groupId: 'modeling',
},
{
menuLabel: 'Design.Create an additive feature.Loft',
commandName: 'Loft',
groupId: 'modeling',
},
{
menuLabel: 'Design.Apply modification feature.Fillet',
commandName: 'Fillet',
groupId: 'modeling',
},
{
menuLabel: 'Design.Apply modification feature.Chamfer',
commandName: 'Chamfer',
groupId: 'modeling',
},
{
menuLabel: 'Design.Apply modification feature.Shell',
commandName: 'Shell',
groupId: 'modeling',
},
{
menuLabel: 'Design.Create with Zoo Text-To-CAD',
commandName: 'Text-to-CAD',
groupId: 'modeling',
},
{
menuLabel: 'Design.Modify with Zoo Text-To-CAD',
commandName: 'Prompt-to-edit',
groupId: 'modeling',
},
]
)
// Add debug function to window object
useEffect(() => {
// @ts-ignore - we're intentionally adding this to window