Skip to content

fix: expose conversionId in convert --async and add --timeout flag (#22)#25

Merged
rarce merged 3 commits into
mainfrom
feat/issue-22-expose-conversionid-timeout
Apr 8, 2026
Merged

fix: expose conversionId in convert --async and add --timeout flag (#22)#25
rarce merged 3 commits into
mainfrom
feat/issue-22-expose-conversionid-timeout

Conversation

@rarce
Copy link
Copy Markdown
Contributor

@rarce rarce commented Apr 8, 2026

Summary

  • Print conversion_id to stderr immediately after runAsync returns (before polling starts) and in every polling status update
  • Add --timeout <seconds> flag (default: 300) to control async polling duration, passed to SDK's .wait() in milliseconds
  • Enrich timeout errors with conversion_id and recovery hint so users can check results later

🔗 Related Issue

Closes #22 (bundles #8 and #10)

✅ Acceptance Criteria

  • conversion_id printed to stderr immediately after runAsync
  • Each polling status update includes conversion_id
  • TTY format: ⟳ Conversion <id>: <STATUS>
  • JSON format: {"conversionId":"<id>","status":"<STATUS>"}
  • Timeout error includes conversion_id
  • --timeout <seconds> flag controls polling timeout (default: 300)
  • Timeout value passed to SDK .wait() in milliseconds

🧪 Testing

  • 5 new tests covering: conversion_id in stderr, timeout passed in ms, default timeout, enriched timeout error, JSON status output with conversionId
  • All 100 tests passing
  • Build successful

🤖 Generated with Claude Code

Print conversion_id to stderr immediately after runAsync and in each
polling status update. Enrich timeout errors with the conversion_id so
users can recover results later. Add --timeout flag (default 300s) to
control polling duration for large documents.

Closes #22

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the UX of docutray convert --async by making the async conversion identifier visible during polling and by adding a configurable polling timeout.

Changes:

  • Print conversion_id immediately after runAsync() returns and include it in each polling status update (TTY + JSON to stderr).
  • Add --timeout <seconds> (default 300) and pass it to the SDK .wait() as milliseconds.
  • Add tests for conversion id output, timeout propagation/default, and JSON polling status output; update help snapshot.

Reviewed changes

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

File Description
src/commands/convert.ts Adds --timeout, prints conversion id + status during async polling, and enriches polling errors.
test/commands/convert.test.ts Adds new async-focused tests (conversion id output, timeout passed/default, JSON status output).
test/snapshots/help.test.ts.snap Updates CLI help snapshot for the new --timeout flag and example.

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

Comment thread src/commands/convert.ts Outdated
Comment thread src/commands/convert.ts
Comment thread src/commands/convert.ts Outdated
Comment thread test/commands/convert.test.ts
… tests

- Remove redundant "(default: 300)" from --timeout description
- Add min:1 validation to --timeout flag to reject 0/negative values
- Only enrich timeout errors with conversionId; rethrow other errors
  intact to preserve statusCode/body/requestId for outputError()
- Add TTY format test for conversion_id in stderr
- Add test verifying non-timeout API errors are not wrapped

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rarce rarce merged commit 107cca3 into main Apr 8, 2026
6 checks passed
@rarce rarce deleted the feat/issue-22-expose-conversionid-timeout branch April 8, 2026 01:13
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.

fix: expose conversionId in convert --async and add --timeout flag

2 participants