feat: per-workspace script management system#25
Open
lyx-tec wants to merge 1 commit into
Open
Conversation
Add a script management system that lets users store, edit, and execute shell scripts within a workspace context. Key features: - Scripts stored in workspace.meta['scripts:list'] (typed WorkspaceScript[]) - Script execution via heredoc → mktemp → source → rm pipeline, supporting bash/zsh/sh/dash (POSIX '.' dot command), with block on fish, cmd, and PowerShell - Script Picker modal (Ctrl+Shift+e or right-click 'Run Script…') with search, keyboard navigation, inline delete, and '+ Add Script' entry - Script Management modal with inline CRUD (edit-in-place, add-at-bottom) - Workspace editor preview card showing first script with live WOS atom - blockId explicitly threaded through right-click → picker → runScript - Go-side MetaTSType registration for 'scripts:list' with auto-generated TypeScript types
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Add a per-workspace script management system. Users can store shell scripts in workspace metadata, execute them from a quick-select picker, and manage them in a dedicated modal.
Implementation
Data Layer (
workspace-scripts.ts)workspace.meta["scripts:list"]with full TypeScript typing via Go-side MetaTSType registrationWorkspaceScriptfields:id,name,command,desc?,lastused?(Unix ms timestamp)getScriptsFromWorkspace/saveScriptsToWorkspace/recordScriptRun— CRUD helpersrunScript(script, blockId?)— builds heredoc pipeline and injects into terminalopenScriptsPicker(blockId?)— unified entry point for both keyboard shortcut and context menulastuseddescending in the pickerExecution (
buildHeredocCommand)Scripts run via a heredoc → temp file → source → cleanup pipeline:
.(dot) command instead ofsourcefor dash compatibility__WAVE_SCR_FILEnaming minimizes collision with user variablesScript Picker (
WorkspaceScriptsPicker)Ctrl+Shift+e(e for execute) or right-click "Run Script…" in terminalScript Management Modal (
WorkspaceScriptsModal)Integration
keymodel.tsregistersCtrl:Shift:e→openScriptsPicker(), returns false if condition not met so the key event propagatesterm-model.ts:getContextMenuItems(blockId)— blockId explicitly threaded through toopenScriptsPicker(blockId), avoidinggetFocusedBlockId()mismatch on right-clickScriptsSectioncomponent with live preview card (green accent left border, modal-bg-color background, "+N more" clickable link)Design Decisions
runScriptreturns{ ok: boolean; reason?: string }— domain logic does not push modals; the caller (picker) decides how to surface errorsterm:localshellpathconfig) — fish detected by path matching, Windows cmd/PowerShell by path + platform checkbuildHeredocCommandis module-private, not exportedScriptRunResultinterface is exported for callers to consumeFiles Changed
pkg/waveobj/wtype.goWorkspaceScriptstruct +ScriptsListfieldpkg/waveobj/wtypemeta.goscripts:listin MetaTSTypepkg/waveobj/metaconsts.goMetaKey_ScriptsListconstantfrontend/types/gotypes.d.tsWorkspaceScripttype +MetaTypeextensionfrontend/app/workspace/workspace-scripts.tsfrontend/app/modals/workspace-scripts-picker.{tsx,scss}frontend/app/modals/workspace-scripts-modal.{tsx,scss}frontend/app/modals/modalregistry.tsxfrontend/app/store/keymodel.tsfrontend/app/view/term/term-model.tsfrontend/app/view/term/term.tsxfrontend/app/tab/workspaceeditor.{tsx,scss}frontend/app/tab/workspaceswitcherdetail.tsxNote: Auto-generated files (
metaconsts.go,gotypes.d.ts) were regenerated viatask generateafter manual Go changes.