Skip to content

Commit 30998f7

Browse files
committed
add docstrings to workspace directory functions
1 parent 6cd4b01 commit 30998f7

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

frontend/app/tab/workspaceswitcher.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,26 @@ interface PreviewViewModel extends BlockAwareViewModel {
150150
goHistory: (path: string) => Promise<void>;
151151
}
152152

153+
/**
154+
* Type guard that checks if a ViewModel has block awareness (blockId and blockAtom properties).
155+
*/
153156
function isBlockAwareViewModel(viewModel: ViewModel): viewModel is BlockAwareViewModel {
154157
return "blockId" in viewModel && "blockAtom" in viewModel;
155158
}
156159

160+
/**
161+
* Type guard that checks if a ViewModel is a preview view with navigation capabilities.
162+
*/
157163
function isPreviewViewModel(viewModel: ViewModel): viewModel is PreviewViewModel {
158164
return viewModel.viewType === "preview" && isBlockAwareViewModel(viewModel) && "goHistory" in viewModel;
159165
}
160166

167+
/**
168+
* Updates all local blocks to use a new workspace directory.
169+
* For preview blocks, navigates to the new directory.
170+
* For terminal blocks, sends a cd command to change to the new directory.
171+
* Skips blocks that have a remote connection.
172+
*/
161173
async function updateBlocksWithNewDirectory(newDirectory: string): Promise<void> {
162174
const allModels = getAllBlockComponentModels();
163175
for (const model of allModels) {

pkg/blockcontroller/shellcontroller.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,8 @@ func createCmdStrAndOpts(blockId string, blockMeta waveobj.MetaMapType, connName
721721
return cmdStr, &cmdOpts, nil
722722
}
723723

724+
// getWorkspaceInfo retrieves the workspace ID and directory for a given tab.
725+
// Returns empty strings if the tab ID is empty or if the workspace cannot be found.
724726
func getWorkspaceInfo(ctx context.Context, tabId string) (wsId string, wsDir string) {
725727
if tabId == "" {
726728
return "", ""

0 commit comments

Comments
 (0)