Repository navigation
fix(rc): display symlinked directories in HostFolderBrowser (#5296) #5360
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
Open
markankamaransheogarat-sys
wants to merge
5
commits into
MoonshotAI:main
Choose a base branch
from
markankamaransheogarat-sys:fix/rc-folder-picker-symlink-dirs-5296
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4c23f3d
fix(rc): display symlinked directories in HostFolderBrowser (#5296)
markankamaransheogarat-sys fac4271
fix(rc): propagate unexpected stat errors and add kap-server changese…
markankamaransheogarat-sys 4784095
test(rc): add EIO stat regression test and split lib/product changese…
markankamaransheogarat-sys 1615bd4
test(rc): place vi.mock after imports for TypeScript 7 typecheck (#5360)
markankamaransheogarat-sys 81d16d6
test(rc): update HostFolderBrowser test import to IProjectService aft…
markankamaransheogarat-sys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "@moonshot-ai/kimi-code": patch | ||
| "kimi-code-app": patch | ||
| "kimi-code": patch | ||
| --- | ||
|
|
||
| Display symlinked directories in the Remote Control workspace folder picker. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "@moonshot-ai/agent-core-v2": patch | ||
| "@moonshot-ai/kap-server": patch | ||
| "@moonshot-ai/kimi-code-sdk": patch | ||
| --- | ||
|
|
||
| Follow symbolic links when enumerating directories in the host folder browser, skipping broken, looped, and permission-denied links while propagating unexpected filesystem stat failures. |
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
88 changes: 88 additions & 0 deletions
88
packages/agent-core-v2/test/app/hostFolderBrowser/hostFolderBrowserService.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import * as fsPromises from "node:fs/promises"; | ||
| import { mkdtemp, mkdir, rm, symlink, writeFile } from "node:fs/promises"; | ||
| import { tmpdir } from "node:os"; | ||
| import { join } from "node:path"; | ||
| import { afterEach, describe, expect, it, vi } from "vitest"; | ||
|
|
||
| import type { IProjectService } from "#/app/project/project"; | ||
| import { HostFolderBrowser } from "#/app/hostFolderBrowser/hostFolderBrowserService"; | ||
|
|
||
| vi.mock("node:fs/promises", async (importOriginal) => { | ||
| const actual = await importOriginal<typeof import("node:fs/promises")>(); | ||
| return { | ||
| ...actual, | ||
| stat: vi.fn((...args: Parameters<typeof actual.stat>) => | ||
| actual.stat(...args), | ||
| ), | ||
| }; | ||
| }); | ||
|
|
||
| const fakeRegistry = { | ||
| list: async () => [], | ||
| } as unknown as IProjectService; | ||
|
|
||
| describe("HostFolderBrowser", () => { | ||
| const dirs: string[] = []; | ||
|
|
||
| afterEach(async () => { | ||
| while (dirs.length > 0) { | ||
| const dir = dirs.pop()!; | ||
| await rm(dir, { recursive: true, force: true }); | ||
| } | ||
| }); | ||
|
|
||
| it("includes symlinked directories and skips broken, looped, and file symlinks", async () => { | ||
| const root = await mkdtemp(join(tmpdir(), "kimi-folder-browser-")); | ||
| dirs.push(root); | ||
|
|
||
| const projects = join(root, "projects"); | ||
| const external = join(root, "external"); | ||
| const targetDir = join(projects, "real-dir"); | ||
| const targetFile = join(root, "file.txt"); | ||
|
|
||
| await mkdir(projects, { recursive: true }); | ||
| await mkdir(external, { recursive: true }); | ||
| await mkdir(targetDir, { recursive: true }); | ||
| await writeFile(targetFile, "hello", "utf8"); | ||
|
|
||
| await symlink(targetDir, join(projects, "internal-link")); | ||
| await symlink(external, join(projects, "external-link")); | ||
| await symlink(targetFile, join(projects, "file-link")); | ||
| await symlink(join(root, "missing-target"), join(projects, "broken-link")); | ||
| await symlink(join(projects, "loop-b"), join(projects, "loop-a")); | ||
| await symlink(join(projects, "loop-a"), join(projects, "loop-b")); | ||
|
|
||
| const browser = new HostFolderBrowser(fakeRegistry); | ||
| const res = await browser.browse(projects); | ||
|
|
||
| expect(res.entries.map((e) => e.name)).toEqual([ | ||
| "external-link", | ||
| "internal-link", | ||
| "real-dir", | ||
| ]); | ||
| expect(res.entries.every((e) => e.is_dir)).toBe(true); | ||
|
|
||
| const nav = await browser.browse(join(projects, "external-link")); | ||
| expect(nav.entries).toEqual([]); | ||
| }); | ||
|
|
||
| it("propagates unexpected stat errors instead of hiding symlinked directories", async () => { | ||
| const root = await mkdtemp(join(tmpdir(), "kimi-folder-browser-eio-")); | ||
| dirs.push(root); | ||
|
|
||
| const projects = join(root, "projects"); | ||
| const targetDir = join(root, "target"); | ||
| await mkdir(projects, { recursive: true }); | ||
| await mkdir(targetDir, { recursive: true }); | ||
| await symlink(targetDir, join(projects, "link-dir")); | ||
|
|
||
| vi.mocked(fsPromises.stat).mockRejectedValueOnce( | ||
| Object.assign(new Error("I/O error"), { code: "EIO" }), | ||
| ); | ||
|
|
||
| const browser = new HostFolderBrowser(fakeRegistry); | ||
| await expect(browser.browse(projects)).rejects.toMatchObject({ | ||
| code: "EIO", | ||
| }); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
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.
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.
If
staterrors are swallowed again, this sole test still passes because it exercises only successful directory links plus intentionally ignored broken, looped, and file links; the previous catch-all therefore satisfies every assertion here. Add a fault-injected case such asEIOthat assertsbrowse()rejects, so the regression test actually fails on the behavior this follow-up corrected.AGENTS.md reference: AGENTS.md:L61-L61
Useful? React with 👍 / 👎.