Add thread rename support

This commit is contained in:
Codex
2026-05-21 09:31:47 +00:00
parent ad61f7eeed
commit bc866d1224
7 changed files with 197 additions and 4 deletions

View File

@@ -224,6 +224,17 @@ func (c *Client) ArchiveThread(ctx context.Context, threadID string) error {
return c.call(ctx, "thread/archive", map[string]any{"threadId": threadID}, &ignored)
}
func (c *Client) SetThreadName(ctx context.Context, threadID, name string) error {
if err := c.EnsureConnected(ctx); err != nil {
return err
}
var ignored json.RawMessage
return c.call(ctx, "thread/setName", map[string]any{
"threadId": threadID,
"name": name,
}, &ignored)
}
func (c *Client) StartTurn(ctx context.Context, threadID, cwd, model, reasoningEffort, sandbox string, input []InputItem) (Turn, error) {
if err := c.EnsureConnected(ctx); err != nil {
return Turn{}, err

View File

@@ -86,6 +86,26 @@ func TestClientWebSocketUnixJSONRPC(t *testing.T) {
return
}
var setName map[string]any
if err := conn.ReadJSON(&setName); err != nil {
serverDone <- err
return
}
if setName["method"] != "thread/setName" {
serverDone <- unexpectedMessage("thread/setName", setName["method"])
return
}
params := setName["params"].(map[string]any)
if params["threadId"] != "thr_1" || params["name"] != "Short title" {
payload, _ := json.Marshal(params)
serverDone <- unexpectedMessage("thread/setName params", string(payload))
return
}
if err := conn.WriteJSON(map[string]any{"id": setName["id"], "result": map[string]any{}}); err != nil {
serverDone <- err
return
}
var response map[string]any
if err := conn.ReadJSON(&response); err != nil {
serverDone <- err
@@ -125,6 +145,9 @@ func TestClientWebSocketUnixJSONRPC(t *testing.T) {
if thread.ID != "thr_1" {
t.Fatalf("unexpected thread: %+v", thread)
}
if err := client.SetThreadName(ctx, "thr_1", "Short title"); err != nil {
t.Fatal(err)
}
if err := client.RespondServerRequest(ctx, 99, "accept"); err != nil {
t.Fatal(err)
}