Skip to content

feat: write an agent's presence row when it saves a post - #697

Merged
josephfusco merged 3 commits into
mainfrom
feat/656-agent-presence-on-post-save
Oct 1, 2026
Merged

josephfusco merged 3 commits into
mainfrom
feat/656-agent-presence-on-post-save

Conversation

@i-am-chitti

Copy link
Copy Markdown
Collaborator

Description

The row's expiry is wp_presence_idle_threshold() rather than the issue's 60s, as Joe suggested, so it follows a site's filtered Heartbeat interval. Checked end to end in wp-env: an agent's save over WP-CLI and REST writes a labelled row that lapses after 75s, while a person's save, or a WP-CLI save without --user, writes none.

Fixes #656

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5.5, Claude Opus 5.5
Used for: Implementation, tests and the end-to-end check.

@github-actions

Copy link
Copy Markdown
Contributor

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props iamchitti, joefusco.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@i-am-chitti i-am-chitti self-assigned this Sep 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🛝 WordPress Playgrounds

Built from a92623b

25 users 100 users
Single site Launch single site, 25 users Launch single site, 100 users
Multisite Launch multisite, 25 users Launch multisite, 100 users

@codecov

codecov Bot commented Sep 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.48%. Comparing base (cf96ff1) to head (a92623b).

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #697      +/-   ##
============================================
+ Coverage     94.46%   94.48%   +0.01%     
  Complexity      270      270              
============================================
  Files            28       28              
  Lines          3942     3951       +9     
============================================
+ Hits           3724     3733       +9     
  Misses          218      218              
Flag Coverage Δ
multisite 94.48% <100.00%> (+0.01%) ⬆️
phpunit 73.70% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@josephfusco

Copy link
Copy Markdown
Collaborator

Using wp_presence_idle_threshold() for the expiry means the row follows a site's filtered Heartbeat interval, and the README now matches how agents actually show up.

A few questions from running it locally. wp_insert_post( array( 'post_status' => 'auto-draft' ) ) returns 0 because core treats it as empty content, so the auto-draft test passes with or without the guard. Would a post_title there make it catch that? Revisions don't support presence either, so wp_presence_post_room() seems to return false for revisions and autosaves before the new checks run. Could the handler lean on that and drop those checks and their test, or is there a case you had in mind where they'd matter? The refresh test also caught nothing the others didn't, since wp_set_presence() rewrites the row on every save. What do you see it guarding?

I'm also curious about trash. Moving a post to the trash fires wp_after_insert_post, so an agent that trashes a post gets a fresh row in that room. Does that fit how you picture agent presence?

@josephfusco josephfusco left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice work on this! 🙌🏼

@josephfusco

Copy link
Copy Markdown
Collaborator

I've moved my questions from yesterday into #698 so they don't hold this up. None of them change what ships here.

@josephfusco
josephfusco merged commit 047dc91 into main Oct 1, 2026
25 checks passed
@josephfusco
josephfusco deleted the feat/656-agent-presence-on-post-save branch October 1, 2026 16:39
@josephfusco josephfusco added this to the 0.13.0 milestone Oct 1, 2026
@josephfusco josephfusco mentioned this pull request Oct 5, 2026
24 of 36 tasks
@josephfusco josephfusco added [Type] Enhancement A suggestion for improvement of an existing feature [Area] Heartbeat 💓 Issues for the heartbeat subsystem labels Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Area] Heartbeat 💓 Issues for the heartbeat subsystem [Type] Enhancement A suggestion for improvement of an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An agent that edits a post should show up in its room without writing its own row

2 participants