Skip to content

feat(attachments): work item attachments and inline description images - #12

Merged
cpatrickalves merged 10 commits into
cpatrickalves:mainfrom
Liewzheng:feat/work-item-attachments
Nov 17, 2026
Merged

cpatrickalves merged 10 commits into
cpatrickalves:mainfrom
Liewzheng:feat/work-item-attachments

Conversation

@Liewzheng

@Liewzheng Liewzheng commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #11. Rebased onto main (v0.6.0). The three comment-converter commits are dropped, because main already has utils/body_html.py; #40 tracks the work they covered. @Liewzheng's commit is kept as is, and the review fixes sit on top of it.

attachment attach ISSUE -f FILE [--force]
  require_file(FILE)                  # exit 5 before any config or API call
  resolve item
  upload_attachment
    list (raw _get) -> duplicate name?  TTY: ask on stderr / no TTY: exit 5, names --force
    register -> POST to presigned storage (timeout 300 s) -> PATCH is_uploaded -> read back

wi create TITLE -d TEXT -i IMG...
  require_file(each IMG)              # nothing written on a bad path
  resolve project, state, labels, module
  create (with -d)
  upload_embed_image per IMG          # v2 ISSUE_DESCRIPTION, v1 fallback on 401/403/404
  one update: -d + <p><img src="ASSET_UUID" /></p>...
  enrich once

wi update ISSUE -i IMG... [--force]
  require_file(each IMG)
  resolve item, state, labels, assignee, estimate
  upload_embed_image per IMG          # last, after every resolver
  one update

Review fixes on top of the original commit:

  • -d is kept in the create call. Before, wi create -d ... -i created the item with no description, and a failed upload left it that way.
  • The item is enriched once. A second pass blanked priority and doubled the prefix (ABC-ABC-5).
  • .md, .markdown and .log upload as text/plain. A self-hosted server rejected text/markdown with 400 Invalid file type.
  • A storage timeout or refused connection exits 4 instead of printing a traceback.
  • attachment ls hides deleted attachments.
  • wi create loses --force, since a new item can't have duplicate names. On wi update, the help says --force only applies to the v1 fallback.
  • wi create --module is resolved before the create, so a mistyped module no longer leaves an item behind.
  • ADR-0008 is amended for the duplicate-name prompt, the only prompt in the CLI: it asks on a TTY only and writes to stderr. ADR-0003 records the attachment and asset bypasses, and each call site has a NOTE:.
  • README, skills/ (version 1.9.x), the command reference, CHANGELOG and docs/caching.md are updated.

Evidence

  • Before: uv run pytest tests/test_commands/test_attachments.py with no Plane config gave 1 failed, 13 passed: test_attach_rejects_missing_file raised AuthenticationError: Missing base URL. ruff format --check flagged 3 files.
    After: make check passes with no PLANE_* vars and no ~/.plane_api: 304 tests pass, plus lint and format-check.
  • Before: wi create "Bug" -p P --priority high -d "Steps" -i shot.png --json returned "priority": "" and a description without <p>Steps</p>.
    After: live run against a self-hosted Plane:
wi create ... --priority high -d "Live test of PR 12" -i red.png   -> exit 0, priority "high",
    description "<p>Live test of PR 12</p><p><img src="8adc9c0f-..." /></p>"
attachment attach -f notes.md                                         -> exit 0, text/plain, uploaded
attachment attach -f blue.png  (again, stdin </dev/null)              -> exit 5, stdout empty,
    "Upload cancelled: 'planecli-test-blue.png' is already attached (1x). Re-run with --force to upload anyway."
wi update -i typo.png --state "Qzxwv Nonexistent"                     -> exit 3, no upload
wi update -i green.png                                                -> exit 0, existing description kept, image appended

The test item was deleted afterwards.

Merge Danger

Door: two-way. Everything is new code paths and docs, with no schema or cache changes. The one thing that's hard to take back is the attachment command name and its --json shape (name, type and size at the top level), which scripts will start to depend on.

Blast Radius: small.

Existing commands change in two places: wi create/wi update gain -i/--image, and wi create --module now resolves before the item is created. Without -i, -d behaves exactly as before.

@nogara

nogara commented Oct 20, 2026

Copy link
Copy Markdown

Thanks for this. I've been running it on a fork. Two tests fail on a machine with no Plane config (~/.plane_api absent, no PLANE_* env vars), as in CI:

  • test_attach_rejects_missing_file: attach resolves the work item before checking the file, so it raises AuthenticationError: Missing base URL instead of the file-not-found ValidationError. Checking the file first fixes it, and a bad path then fails before any config or network access:

    # Fail on a bad path before touching the config or the network.
    if not os.path.isfile(file):
        raise ValidationError(f"File not found: {file}")
  • test_guess_mime_known_extension: mimetypes has no .md entry on some platforms (the uv-managed CPython 3.12 on macOS returns None), so the result is application/octet-stream. A small fallback map fixes it:

    _EXTRA_MIME = {".md": "text/markdown", ".markdown": "text/markdown", ".log": "text/plain"}
    
    def _guess_mime(filename: str) -> str:
        mime, _ = mimetypes.guess_type(filename)
        return mime or _EXTRA_MIME.get(Path(filename).suffix.lower(), "application/octet-stream")

Both changes are in commit cf8115c on nogara/plane-cli feat/attachment-download if you want to cherry-pick it.

Liewzheng and others added 10 commits November 17, 2026 12:05
Add an `attachment` sub-app with `attach`/`ls` commands, backed by a
three-step upload flow (register for a presigned S3 URL, PUT the binary,
PATCH is_uploaded and verify the write — see ADRs 0003 and 0007).
Duplicate asset names are rejected unless the user confirms.

`wi create`/`wi update` gain repeatable `-i/--image` flags that upload an
image and append it to the description. The img src stores only the
asset UUID — the web editor resolves it via getAssetSrc, so storing a
full path breaks image rendering ("Error loading image").

The v2 app upload endpoint (ISSUE_DESCRIPTION) is preferred and
automatically falls back to v1 when the server rejects API-token auth;
asset UUIDs stay interchangeable across both paths.
…d last, enrich once (cpatrickalves#11)

wi create -i sent no description in the create call and enriched the item twice (blank priority, doubled sequence_id prefix). wi update -i uploaded before resolving state and labels. Both now check every -i path before any API call, and --force leaves wi create, where a new item has no attachments to collide with.
…ckalves#11)

Some Plane servers reject text/markdown with 400 "Invalid file type.", and platforms without /etc/mime.types know none of these extensions. text/plain is accepted everywhere.
…items and test gaps (cpatrickalves#11)

A storage timeout or refused connection now exits 4 instead of a traceback. attachment ls hides deleted attachments, as the duplicate guard already did, and keeps a top-level name when attributes lack one. A file named just .md uploads as text/plain. wi create resolves --module before creating the item.

Tests: load the MIME table before patching os.path.isfile/open (four tests hung when run alone), assert the register and PATCH payloads and the exact error messages, and cover the TTY answer through upload_attachment, the 401/403/404 fallback with --force, the deleted-duplicate case and the remaining exit codes.
@cpatrickalves

Copy link
Copy Markdown
Owner

@Liewzheng thanks for this feature. A heads-up before it merges: I rebased your branch onto main and force-pushed it, so its history changed.

If you have local work on feat/work-item-attachments, reset it to the fork's branch before pushing again.

@cpatrickalves cpatrickalves left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Approved after the rebase and review fixes: make check, CI on 3.11–3.13 and a live run against a self-hosted Plane pass.

@cpatrickalves
cpatrickalves merged commit f72e415 into cpatrickalves:main Nov 17, 2026
3 checks passed
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.

feat: work item attachments and inline description images

4 participants