addSessionTx inserts a session within a transaction.
(ctx context.Context, tx *sql.Tx, session *Session)
| 1119 | |
| 1120 | // addSessionTx inserts a session within a transaction. |
| 1121 | func (s *SQLiteSessionStore) addSessionTx(ctx context.Context, tx *sql.Tx, session *Session) error { |
| 1122 | fields, err := sessionPersistedFieldsOf(session) |
| 1123 | if err != nil { |
| 1124 | return err |
| 1125 | } |
| 1126 | |
| 1127 | _, err = tx.ExecContext(ctx, |
| 1128 | `INSERT INTO sessions ( |
| 1129 | id, tools_approved, input_tokens, output_tokens, title, cost, send_user_message, |
| 1130 | max_iterations, working_dir, created_at, starred, permissions, agent_model_overrides, |
| 1131 | custom_models_used, thinking, parent_id |
| 1132 | ) |
| 1133 | VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, |
| 1134 | session.ID, session.ToolsApproved, session.InputTokens, session.OutputTokens, |
| 1135 | session.Title, session.Cost, session.SendUserMessage, session.MaxIterations, |
| 1136 | session.WorkingDir, session.CreatedAt.Format(time.RFC3339), session.Starred, |
| 1137 | fields.PermissionsJSON, fields.AgentModelOverridesJSON, fields.CustomModelsUsedJSON, false, |
| 1138 | fields.ParentID) |
| 1139 | return err |
| 1140 | } |
| 1141 | |
| 1142 | // addItemTx inserts a session item within a transaction. |
| 1143 | func (s *SQLiteSessionStore) addItemTx(ctx context.Context, tx *sql.Tx, sessionID string, position int, item Item) error { |
no test coverage detected