Skip to content

Commit 4ffdb92

Browse files
committed
Remove unused branch metadata and split_diff_view from sessions
Remove BranchParentSessionID, BranchParentPosition, and BranchCreatedAt fields from the Session struct and Summary struct. These were stored and persisted but never read for any logic or UI display. The branching mechanism itself (BranchSession) remains functional - only the provenance metadata that nothing consumed is removed. Also drops the split_diff_view column which was already ignored in code. Adds migration 019 to drop the columns and index from SQLite.
1 parent ebd216e commit 4ffdb92

6 files changed

Lines changed: 78 additions & 170 deletions

File tree

pkg/session/branch.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"maps"
77
"slices"
88
"strings"
9-
"time"
109

1110
"github.com/docker/docker-agent/pkg/chat"
1211
)
@@ -24,11 +23,6 @@ func BranchSession(parent *Session, branchAtPosition int) (*Session, error) {
2423
branched := New()
2524
copySessionMetadata(branched, parent, generateBranchTitle(parent.Title))
2625

27-
now := time.Now()
28-
branched.BranchParentSessionID = parent.ID
29-
branched.BranchParentPosition = &branchAtPosition
30-
branched.BranchCreatedAt = &now
31-
3226
branched.Messages = make([]Item, 0, branchAtPosition)
3327
for i := range branchAtPosition {
3428
cloned, err := cloneSessionItem(parent.Messages[i])

pkg/session/branch_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,6 @@ func TestBranchSession(t *testing.T) {
135135

136136
assert.NotEqual(t, parent.ID, branched.ID)
137137
assert.Equal(t, "Parent Title (branched)", branched.Title)
138-
assert.Equal(t, parent.ID, branched.BranchParentSessionID)
139-
assert.NotNil(t, branched.BranchParentPosition)
140-
assert.Equal(t, 2, *branched.BranchParentPosition)
141-
assert.NotNil(t, branched.BranchCreatedAt)
142-
143138
assert.Len(t, branched.Messages, 2)
144139
assert.Equal(t, "msg1", branched.Messages[0].Message.Message.Content)
145140
assert.Equal(t, "msg2", branched.Messages[1].Message.Message.Content)

pkg/session/migrations.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,18 @@ func getAllMigrations() []Migration {
332332
Description: "Add index on session_items(session_id, item_type) to speed up session summary message counts",
333333
UpSQL: `CREATE INDEX IF NOT EXISTS idx_session_items_session_type ON session_items(session_id, item_type)`,
334334
},
335+
{
336+
ID: 19,
337+
Name: "019_drop_branch_and_split_diff_columns",
338+
Description: "Drop unused branch metadata columns and split_diff_view column",
339+
UpSQL: `
340+
DROP INDEX IF EXISTS idx_sessions_branch_parent;
341+
ALTER TABLE sessions DROP COLUMN branch_parent_session_id;
342+
ALTER TABLE sessions DROP COLUMN branch_parent_position;
343+
ALTER TABLE sessions DROP COLUMN branch_created_at;
344+
ALTER TABLE sessions DROP COLUMN split_diff_view;
345+
`,
346+
},
335347
}
336348
}
337349

pkg/session/session.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,6 @@ type Session struct {
113113
// These are shown in the model picker for easy re-selection.
114114
CustomModelsUsed []string `json:"custom_models_used,omitempty"`
115115

116-
// BranchParentSessionID indicates this session was branched from another session.
117-
BranchParentSessionID string `json:"branch_parent_session_id,omitempty"`
118-
119-
// BranchParentPosition is the parent session item position where this branch occurred.
120-
// Only set when BranchParentSessionID is non-empty.
121-
BranchParentPosition *int `json:"branch_parent_position,omitempty"`
122-
123-
// BranchCreatedAt is the time when this branch session was created.
124-
BranchCreatedAt *time.Time `json:"branch_created_at,omitempty"`
125-
126116
// AgentName, when set, tells RunStream which agent to use for this session
127117
// instead of reading from the shared runtime currentAgent field. This is
128118
// required for background agent tasks where multiple sessions may run

0 commit comments

Comments
 (0)