Skip to content

[codex] cache things-cli read state#10

Open
pdurlej wants to merge 1 commit into
arthursoares:mainfrom
pdurlej:codex/cache-cli-read-state
Open

[codex] cache things-cli read state#10
pdurlej wants to merge 1 commit into
arthursoares:mainfrom
pdurlej:codex/cache-cli-read-state

Conversation

@pdurlej

@pdurlej pdurlej commented May 19, 2026

Copy link
Copy Markdown

Summary

  • add an incremental local state cache for things-cli read commands
  • avoid the startup history.Sync() call for read-only commands
  • fetch only delta items after the cached server index, rebuilding from zero only when the cache cursor is ahead of the server
  • document THINGS_CLI_CACHE for overriding the cache file path
  • add tests for command classification and cache round-tripping

Context

Before this change, every read command rebuilt memory.State from start-index=0, and initCLI() also fetched history items before dispatching the command. That made commands like list, show, areas, projects, and tags pay a full-history cost on every invocation.

The cache stores the aggregated memory.State plus the last server index. On subsequent read commands, the CLI checks the current server index and applies only new history items to the cached state. Write commands still sync the history head before writing so ancestor-index stays valid.

This branch is independent of the pagination fix in #6: before fetching a delta page, it seeds history.LoadedServerIndex with the cached cursor so the current main implementation continues from the correct position.

Validation

  • go test ./cmd/things-cli -count=1
  • go test ./...

@pdurlej pdurlej marked this pull request as ready for review May 19, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant