Skip to content

Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.

fix(automations): preview shows the newest feed item, not the oldest

Paulo Castellano109ad7dfc041
diff --git a/app/Actions/Automation/Node/RunFetchRssNode.php b/app/Actions/Automation/Node/RunFetchRssNode.php
index a8394ee7f..3482d985e 100644
--- a/app/Actions/Automation/Node/RunFetchRssNode.php
+++ b/app/Actions/Automation/Node/RunFetchRssNode.php
@@ -96,14 +96,24 @@ class RunFetchRssNode
return NodeRunResult::completed(['fetch' => ['count' => 0]], nextHandle: self::NO_ITEMS_HANDLE);
}
- $first = array_shift($newItems);
-
- if (! $isPreview) {
- $this->spawnSiblings($run, $nodeId, $newItems);
+ $total = count($newItems);
+
+ // A preview (manual/dry test) surfaces ONE item and never fans out, so it
+ // shows the newest item — what the user expects to test against. A real run
+ // takes the oldest new item and fans the rest out as siblings, preserving
+ // feed chronology across branches (items are sorted oldest-first).
+ if ($isPreview) {
+ return NodeRunResult::completed([
+ 'fetch' => ['count' => $total, 'spawned' => 0],
+ 'fetched' => end($newItems),
+ ]);
}
+ $first = array_shift($newItems);
+ $this->spawnSiblings($run, $nodeId, $newItems);
+
return NodeRunResult::completed([
- 'fetch' => ['count' => count($newItems) + 1, 'spawned' => $isPreview ? 0 : count($newItems)],
+ 'fetch' => ['count' => $total, 'spawned' => count($newItems)],
'fetched' => $first,
]);
}
diff --git a/tests/Feature/Automation/Node/FetchRssNodeTest.php b/tests/Feature/Automation/Node/FetchRssNodeTest.php
index dc83b8e30..691895456 100644
--- a/tests/Feature/Automation/Node/FetchRssNodeTest.php
+++ b/tests/Feature/Automation/Node/FetchRssNodeTest.php
@@ -193,6 +193,11 @@ it('does not persist the production watermark on a manual real-data test', funct
expect($result->status)->toBe(NodeRunStatus::Completed);
expect($result->output['fetch']['count'])->toBeGreaterThan(0);
+ // ...surfaces the NEWEST item (key 'c', 15 Jun) — not the oldest — so the
+ // test reflects what the user just published, and spawns no siblings.
+ expect($result->output['fetched']['key'])->toBe('c');
+ expect($result->output['fetch']['spawned'])->toBe(0);
+
// ...and never advances the persisted watermark.
$state = AutomationNodeState::for($automation->id, 'fetch_1');
expect($state->data['last_item_date'])->toBe('2030-01-01T00:00:00+00:00');