Skip to content

Commit 20cbe82

Browse files
stephentoubCopilot
andcommitted
Rename Cwd/InitialCwd to WorkingDirectory/InitialWorkingDirectory in Go and .NET
Complete the cwd → workingDirectory rename across all SDKs for consistency. Wire format (JSON) is preserved via struct tags and JsonPropertyName attributes. Go: - ClientOptions.Cwd → WorkingDirectory - SessionFsConfig.InitialCwd → InitialWorkingDirectory - SessionContext.Cwd → WorkingDirectory (json:"cwd") - SessionListFilter.Cwd → WorkingDirectory (json:"cwd,omitempty") .NET: - SessionFsConfig.InitialCwd → InitialWorkingDirectory ([JsonPropertyName("initialCwd")]) - SessionContext.Cwd → WorkingDirectory ([JsonPropertyName("cwd")]) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1529288 commit 20cbe82

13 files changed

Lines changed: 35 additions & 33 deletions

dotnet/src/Client.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ private async Task ConfigureSessionFsAsync(CancellationToken cancellationToken)
12331233
}
12341234

12351235
await Rpc.SessionFs.SetProviderAsync(
1236-
_options.SessionFs.InitialCwd,
1236+
_options.SessionFs.InitialWorkingDirectory,
12371237
_options.SessionFs.SessionStatePath,
12381238
_options.SessionFs.Conventions,
12391239
_options.SessionFs.Capabilities,

dotnet/src/Types.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,8 @@ public sealed class SessionFsConfig
396396
/// <summary>
397397
/// Initial working directory for sessions (user's project directory).
398398
/// </summary>
399-
public required string InitialCwd { get; init; }
399+
[JsonPropertyName("initialCwd")]
400+
public required string InitialWorkingDirectory { get; init; }
400401

401402
/// <summary>
402403
/// Path within each session's SessionFs where the runtime stores
@@ -2600,7 +2601,8 @@ public MessageOptions Clone()
26002601
public sealed class SessionContext
26012602
{
26022603
/// <summary>Working directory where the session was created.</summary>
2603-
public string Cwd { get; set; } = string.Empty;
2604+
[JsonPropertyName("cwd")]
2605+
public string WorkingDirectory { get; set; } = string.Empty;
26042606
/// <summary>Git repository root (if in a git repo).</summary>
26052607
public string? GitRoot { get; set; }
26062608
/// <summary>GitHub repository in "owner/repo" format.</summary>

dotnet/test/E2E/SessionE2ETests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ await TestHelper.WaitForConditionAsync(
450450
// Context may be present on sessions that have been persisted with workspace.yaml
451451
if (ourSession.Context != null)
452452
{
453-
Assert.False(string.IsNullOrEmpty(ourSession.Context.Cwd), "Expected context.Cwd to be non-empty when context is present");
453+
Assert.False(string.IsNullOrEmpty(ourSession.Context.WorkingDirectory), "Expected context.WorkingDirectory to be non-empty when context is present");
454454
}
455455
}
456456

dotnet/test/E2E/SessionFsE2ETests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class SessionFsE2ETests(E2ETestFixture fixture, ITestOutputHelper output)
1515
{
1616
private static readonly SessionFsConfig SessionFsConfig = new()
1717
{
18-
InitialCwd = "/",
18+
InitialWorkingDirectory = "/",
1919
SessionStatePath = CreateSessionStatePath(),
2020
Conventions = SessionFsSetProviderConventions.Posix,
2121
};

dotnet/test/E2E/SessionFsSqliteE2ETests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class SessionFsSqliteE2ETests(E2ETestFixture fixture, ITestOutputHelper o
1414
{
1515
private static readonly SessionFsConfig SessionFsConfig = new()
1616
{
17-
InitialCwd = "/",
17+
InitialWorkingDirectory = "/",
1818
SessionStatePath = "/session-state",
1919
Conventions = SessionFsSetProviderConventions.Posix,
2020
Capabilities = new SessionFsSetProviderCapabilities { Sqlite = true },

go/client.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ func validateSessionFsConfig(config *SessionFsConfig) error {
5858
if config == nil {
5959
return nil
6060
}
61-
if config.InitialCwd == "" {
62-
return errors.New("SessionFs.InitialCwd is required")
61+
if config.InitialWorkingDirectory == "" {
62+
return errors.New("SessionFs.InitialWorkingDirectory is required")
6363
}
6464
if config.SessionStatePath == "" {
6565
return errors.New("SessionFs.SessionStatePath is required")
@@ -353,7 +353,7 @@ func (c *Client) Start(ctx context.Context) error {
353353
// If a session filesystem provider was configured, register it.
354354
if c.options.SessionFs != nil {
355355
req := &rpc.SessionFsSetProviderRequest{
356-
InitialCwd: c.options.SessionFs.InitialCwd,
356+
InitialCwd: c.options.SessionFs.InitialWorkingDirectory,
357357
SessionStatePath: c.options.SessionFs.SessionStatePath,
358358
Conventions: c.options.SessionFs.Conventions,
359359
}
@@ -945,7 +945,7 @@ func (c *Client) ResumeSessionWithOptions(ctx context.Context, sessionID string,
945945
// Returns a list of SessionMetadata for all available sessions, including their IDs,
946946
// timestamps, optional summaries, and context information.
947947
//
948-
// An optional filter can be provided to filter sessions by cwd, git root, repository, or branch.
948+
// An optional filter can be provided to filter sessions by working directory, git root, repository, or branch.
949949
//
950950
// Example:
951951
//
@@ -1501,8 +1501,8 @@ func (c *Client) startCLIServer(ctx context.Context) error {
15011501
configureProcAttr(c.process)
15021502

15031503
// Set working directory if specified
1504-
if c.options.Cwd != "" {
1505-
c.process.Dir = c.options.Cwd
1504+
if c.options.WorkingDirectory != "" {
1505+
c.process.Dir = c.options.WorkingDirectory
15061506
}
15071507

15081508
c.process.Env = append([]string{}, c.options.Env...)

go/client_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,14 @@ func TestClient_URLParsing(t *testing.T) {
135135
}
136136

137137
func TestClient_SessionFsConfig(t *testing.T) {
138-
t.Run("should throw error when InitialCwd is missing", func(t *testing.T) {
138+
t.Run("should throw error when InitialWorkingDirectory is missing", func(t *testing.T) {
139139
defer func() {
140140
if r := recover(); r == nil {
141-
t.Error("Expected panic for missing SessionFs.InitialCwd")
141+
t.Error("Expected panic for missing SessionFs.InitialWorkingDirectory")
142142
} else {
143-
matched, _ := regexp.MatchString("SessionFs.InitialCwd is required", r.(string))
143+
matched, _ := regexp.MatchString("SessionFs.InitialWorkingDirectory is required", r.(string))
144144
if !matched {
145-
t.Errorf("Expected panic message to contain 'SessionFs.InitialCwd is required', got: %v", r)
145+
t.Errorf("Expected panic message to contain 'SessionFs.InitialWorkingDirectory is required', got: %v", r)
146146
}
147147
}
148148
}()
@@ -169,7 +169,7 @@ func TestClient_SessionFsConfig(t *testing.T) {
169169

170170
NewClient(&ClientOptions{
171171
SessionFs: &SessionFsConfig{
172-
InitialCwd: "/",
172+
InitialWorkingDirectory: "/",
173173
Conventions: rpc.SessionFsSetProviderConventionsPosix,
174174
},
175175
})

go/internal/e2e/client_options_e2e_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func TestClientOptionsE2E(t *testing.T) {
5656
}
5757

5858
client := ctx.NewClient(func(opts *copilot.ClientOptions) {
59-
opts.Cwd = clientCwd
59+
opts.WorkingDirectory = clientCwd
6060
})
6161
t.Cleanup(func() { client.ForceStop() })
6262

go/internal/e2e/session_e2e_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -894,8 +894,8 @@ func TestSessionE2E(t *testing.T) {
894894
// Verify context field is present on sessions
895895
for _, s := range sessions {
896896
if s.Context != nil {
897-
if s.Context.Cwd == "" {
898-
t.Error("Expected context.Cwd to be non-empty when context is present")
897+
if s.Context.WorkingDirectory == "" {
898+
t.Error("Expected context.WorkingDirectory to be non-empty when context is present")
899899
}
900900
}
901901
}
@@ -1006,8 +1006,8 @@ func TestSessionE2E(t *testing.T) {
10061006

10071007
// Verify context field
10081008
if metadata.Context != nil {
1009-
if metadata.Context.Cwd == "" {
1010-
t.Error("Expected context.Cwd to be non-empty when context is present")
1009+
if metadata.Context.WorkingDirectory == "" {
1010+
t.Error("Expected context.WorkingDirectory to be non-empty when context is present")
10111011
}
10121012
}
10131013

go/internal/e2e/session_fs_e2e_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestSessionFsE2E(t *testing.T) {
2020
providerRoot := t.TempDir()
2121
sessionStatePath := createSessionStatePath(t)
2222
sessionFsConfig := &copilot.SessionFsConfig{
23-
InitialCwd: "/",
23+
InitialWorkingDirectory: "/",
2424
SessionStatePath: sessionStatePath,
2525
Conventions: rpc.SessionFsSetProviderConventionsPosix,
2626
}

0 commit comments

Comments
 (0)