Skip to content

feat: include retry history in JSON output for send commands #21

Description

@dapi

Problem

When using --json mode, logSendRetry is completely suppressed — retry attempts produce zero output. If a command retries multiple times and eventually succeeds or fails, the user in JSON mode only sees the final result with attempts: N but has no visibility into what happened during retries.

Current Behavior

tgcli send photo --to @chan --photo ./img.png --retries 3 --json
# Output (success after 2 retries):
{"ok":true,"method":"sendPhoto","message_id":123,"attempts":3}
# No information about WHY it retried or what errors occurred

Proposed Solutions

Two complementary approaches:

Option A: Add retry log to final JSON payload

{
  "ok": true,
  "method": "sendPhoto",
  "message_id": 123,
  "attempts": 3,
  "retry_log": [
    {"attempt": 1, "error": {"type": "network", "message": "ECONNRESET", "code": "ECONNRESET"}},
    {"attempt": 2, "error": {"type": "network", "message": "ECONNRESET", "code": "ECONNRESET"}}
  ]
}

Option B: Write retry progress to stderr in JSON mode

Retry logs go to stderr (not stdout) so JSON parsers aren't affected.

Recommendation

Option A is more useful for programmatic consumers. Option B is simpler to implement. Both can coexist.

Context

Found during PR #18 review by silent-failure-hunter agent.

🤖 Generated with Claude Code

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