The open source coding agent.
TypeScript
chore: cleanup
adamdottv8270a1e4b133
diff --git a/internal/history/history.go b/internal/history/history.goindex 807b0e75b0b..4a72cb0437d 100644--- a/internal/history/history.go+++ b/internal/history/history.go@@ -323,7 +323,6 @@ func (s *service) Delete(ctx context.Context, id string) error {return nil}-// getServiceForPublish is an internal helper for Deletefunc (s *service) getServiceForPublish(ctx context.Context, id string) (*File, error) {// Assumes outer lock is NOT held or caller manages it.// For GetFile, it has its own RLock.@@ -368,45 +367,55 @@ func (s *service) fromDBItem(item db.File) File {Path: item.Path,Content: item.Content,Version: item.Version,- CreatedAt: item.CreatedAt * 1000, // DB stores seconds, Go struct uses milliseconds- UpdatedAt: item.UpdatedAt * 1000, // DB stores seconds, Go struct uses milliseconds+ CreatedAt: item.CreatedAt * 1000,+ UpdatedAt: item.UpdatedAt * 1000,}}-// --- Package-Level Wrapper Functions ---func Create(ctx context.Context, sessionID, path, content string) (File, error) {return GetService().Create(ctx, sessionID, path, content)}+func CreateVersion(ctx context.Context, sessionID, path, content string) (File, error) {return GetService().CreateVersion(ctx, sessionID, path, content)}+func Get(ctx context.Context, id string) (File, error) {return GetService().Get(ctx, id)}+func GetByPathAndVersion(ctx context.Context, sessionID, path, version string) (File, error) {return GetService().GetByPathAndVersion(ctx, sessionID, path, version)}+func GetLatestByPathAndSession(ctx context.Context, path, sessionID string) (File, error) {return GetService().GetLatestByPathAndSession(ctx, path, sessionID)}+func ListBySession(ctx context.Context, sessionID string) ([]File, error) {return GetService().ListBySession(ctx, sessionID)}+func ListLatestSessionFiles(ctx context.Context, sessionID string) ([]File, error) {return GetService().ListLatestSessionFiles(ctx, sessionID)}+func ListVersionsByPath(ctx context.Context, path string) ([]File, error) {return GetService().ListVersionsByPath(ctx, path)}+func Update(ctx context.Context, file File) (File, error) {return GetService().Update(ctx, file)}+func Delete(ctx context.Context, id string) error {return GetService().Delete(ctx, id)}+func DeleteSessionFiles(ctx context.Context, sessionID string) error {return GetService().DeleteSessionFiles(ctx, sessionID)}-func SubscribeToEvents(ctx context.Context) <-chan pubsub.Event[File] {++func Subscribe(ctx context.Context) <-chan pubsub.Event[File] {return GetService().Subscribe(ctx)}diff --git a/internal/logging/logging.go b/internal/logging/logging.goindex 850fd85d6b9..54f33989f41 100644--- a/internal/logging/logging.go+++ b/internal/logging/logging.go@@ -165,7 +165,7 @@ func ListAll(ctx context.Context, limit int) ([]Log, error) {return GetService().ListAll(ctx, limit)}-func SubscribeToEvents(ctx context.Context) <-chan pubsub.Event[Log] {+func Subscribe(ctx context.Context) <-chan pubsub.Event[Log] {return GetService().Subscribe(ctx)}diff --git a/internal/message/message.go b/internal/message/message.goindex 417121750a6..4c6726ca1ac 100644--- a/internal/message/message.go+++ b/internal/message/message.go@@ -286,53 +286,14 @@ func (s *service) fromDBItem(item db.Message) (Message, error) {return Message{}, fmt.Errorf("unmarshallParts for message ID %s: %w. Raw parts: %s", item.ID, err, item.Parts)}- // DB stores created_at, updated_at, finished_at as Unix seconds.- // Go struct Message stores them as Unix milliseconds.- createdAtMillis := item.CreatedAt * 1000- updatedAtMillis := item.UpdatedAt * 1000-msg := Message{ID: item.ID,SessionID: item.SessionID,Role: MessageRole(item.Role),Parts: parts,Model: models.ModelID(item.Model.String),- CreatedAt: createdAtMillis,- UpdatedAt: updatedAtMillis,- }-- // Ensure Finish part in msg.Parts reflects the item.FinishedAt state- // if item.FinishedAt is the source of truth for the "overall message finished time".- // The `unmarshallParts` should already create a Finish part if it's in the JSON.- // This logic reconciles the DB column with the JSON parts.- var existingFinishPart *Finish- var finishPartIndex = -1-- for i, p := range msg.Parts {- if fp, ok := p.(Finish); ok {- existingFinishPart = &fp- finishPartIndex = i- break- }- }-- if item.FinishedAt.Valid && item.FinishedAt.Int64 > 0 {- dbFinishTimeMillis := item.FinishedAt.Int64 * 1000- if existingFinishPart != nil {- // If a Finish part exists from JSON, update its time if DB's time is different.- // This assumes DB `finished_at` is the ultimate source of truth for when the message truly finished.- if existingFinishPart.Time != dbFinishTimeMillis {- slog.Debug("Aligning Finish part time with DB finished_at", "message_id", msg.ID, "json_finish_time", existingFinishPart.Time, "db_finish_time", dbFinishTimeMillis)- existingFinishPart.Time = dbFinishTimeMillis- msg.Parts[finishPartIndex] = *existingFinishPart- }- } else {- // If no Finish part in JSON but DB says it's finished, add one.- // We might not know the original FinishReason here, so use a sensible default or leave it to be set by Update.- // This scenario should be less common if `Update` always ensures a Finish part for finished messages.- slog.Debug("Synthesizing Finish part from DB finished_at", "message_id", msg.ID)- msg.Parts = append(msg.Parts, Finish{Reason: FinishReasonEndTurn, Time: dbFinishTimeMillis})- }+ CreatedAt: item.CreatedAt * 1000,+ UpdatedAt: item.UpdatedAt * 1000,}return msg, nil@@ -366,7 +327,7 @@ func DeleteSessionMessages(ctx context.Context, sessionID string) error {return GetService().DeleteSessionMessages(ctx, sessionID)}-func SubscribeToEvents(ctx context.Context) <-chan pubsub.Event[Message] {+func Subscribe(ctx context.Context) <-chan pubsub.Event[Message] {return GetService().Subscribe(ctx)}diff --git a/internal/session/session.go b/internal/session/session.goindex e377bfd213b..c3c4cf56ef7 100644--- a/internal/session/session.go+++ b/internal/session/session.go@@ -209,8 +209,8 @@ func (s *service) fromDBItem(item db.Session) Session {Cost: item.Cost,Summary: item.Summary.String,SummarizedAt: item.SummarizedAt.Int64,- CreatedAt: item.CreatedAt,- UpdatedAt: item.UpdatedAt,+ CreatedAt: item.CreatedAt * 1000,+ UpdatedAt: item.UpdatedAt * 1000,}}