Skip to content

Commit ce4ee0b

Browse files
fix(parser): preserve JSONL provider symlink discovery
Command Code and iFlow legacy discovery followed symlinked project directories. The migrated providers should keep that behavior so users with linked project roots do not silently lose discovery or raw-session lookup after moving onto the provider facade.
1 parent 338e329 commit ce4ee0b

4 files changed

Lines changed: 66 additions & 0 deletions

File tree

internal/parser/commandcode_provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ func newCommandCodeSourceSet(roots []string) DirectoryJSONLSourceSet {
113113
AgentCommandCode,
114114
roots,
115115
JSONLSourceSetOptions{
116+
FollowSymlinkDirs: true,
116117
IncludePath: isCommandCodeSourcePath,
117118
ProjectHint: func(root, path string) string { return "" },
118119
SessionIDFromPath: commandCodeSessionIDFromPath,

internal/parser/commandcode_provider_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,35 @@ func TestCommandCodeProviderSourceMethods(t *testing.T) {
7070
assert.Equal(t, sourcePath, changed[0].DisplayPath)
7171
}
7272

73+
func TestCommandCodeProviderDiscoversSymlinkedProjectDirectory(t *testing.T) {
74+
root := t.TempDir()
75+
realProjectDir := filepath.Join(t.TempDir(), "real-project")
76+
linkProjectDir := filepath.Join(root, "linked-project")
77+
if err := os.Symlink(realProjectDir, linkProjectDir); err != nil {
78+
t.Skipf("symlink not supported: %v", err)
79+
}
80+
sourcePath := filepath.Join(linkProjectDir, "sess_123.jsonl")
81+
writeSourceFile(t, filepath.Join(realProjectDir, "sess_123.jsonl"), commandCodeProviderFixture())
82+
83+
provider, ok := NewProvider(AgentCommandCode, ProviderConfig{
84+
Roots: []string{root},
85+
Machine: "devbox",
86+
})
87+
require.True(t, ok)
88+
89+
discovered, err := provider.Discover(context.Background())
90+
require.NoError(t, err)
91+
require.Len(t, discovered, 1)
92+
assert.Equal(t, sourcePath, discovered[0].DisplayPath)
93+
94+
found, ok, err := provider.FindSource(context.Background(), FindSourceRequest{
95+
RawSessionID: "sess_123",
96+
})
97+
require.NoError(t, err)
98+
require.True(t, ok)
99+
assert.Equal(t, sourcePath, found.DisplayPath)
100+
}
101+
73102
func TestCommandCodeProviderParse(t *testing.T) {
74103
root := t.TempDir()
75104
sourcePath := filepath.Join(root, "project", "sess_123.jsonl")

internal/parser/iflow_provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ func newIflowSourceSet(roots []string) DirectoryJSONLSourceSet {
120120
AgentIflow,
121121
roots,
122122
JSONLSourceSetOptions{
123+
FollowSymlinkDirs: true,
123124
IncludePath: isIflowSourcePath,
124125
SessionIDFromPath: iflowSessionIDFromPath,
125126
},

internal/parser/iflow_provider_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,41 @@ func TestIflowProviderSourceMethods(t *testing.T) {
7171
assert.Equal(t, sourcePath, changed[0].DisplayPath)
7272
}
7373

74+
func TestIflowProviderDiscoversSymlinkedProjectDirectory(t *testing.T) {
75+
root := t.TempDir()
76+
realProjectDir := filepath.Join(t.TempDir(), "real-project")
77+
linkProjectDir := filepath.Join(root, "linked-project")
78+
if err := os.Symlink(realProjectDir, linkProjectDir); err != nil {
79+
t.Skipf("symlink not supported: %v", err)
80+
}
81+
rawID := "5de701fc-7454-4858-a249-95cac4fd3b51"
82+
sourcePath := filepath.Join(linkProjectDir, "session-"+rawID+".jsonl")
83+
copyFixtureFile(
84+
t,
85+
"testdata/iflow/session-"+rawID+".jsonl",
86+
filepath.Join(realProjectDir, "session-"+rawID+".jsonl"),
87+
)
88+
89+
provider, ok := NewProvider(AgentIflow, ProviderConfig{
90+
Roots: []string{root},
91+
Machine: "devbox",
92+
})
93+
require.True(t, ok)
94+
95+
discovered, err := provider.Discover(context.Background())
96+
require.NoError(t, err)
97+
require.Len(t, discovered, 1)
98+
assert.Equal(t, sourcePath, discovered[0].DisplayPath)
99+
assert.Equal(t, "linked-project", discovered[0].ProjectHint)
100+
101+
found, ok, err := provider.FindSource(context.Background(), FindSourceRequest{
102+
RawSessionID: rawID,
103+
})
104+
require.NoError(t, err)
105+
require.True(t, ok)
106+
assert.Equal(t, sourcePath, found.DisplayPath)
107+
}
108+
74109
func TestIflowProviderParse(t *testing.T) {
75110
root := t.TempDir()
76111
project := "test-project"

0 commit comments

Comments
 (0)