Commit c712b29
Implement the /publish slash command to push local sites to WP.com (#4043)
## Related issues
<!--
Link a related issue to this PR. If the PR does not immediately resolve
the issue,
for example, it requires a separate deployment to production, avoid
using the "Fixes" keyword and use "Related to" instead.
-->
Fixes STU-1552
## How AI was used in this PR
<!--
Help reviewers understand what to look for and verify that you've
reviewed the code yourself.
-->
## Proposed Changes
<!--
Explain the intent of this PR:
- What problem does it solve, or what need does it address?
- How does it affect the user (new capability, fix, performance,
accessibility, etc.)?
- Note any user-visible behavior changes or trade-offs.
Focus on the "why" and the user impact. Avoid listing modified files or
describing implementation mechanics — the diff already shows that.
-->
This PR adds a `/publish` command for publishing local sites to WP.com.
## Testing Instructions
<!--
Add as many details as possible to help others reproduce the issue and
test the fix.
"Before / After" screenshots can also be very helpful when the change is
visual.
-->
* Pull the changes from this branch
* Build CLI with `npm run cli:build`
* Launch Studio code with `node apps/cli/dist/cli/main.mjs code`
* Ensure that you have no sites selected first
* Type `publish`
* Confirm that you are encouraged to select a site
<img width="738" height="204" alt="Screenshot 2026-07-02 at 10 46 23 AM"
src="https://github.com/user-attachments/assets/70596d4a-6a28-40ca-bdc6-d1f7afd37482"
/>
* Once the site is selected, type `/publish` again
* Select a remote site to publish to
* Start push process
* Confirm that it goes through
* Then, test with `/publish` command for an account that does not have
any remote sites (you can use this diff and will need to rebuild CLI):
```diff --git a/apps/cli/ai/slash-commands.ts b/apps/cli/ai/slash-commands.ts
index e56a72b..ebf34e5de 100644
--- a/apps/cli/ai/slash-commands.ts
+++ b/apps/cli/ai/slash-commands.ts
@@ -515,7 +515,7 @@ export const AI_CHAT_SLASH_COMMANDS: SlashCommandDef[] = [
ctx.ui.showProgress( __( 'Fetching your WordPress.com sites…' ) );
ctx.ui.setBusy( true );
- const remoteSites = await fetchSyncableSites( token.accessToken );
+ const remoteSites: Awaited< ReturnType< typeof fetchSyncableSites > > = []; // TODO: remove mock
const syncable = remoteSites.filter( ( s ) => s.syncSupport === 'syncable' );
if ( syncable.length === 0 ) {
```
* Confirm it opens a link in the browser if you have no WP.com sites:
<img width="751" height="243" alt="Screenshot 2026-07-02 at 11 23 36 AM"
src="https://github.com/user-attachments/assets/bdc9f6cb-371e-491b-bc99-f3a055197f79"
/>
* Try using the `/publish` command when you are logged out and confirm
that you are asked to login first
## Pre-merge Checklist
<!--
Complete applicable items on this checklist **before** merging into
trunk. Inapplicable items can be left unchecked.
Both the PR author and reviewer are responsible for ensuring the
checklist is completed.
-->
- [ ] Have you checked for TypeScript, React or other console errors?
---------
Co-authored-by: Kateryna Kodonenko <kateryna@automattic.com>1 parent a6aa1dc commit c712b29
1 file changed
Lines changed: 94 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
493 | 495 | | |
494 | 496 | | |
495 | 497 | | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
496 | 590 | | |
497 | 591 | | |
498 | 592 | | |
| |||
0 commit comments