chore: integrate coder/quartz by johnstcn · Pull Request #175 · coder/agentapi

Pull request overview

This pull request integrates the coder/quartz library to provide a clock abstraction throughout the codebase, enabling better testability by allowing time-dependent code to use mock clocks in tests.

Changes:

  • Added github.com/coder/quartz dependency to replace direct time package usage
  • Replaced time.Now(), time.Sleep(), time.After(), and time.Since() calls with clock-based equivalents
  • Updated test files to use quartz.NewMock(t) for deterministic time-based testing

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
go.mod Added github.com/coder/quartz v0.1.2 dependency and removed unused go.uber.org/atomic
go.sum Updated dependency checksums including quartz and transitive dependencies
lib/util/util.go Added Clock field to WaitTimeout struct and replaced time operations with clock-based equivalents
lib/termexec/termexec.go Added clock field to Process struct and replaced time operations with clock methods
lib/screentracker/conversation.go Replaced GetTime function with Clock field and updated all time operations to use the clock
lib/screentracker/conversation_test.go Updated tests to use mock clocks for deterministic testing
lib/httpapi/server.go Added clock field to Server struct and updated ticker usage in snapshot loop

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.