Skip to content

feat: add canvas create command#65

Closed
heo001997 wants to merge 2 commits into
shaharia-lab:mainfrom
heo001997:feat/canvas-create
Closed

feat: add canvas create command#65
heo001997 wants to merge 2 commits into
shaharia-lab:mainfrom
heo001997:feat/canvas-create

Conversation

@heo001997

@heo001997 heo001997 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds slackcli canvas create — the C in canvas CRUD. First of a 3-PR series (create → edit → delete) building on #31 (list + read).

Closes #62

What's added

  • canvas create subcommand — --title, --content / --file / --stdin (mutually-exclusive markdown sources), --channel, --json, --workspace.
  • SlackClient.createCanvas() → wraps canvases.create, JSON-wraps document_content as {type:"markdown", markdown}. No auth-type special-casing — routes through the existing request() dispatcher (works with standard + browser tokens).
  • Types: CanvasCreateOptions, CanvasDocumentContent.
  • README: create examples + token-support note — canvas create needs a Standard token (xoxb/xoxp) with canvases:write; browser tokens (xoxc/xoxd) can't do canvas CUD; list + read work with both.
  • CHANGELOG entry.

Tests

  • New src/commands/canvas.test.ts — unit tests for buildCreateParams (title-only, markdown→document_content, channel→channel_id, empty) and resolveCanvasMarkdown (mutual exclusion, inline content, missing-file error).
  • bun test188 pass / 0 fail. bun run build → ok.
  • Live-verified on a real workspace with a standard xoxp token: created a canvas tabbed into a channel; canvas_id returned.

Manual Tests

  • Create canvas - Inline / From file / Stdin / Empty => OK!
image image image image image image

Notes

@heo001997 heo001997 marked this pull request as ready for review June 9, 2026 07:11

@shahariaazam shahariaazam left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR. I have requested few changes

Comment thread src/commands/canvas.ts
* be unit-tested without a network call. document_content is JSON-stringified
* to match how the Slack API expects nested objects over form-encoding.
*/
export function buildCreateParams(input: {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Major: tested function is not the one that runs

Why: buildCreateParams duplicates the param logic in SlackClient.createCanvas (slack-client.ts:461-470), but the create action only calls createCanvas. The 6 unit tests assert on buildCreateParams, so the production builder is untested and the suite stays green even if it breaks. Two copies will drift.

Fix: keep one builder (in the client), test that one, and remove buildCreateParams.

Comment thread README.md
> |---|:---:|:---:|
> | `canvas list` | ✅ | ✅ |
> | `canvas read` | ✅ | ✅ |
> | `canvas create` | ✅ (needs `canvases:write`) | ❌ |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Major: contradictory browser-token claim

Why: this table says canvas create with a browser token is not supported, but CHANGELOG.md:15 says it requires canvases:write "or browser auth" and the PR body says it works with both. The code routes through request() which dispatches to browserRequest, and only a standard token was live-tested, so the not-supported claim is unverified and inconsistent.

Fix: test canvases.create with a browser token, then make README and CHANGELOG agree.

Comment thread src/types/index.ts
markdown: string;
}

export interface CanvasCreateOptions {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor: unused types

Why: CanvasCreateOptions and CanvasDocumentContent are never imported. The action's options is untyped and both builders inline JSON.stringify({type:'markdown', markdown}) instead of CanvasDocumentContent.

Fix: type the action param as CanvasCreateOptions and use CanvasDocumentContent, or remove the types.

@heo001997 heo001997 closed this Jun 21, 2026
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: add canvas create command

2 participants