Skip to content

Commit cff9854

Browse files
committed
fix(codebuff): timestamp timezone and reconciliation performance
1. Timestamp timezone: Convert UTC session directory timestamp to local time before combining with wall-clock timestamps, preventing shifted session bounds for non-UTC users. 2. Reconciliation performance: Added Codebuff case to providerSourceFreshBeforeFingerprint that computes a composite stat-only value across all three files (chat-messages.json, run-state.json, chat-meta.json) and checks the skip cache before content hashing. This reduces background I/O for unchanged sessions.
1 parent d7facf6 commit cff9854

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

internal/parser/codebuff.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,14 +411,16 @@ func readCodebuffChatMeta(path string) codebuffChatMeta {
411411

412412
// parseCodebuffSessionDate parses the session directory name as an ISO 8601
413413
// timestamp. The directory name format is "2026-07-16T00-09-00.236Z".
414+
// The returned time is always in the local timezone so that time-only
415+
// message timestamps (HH:MM PM) combine correctly with the date.
414416
func parseCodebuffSessionDate(sessionID string) time.Time {
415417
// Try full ISO format with milliseconds and Z suffix.
416418
if ts, err := time.Parse("2006-01-02T15-04-05.999Z", sessionID); err == nil {
417-
return ts
419+
return ts.In(time.Local)
418420
}
419421
// Try without milliseconds.
420422
if ts, err := time.Parse("2006-01-02T15-04-05Z", sessionID); err == nil {
421-
return ts
423+
return ts.In(time.Local)
422424
}
423425
// Try with milliseconds, no Z. Interpret as local time since
424426
// codebuff records wall-clock timestamps without a UTC offset.

internal/sync/engine.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8405,6 +8405,32 @@ func (e *Engine) providerSourceFreshBeforeFingerprint(
84058405
if e.shouldSkipByPath(path, effectiveInfo) {
84068406
return mtime, true
84078407
}
8408+
case parser.AgentCodebuff:
8409+
// Codebuff's fingerprint is composite (chat-messages.json
8410+
// plus run-state.json and chat-meta.json). The stat-only
8411+
// composite below matches the stored Size/Mtime the fingerprint
8412+
// stamps, so unchanged sessions skip without reading transcript
8413+
// bytes, and a sibling-only change still changes the composite
8414+
// and falls through to the full fingerprint.
8415+
dir := filepath.Dir(path)
8416+
size := info.Size()
8417+
mtime := info.ModTime().UnixNano()
8418+
for _, name := range []string{"run-state.json", "chat-meta.json"} {
8419+
companion := filepath.Join(dir, name)
8420+
if ci, err := os.Stat(companion); err == nil {
8421+
size += ci.Size()
8422+
if cm := ci.ModTime().UnixNano(); cm > mtime {
8423+
mtime = cm
8424+
}
8425+
}
8426+
}
8427+
effectiveInfo := fakeSnapshotInfo{
8428+
fSize: size,
8429+
fMtime: mtime,
8430+
}
8431+
if e.shouldSkipByPath(path, effectiveInfo) {
8432+
return mtime, true
8433+
}
84088434
}
84098435
return 0, false
84108436
}

0 commit comments

Comments
 (0)