Skip to content

bug: dry-run shows malformed stale message — missing duration string #70

@claude

Description

@claude

Description

When the cache is stale, uncompact dry-run renders the stale warning without the age duration, producing output like:

> Injected by Uncompact at 2026-02-27 12:00:00 UTC | ⚠️ STALE: last updated

instead of:

> Injected by Uncompact at 2026-02-27 12:00:00 UTC | ⚠️ STALE: last updated 3.2 hours ago

Root Cause

In cmd/status.go:245, store.Get() returns five values (graph, fresh, expiresAt, fetchedAt, err), but expiresAt and fetchedAt are silently discarded with _:

cachedGraph, fresh, _, _, err := store.Get(proj.Hash)

Then RenderOptions is built without StaleAt:

opts := tmpl.RenderOptions{
    MaxTokens:     maxTokens,
    Stale:         !fresh,
    WorkingMemory: wm,
    // StaleAt is missing!
}

In internal/template/render.go:99-101, StaleDuration is only populated when opts.StaleAt != nil:

if opts.Stale && opts.StaleAt != nil {
    data.StaleDuration = humanDuration(now.Sub(*opts.StaleAt))
}

So StaleDuration stays "" and the template emits a trailing space with no time string.

Fix

Capture expiresAt from store.Get() and pass it as StaleAt in RenderOptions:

cachedGraph, fresh, expiresAt, _, err := store.Get(proj.Hash)
// ...
opts := tmpl.RenderOptions{
    MaxTokens:     maxTokens,
    Stale:         !fresh,
    StaleAt:       expiresAt,
    WorkingMemory: wm,
}

Affected file: cmd/status.go, dryRunHandler function (~line 245).

@claude please implement this

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions