Skip to content

stats/status-line resolve analytics DB inconsistently with dispatch (config db_path ignored) #105

Description

@vishnujayvel

Problem

Found while live-verifying the cost-tracking writer (#103). Commands resolve the analytics DB path inconsistently:

  • dispatch (the writer) uses config.Analytics.DBPath from the loaded config.
  • stats uses a --data-dir flag that defaults to ~/.hookwise/analytics.db (DefaultDBPath) and does not read config.Analytics.DBPath or honor HOOKWISE_STATE_DIR.

So if a user sets a custom analytics.db_path, dispatch writes cost into the custom DB but stats reads the default DB and shows $0. (Repro: set analytics.db_path to a temp file, dispatch a Stop with a transcript → custom DB gets total_today/estimated_cost_usd, but hookwise stats shows $0 from ~/.hookwise/analytics.db.)

Default config (no custom db_path) is unaffected since both land on ~/.hookwise/analytics.db.

Likely also affected

The cost status-line segment / renderCostSegment path — confirm it resolves the DB the same way dispatch does.

Fix direction

Make stats (and the status-line cost path) default dataDir from the loaded config's Analytics.DBPath (falling back to DefaultDBPath) so reader and writer agree. Same class as #104 (doctor reads real ~/.hookwise).

Severity: low-medium (silent $0 under custom db_path), but it undermines confidence in the brand-new cost feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions