Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions internal/cmd/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ func forkSession(srcPath, dstPath, newSessionID, targetDir string) (*forkResult,

var record map[string]any
if err := json.Unmarshal([]byte(line), &record); err != nil {
writer.WriteString(line)
writer.WriteByte('\n')
_, _ = writer.WriteString(line)
_ = writer.WriteByte('\n')
lineCount++
continue
}
Expand All @@ -160,14 +160,14 @@ func forkSession(srcPath, dstPath, newSessionID, targetDir string) (*forkResult,

rewritten, err := json.Marshal(record)
if err != nil {
writer.WriteString(line)
writer.WriteByte('\n')
_, _ = writer.WriteString(line)
_ = writer.WriteByte('\n')
lineCount++
continue
}

writer.Write(rewritten)
writer.WriteByte('\n')
_, _ = writer.Write(rewritten)
_ = writer.WriteByte('\n')
lineCount++
}

Expand Down
12 changes: 6 additions & 6 deletions internal/cmd/fork_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestForkRewritesSessionIDAndCWD(t *testing.T) {
scanner := bufio.NewScanner(f)
for scanner.Scan() {
var record map[string]any
json.Unmarshal([]byte(scanner.Text()), &record)
_ = json.Unmarshal([]byte(scanner.Text()), &record)

if sid, ok := record["sessionId"].(string); ok {
if sid != "new-session-id" {
Expand Down Expand Up @@ -92,7 +92,7 @@ func TestForkDropsFileHistorySnapshot(t *testing.T) {
`{"type":"user","sessionId":"old","cwd":"/old","uuid":"u1","message":{"role":"user","content":"hi"}}`,
`{"type":"file-history-snapshot","messageId":"m2","snapshot":{},"isSnapshotUpdate":true}`,
}
os.WriteFile(srcPath, []byte(strings.Join(lines, "\n")+"\n"), 0644)
_ = os.WriteFile(srcPath, []byte(strings.Join(lines, "\n")+"\n"), 0644)

result, err := forkSession(srcPath, dstPath, "new-id", "/new")
if err != nil {
Expand All @@ -117,7 +117,7 @@ func TestForkNullsWorktreeState(t *testing.T) {
`{"type":"user","sessionId":"old","cwd":"/old","uuid":"u1","message":{"role":"user","content":"hi"}}`,
`{"type":"worktree-state","worktreeSession":{"worktreePath":"/old/worktree"},"worktreePath":"/old/worktree"}`,
}
os.WriteFile(srcPath, []byte(strings.Join(lines, "\n")+"\n"), 0644)
_ = os.WriteFile(srcPath, []byte(strings.Join(lines, "\n")+"\n"), 0644)

_, err := forkSession(srcPath, dstPath, "new-id", "/new")
if err != nil {
Expand All @@ -129,7 +129,7 @@ func TestForkNullsWorktreeState(t *testing.T) {
scanner := bufio.NewScanner(f)
for scanner.Scan() {
var record map[string]any
json.Unmarshal([]byte(scanner.Text()), &record)
_ = json.Unmarshal([]byte(scanner.Text()), &record)
if record["type"] == "worktree-state" {
if record["worktreeSession"] != nil {
t.Error("worktreeSession should be null in forked output")
Expand All @@ -151,9 +151,9 @@ func TestForkPreservesParentUUIDChain(t *testing.T) {
`{"type":"assistant","sessionId":"old","cwd":"/old","uuid":"a1","parentUuid":"u1","message":{"role":"assistant","content":"a"}}`,
`{"type":"user","sessionId":"old","cwd":"/old","uuid":"u2","parentUuid":"a1","message":{"role":"user","content":"q2"}}`,
}
os.WriteFile(srcPath, []byte(strings.Join(lines, "\n")+"\n"), 0644)
_ = os.WriteFile(srcPath, []byte(strings.Join(lines, "\n")+"\n"), 0644)

forkSession(srcPath, dstPath, "new-id", "/new")
_, _ = forkSession(srcPath, dstPath, "new-id", "/new")

f, _ := os.Open(dstPath)
defer f.Close()
Expand Down
Loading