Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

LinkedIn: the submit probe recognizes the share composer's Post too

Barack Sokullu46b1dfcf54c4
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 8b71a5b70..665556a83 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -30260,7 +30260,41 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
? { isSubmit: true, strong: publishTestId }
: { isSubmit: false, strong: false };
};
+ // LinkedIn's share composer is server-driven UI: its controls carry only
+ // generated class names, but the screen itself is marked
+ // (data-sdui-screen ending in ".sharing.ShareCompose") whatever the
+ // page's language. It counts only with one editor of its own and outside
+ // every messaging scope, as in the recipient guard.
+ const linkedInShareComposeFor = (candidate) => {
+ if (!/(?:^|\.)linkedin\.com$/.test(String(host || '').toLowerCase().replace(/\.$/, ''))
+ || !candidate || candidate.nodeType !== 1) return null;
+ try {
+ const screen = candidate.closest?.('[data-sdui-screen$=".sharing.ShareCompose"]');
+ if (!screen || !isVisible(screen)) return null;
+ const messaging = 'form,[role="log"],[data-message-id],[data-thread-id],[data-conversation-id],'
+ + '.msg-form,.msg-overlay-conversation-bubble,.msg-convo-wrapper,[class*="msg-"],[class*="messaging"],'
+ + '[id*="messaging"],[data-messaging],[data-test-messaging]';
+ if (candidate.closest?.(messaging) || screen.closest?.(messaging)) return null;
+ const editors = [...screen.querySelectorAll('[contenteditable="true"],textarea')].filter(isVisible);
+ return editors.length === 1 ? screen : null;
+ } catch {
+ return null;
+ }
+ };
+ // In that composer, a button whose captions a model read as publishing
+ // or committing ("Post", or "Gönder" in Turkish) publishes the post. A
+ // control that opens a menu or a picker (the audience selector reads
+ // "Post to Anyone") only edits the draft.
+ const linkedInSharePublishEvidence = (candidate) => {
+ if (!linkedInShareComposeFor(candidate)) return null;
+ if (String(candidate.tagName || '').toLowerCase() !== 'button'
+ || candidate.hasAttribute?.('aria-haspopup') || candidate.hasAttribute?.('aria-expanded')) return null;
+ return commitReading(captionsReading(controlCaptions(candidate))) ? { isSubmit: true, strong: true } : null;
+ };
const socialPublicationControlFor = (root, el) => {
+ // LinkedIn's share composer: its post control publishes.
+ const shareTarget = labelControlFor(el) || el;
+ if (linkedInSharePublishEvidence(shareTarget?.closest?.('button,input,[role="button"],[onclick],[data-action]') || shareTarget)) return true;
if (!socialPublishAdapterName() || !el) return undefined;
const target = labelControlFor(el) || el;
const control = target.closest?.('button,input,[role="button"],[onclick],[data-action]') || target;
@@ -30329,7 +30363,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const hasActivationHandler = candidate.hasAttribute?.('onclick') || candidate.hasAttribute?.('data-action');
const form = candidate.form || candidate.closest?.('form');
if (!form && nativeConfirmationCommit(candidate)) return { isSubmit: true, strong: true };
- if (!form) return socialPublishControlEvidence(candidate);
+ if (!form) return linkedInSharePublishEvidence(candidate) || socialPublishControlEvidence(candidate);
const inlineHandler = String(candidate.getAttribute?.('onclick') || '');
// A button-typed control submits its form only by script: a handler
// that calls requestSubmit or submit, or a caption or action name a
@@ -30416,6 +30450,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
return candidate?.form
|| candidate?.closest?.('form')
|| socialPublishComposerFor(candidate)
+ || linkedInShareComposeFor(candidate)
|| null;
};
const isFormField = (el) => {
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 943438696..677471ba8 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -27302,7 +27302,41 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
? { isSubmit: true, strong: publishTestId }
: { isSubmit: false, strong: false };
};
+ // LinkedIn's share composer is server-driven UI: its controls carry only
+ // generated class names, but the screen itself is marked
+ // (data-sdui-screen ending in ".sharing.ShareCompose") whatever the
+ // page's language. It counts only with one editor of its own and outside
+ // every messaging scope, as in the recipient guard.
+ const linkedInShareComposeFor = (candidate) => {
+ if (!/(?:^|\.)linkedin\.com$/.test(String(host || '').toLowerCase().replace(/\.$/, ''))
+ || !candidate || candidate.nodeType !== 1) return null;
+ try {
+ const screen = candidate.closest?.('[data-sdui-screen$=".sharing.ShareCompose"]');
+ if (!screen || !isVisible(screen)) return null;
+ const messaging = 'form,[role="log"],[data-message-id],[data-thread-id],[data-conversation-id],'
+ + '.msg-form,.msg-overlay-conversation-bubble,.msg-convo-wrapper,[class*="msg-"],[class*="messaging"],'
+ + '[id*="messaging"],[data-messaging],[data-test-messaging]';
+ if (candidate.closest?.(messaging) || screen.closest?.(messaging)) return null;
+ const editors = [...screen.querySelectorAll('[contenteditable="true"],textarea')].filter(isVisible);
+ return editors.length === 1 ? screen : null;
+ } catch {
+ return null;
+ }
+ };
+ // In that composer, a button whose captions a model read as publishing
+ // or committing ("Post", or "Gönder" in Turkish) publishes the post. A
+ // control that opens a menu or a picker (the audience selector reads
+ // "Post to Anyone") only edits the draft.
+ const linkedInSharePublishEvidence = (candidate) => {
+ if (!linkedInShareComposeFor(candidate)) return null;
+ if (String(candidate.tagName || '').toLowerCase() !== 'button'
+ || candidate.hasAttribute?.('aria-haspopup') || candidate.hasAttribute?.('aria-expanded')) return null;
+ return commitReading(captionsReading(controlCaptions(candidate))) ? { isSubmit: true, strong: true } : null;
+ };
const socialPublicationControlFor = (root, el) => {
+ // LinkedIn's share composer: its post control publishes.
+ const shareTarget = labelControlFor(el) || el;
+ if (linkedInSharePublishEvidence(shareTarget?.closest?.('button,input,[role="button"],[onclick],[data-action]') || shareTarget)) return true;
if (!socialPublishAdapterName() || !el) return undefined;
const target = labelControlFor(el) || el;
const control = target.closest?.('button,input,[role="button"],[onclick],[data-action]') || target;
@@ -27371,7 +27405,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const hasActivationHandler = candidate.hasAttribute?.('onclick') || candidate.hasAttribute?.('data-action');
const form = candidate.form || candidate.closest?.('form');
if (!form && nativeConfirmationCommit(candidate)) return { isSubmit: true, strong: true };
- if (!form) return socialPublishControlEvidence(candidate);
+ if (!form) return linkedInSharePublishEvidence(candidate) || socialPublishControlEvidence(candidate);
const inlineHandler = String(candidate.getAttribute?.('onclick') || '');
// A button-typed control submits its form only by script: a handler
// that calls requestSubmit or submit, or a caption or action name a
@@ -27458,6 +27492,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
return candidate?.form
|| candidate?.closest?.('form')
|| socialPublishComposerFor(candidate)
+ || linkedInShareComposeFor(candidate)
|| null;
};
const isFormField = (el) => {
diff --git a/test/fixtures/message-recipient-navigation.mjs b/test/fixtures/message-recipient-navigation.mjs
index 1cb70d5f0..59506fda7 100644
--- a/test/fixtures/message-recipient-navigation.mjs
+++ b/test/fixtures/message-recipient-navigation.mjs
@@ -850,6 +850,11 @@ export function registerMessageRecipientNavigationFixtures({
await page.evaluate(() => history.replaceState({}, '', '/sharing/compose'));
const plan = (overrides = {}) => agent._startPlanExecutionGuard(1, 'act', {
requestKind: 'execute', requiresStateChange: true, requiresSubmission: true, ...overrides });
+ // The submit probe, run as the agent runs it: it decides the submit
+ // card, the submission receipt and the record of a possible post.
+ const submitProbe = (tool, args) => probeWithReadings((name, passArgs) => page.evaluate(({ source, tool, args }) =>
+ Function('return (' + source + ')')()(tool, args), { source: AgentClass._submitActionProbe.toString(), tool: name, args: passArgs }),
+ tool, args);
// The task started on another site: no LinkedIn workflow, and no
// private message named. Its plan requires the submission.
plan();
@@ -861,6 +866,9 @@ export function registerMessageRecipientNavigationFixtures({
assert.equal(observed.publicPost, true, JSON.stringify({ postLabel, tool, args, observed }));
assert.equal(observed.messageSend, false);
assert.equal(await guard(tool, args), null, `${postLabel} ${tool}: the planned post goes through`);
+ const submit = await submitProbe(tool, args);
+ assert.equal(submit?.isSubmit, true, `${postLabel} ${tool}: the post is a submission ${JSON.stringify(submit)}`);
+ assert.equal(submit.publicationControl, true, `${postLabel} ${tool}: the post is a publication`);
}
}
// The draft's other controls are not sends, and not the post.
@@ -871,6 +879,7 @@ export function registerMessageRecipientNavigationFixtures({
assert.equal(observed.messageSend, false, selector);
assert.notEqual(observed.publicPost, true, selector);
assert.equal(await guard('click', { selector }), null, selector);
+ assert.notEqual((await submitProbe('click', { selector }))?.publicationControl, true, selector);
}
// A task that names a private message to send, or asks for no
// submission at all, does not post.
@@ -888,6 +897,7 @@ export function registerMessageRecipientNavigationFixtures({
for (const variant of [{ editors: 2 }, { scope: 'data-conversation-id="alice"' }]) {
await composeShareScreen(page, variant);
assert.equal((await guard('click', { selector: '#publish' }))?.noDispatch, true, JSON.stringify(variant));
+ assert.notEqual((await submitProbe('click', { selector: '#publish' }))?.publicationControl, true, JSON.stringify(variant));
}
await page.evaluate(() => document.getElementById('share-dialog')?.remove());
});