-
-
Notifications
You must be signed in to change notification settings - Fork 427
修复 workspace 浏览页初始化后不加载目录 #605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -226,13 +226,14 @@ export function WorkspaceBrowser(props: { | |
| void loadDirectory(selectedRoot) | ||
| }, [machineId, selectedRoot, currentPath, loadDirectory]) | ||
|
|
||
| // If switching machines, reset view | ||
| // 切换机器时重置浏览状态,并立即对齐到新机器的第一个 workspace root。 | ||
| // 否则 selectedRoot 可能被清空后跳过自动加载,页面会停在空态。 | ||
| useEffect(() => { | ||
| setSelectedRoot(null) | ||
| setSelectedRoot(workspaceRoots[0] ?? null) | ||
| setCurrentPath(null) | ||
| setEntries([]) | ||
| setError(null) | ||
| }, [machineId]) | ||
| }, [machineId, workspaceRoots]) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [MAJOR] |
||
|
|
||
| const handleEntryClick = useCallback((entry: MachineDirectoryEntry) => { | ||
| if (entry.type !== 'directory' || !currentPath) return | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Major]
workspaceRoots在没有 roots 时来自selectedMachine?.metadata?.workspaceRoots ?? [],每次 render 都会得到新的空数组引用。这个 effect 现在依赖它,并且无条件setEntries([])写入新的数组状态,所以未配置 workspace roots 或 roots 尚未加载时会进入 render 循环,/browse的空态也可能卡死。Suggested fix: