Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
98e44f2
Insert email drafts as paragraph blocks and roll back unverified writes
Rouler4wd Sep 14, 2026
266fa2e
Let compose snapshots carry the thread, signature and quote regions
Rouler4wd Sep 14, 2026
1f59d51
Serve the Chromium compose fixture locally with Gmail editor styling
Rouler4wd Sep 14, 2026
a28f62c
Detect Gmail inline replies and Outlook bodies with varied labels
Rouler4wd Sep 14, 2026
3c7c81f
Give the launch intro view and video unique project identifiers
Rouler4wd Sep 14, 2026
9999d78
Write predicted emails above signatures and quotes with one click undo
Rouler4wd Sep 14, 2026
6730f3f
Check the composer before focusing its tab and route draft undo
Rouler4wd Sep 14, 2026
75ece4c
Add the email prediction prompt, cleanup, grounding and action valida…
Rouler4wd Sep 14, 2026
0c4f771
Let the browser bridge write drafts with a mode and undo them
Rouler4wd Sep 14, 2026
f9aeb4b
Read and write Apple Mail bodies rendered as WebKit web areas
Rouler4wd Sep 14, 2026
08fc82c
Write predicted emails directly with undo and offer follow up actions
Rouler4wd Sep 14, 2026
4d5a792
Check availability claims against the calendar and detect the reply l…
Rouler4wd Sep 14, 2026
69c178e
Run the email prediction and Mail matcher tests in CI
Rouler4wd Sep 14, 2026
a4b0b20
Infer accepted meeting times and catch contradictory availability
Rouler4wd Sep 14, 2026
d3d6301
Add a live evaluation of predictive email writing
Rouler4wd Sep 14, 2026
a26f527
Keep the review card for explicit requests and every refused write
Rouler4wd Sep 14, 2026
0a37ff7
Paste into Apple Mail only when focus is on the message body
Rouler4wd Sep 14, 2026
610ecf2
Offer an automatic prediction for review when the person types meanwhile
Rouler4wd Sep 14, 2026
c72f211
Offer only Copy for Apple Mail messages that already have text
Rouler4wd Sep 14, 2026
adf3a31
Expire deferred predictions and withdraw action offers after undo
Rouler4wd Sep 14, 2026
5c21a00
Read the calendar and Mail sent mailbox off the main thread with dead…
Rouler4wd Sep 14, 2026
7e461bc
Back off and cap the composer handshake retries
Rouler4wd Sep 14, 2026
788d118
Reject stale times, off topic replies and dropped note facts
Rouler4wd Sep 14, 2026
b502014
Protect the clipboard, undo notices and Composio disclosure
Rouler4wd Sep 14, 2026
098195d
Narrow the deferral, topic and duration checks after the live evaluation
Rouler4wd Sep 14, 2026
430242b
Merge the task and browser bridge reliability fixes into email predic…
Rouler4wd Sep 15, 2026
afdb1e9
Answer the read only compose precheck in the worker visibility test m…
Rouler4wd Sep 15, 2026
d31c210
Merge the long poll cap test fix into email prediction
Rouler4wd Sep 15, 2026
06dc187
Merge the loopback test task pool fix into email prediction
Rouler4wd Sep 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ jobs:
holmes/tests/run-email-draft-intent-tests.sh
holmes/tests/run-email-drafting-tests.sh
holmes/tests/run-email-draft-coordinator-tests.sh
holmes/tests/run-email-prediction-tests.sh
holmes/tests/run-mail-compose-matcher-tests.sh
holmes/tests/run-request-routing-tests.sh
holmes/tests/run-voice-hold-tests.sh
holmes/tests/run-work-activity-tests.sh
Expand Down
37 changes: 26 additions & 11 deletions holmes/holmes-extension/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ async function runOneCommand(cmd, token) {
let outcome;
runningCommandCount++;
try {
outcome = action === "read_email_compose" || action === "fill_email_draft"
outcome = action === "read_email_compose" || action === "fill_email_draft" || action === "undo_email_draft"
? await emailComposeCommand(cmd) : await HolmesAutomation.execute(cmd);
} catch (e) {
outcome = { ok: false, error: String(e && e.message ? e.message : e) };
Expand Down Expand Up @@ -966,21 +966,35 @@ async function emailComposeCommand(cmd) {
const params = cmd.params || {};
const instanceId = await browserInstance();
let tab;
if (cmd.action === "fill_email_draft") {
// Explicit Insert targets the original tab, never the current cursor. A
// document/composer comparison still occurs inside it before any write.
if (cmd.action === "fill_email_draft" || cmd.action === "undo_email_draft") {
// Writes and undo target the original tab, never the current cursor. A
// document/composer comparison still occurs inside it before any change.
let identity;
try { identity = JSON.parse(params.expected && params.expected.identity); } catch (_) { identity = null; }
if (!Array.isArray(identity) || identity[0] !== instanceId || !Number.isInteger(identity[2])) {
return { ok: false, refused: true, reason: "The draft belongs to another browser session." };
}
tab = await chrome.tabs.get(identity[2]);
if (tab.windowId !== identity[1]) return { ok: false, refused: true, reason: "The composer window changed." };
await chrome.windows.update(tab.windowId, { focused: true });
await chrome.tabs.update(tab.id, { active: true });
await notifyActive(tab.id, true);
if (!(await waitForTabVisible(tab.id))) {
return { ok: false, refused: true, reason: "The composer tab did not become visible after Holmes switched to it." };
if (cmd.action === "fill_email_draft") {
// Validate in the page first: a refused insert leaves windows and tabs
// exactly where the person had them. Bounded like every compose message.
const precheck = await withTimeout(chrome.tabs.sendMessage(tab.id, { type: "holmes:checkEmailDraft",
environment: { tabId: tab.id, windowId: tab.windowId, instanceId },
body: params.body, expected: params.expected, options: params.options }),
CONFIG.composeMessageTimeoutMs, "compose precheck");
if (!precheck || precheck.ok !== true) {
return precheck || { ok: false, refused: true, reason: "The composer did not answer." };
}
// Automatic writes happen only in the composer the person is looking at.
if (!(params.options && params.options.mode === "auto")) {
await chrome.windows.update(tab.windowId, { focused: true });
await chrome.tabs.update(tab.id, { active: true });
await notifyActive(tab.id, true);
if (!(await waitForTabVisible(tab.id))) {
return { ok: false, refused: true, reason: "The composer tab did not become visible after Holmes switched to it." };
}
}
}
} else {
const tabs = await chrome.tabs.query({ active: true, lastFocusedWindow: true });
Expand All @@ -993,11 +1007,12 @@ async function emailComposeCommand(cmd) {
}
const environment = { tabId: tab.id, windowId: tab.windowId, instanceId };
if (await activeTabId() !== tab.id) return { ok: false, refused: true, reason: "The active tab changed." };
const messageTypes = { read_email_compose: "holmes:readEmailCompose", fill_email_draft: "holmes:fillEmailDraft", undo_email_draft: "holmes:undoEmailDraft" };
// Bounded: a content script that never answers must not pin a command slot,
// block this tab's lane, or keep the worker awake indefinitely.
const result = await withTimeout(chrome.tabs.sendMessage(tab.id, {
type: cmd.action === "read_email_compose" ? "holmes:readEmailCompose" : "holmes:fillEmailDraft",
environment, body: params.body, expected: params.expected
type: messageTypes[cmd.action],
environment, body: params.body, expected: params.expected, options: params.options, token: params.token
}), CONFIG.composeMessageTimeoutMs, "compose message");
// A tab switch while the response was in flight invalidates a refresh. The
// page writer separately validates the exact identity before any mutation.
Expand Down
49 changes: 43 additions & 6 deletions holmes/holmes-extension/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -2408,7 +2408,14 @@

function scopeComposeRead() {
if (!window.HolmesEmailCompose || isExcludedHost()) return null;
return window.HolmesEmailCompose.read();
var compose = window.HolmesEmailCompose.read();
// Back off 1.5s, 3s, 6s and so on up to a minute, and stop after 8 attempts.
if (compose && !compose.identity && helloRetries < 8
&& Date.now() - lastHelloAt > Math.min(60000, 1500 * Math.pow(2, helloRetries))) {
helloRetries++;
sayHello();
}
return compose;
}

function extensionVersion() {
Expand Down Expand Up @@ -2615,12 +2622,23 @@
}
});
} catch (e) { /* storage unavailable — the app can still accept an empty token */ }
sayHello();
}

// The composer identity needs this tab's id, window and browser instance from
// the worker. A hello that raced a starting worker is retried (see
// scopeComposeRead) instead of silently leaving email drafting blocked.
var lastHelloAt = 0, helloRetries = 0;
function sayHello() {
if (!hasRuntime()) return;
lastHelloAt = Date.now();
try {
chrome.runtime.sendMessage({ type: "holmes:hello" }, function (res) {
// Reading lastError suppresses the "unchecked runtime.lastError" console noise
// when the service worker is still starting up.
var err = chrome.runtime.lastError;
if (err || !res) return;
helloRetries = 0;
if (res.token) TOKEN = res.token;
if (typeof res.tabId === "number") TAB_ID = res.tabId;
if (typeof res.windowId === "number") WINDOW_ID = res.windowId;
Expand Down Expand Up @@ -2819,6 +2837,23 @@
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
if (!msg || typeof msg.type !== "string") return false;

// Read only precheck, answered before the worker changes any focus. A
// background tab may still be the right composer for an explicit insert.
if (msg.type === "holmes:checkEmailDraft") {
var checkMode = msg.options && msg.options.mode;
if (isExcludedHost() || !window.HolmesEmailCompose) {
sendResponse({ ok: false, refused: true, reason: "Reload the extension to enable precise draft insertion." });
} else if (document.visibilityState !== "visible" || !IS_ACTIVE_TAB) {
sendResponse(checkMode === "auto"
? { ok: false, refused: true, reason: "The composer is no longer in the active tab." }
: { ok: true, deferred: true });
} else {
if (msg.environment) window.HolmesEmailCompose.setEnvironment(Object.assign({ app: BROWSER }, msg.environment));
sendResponse(window.HolmesEmailCompose.check(msg.expected, Object.assign({ body: msg.body }, msg.options || {})));
}
return false;
}

// Liveness and visibility probe from the worker: heartbeat health checks
// and the wait for a just activated tab to become visible before insert.
if (msg.type === "holmes:ping") {
Expand All @@ -2828,7 +2863,7 @@
return false;
}

if (msg.type === "holmes:readEmailCompose" || msg.type === "holmes:fillEmailDraft") {
if (msg.type === "holmes:readEmailCompose" || msg.type === "holmes:fillEmailDraft" || msg.type === "holmes:undoEmailDraft") {
if (isExcludedHost() || !IS_ACTIVE_TAB || document.visibilityState !== "visible") {
sendResponse({ ok: false, refused: true, reason: "The composer is no longer in the active tab." });
return false;
Expand All @@ -2839,12 +2874,14 @@
if (msg.type === "holmes:readEmailCompose") {
sendResponse({ ok: true, payload: buildPayload() });
} else {
var staged = window.HolmesEmailCompose
? window.HolmesEmailCompose.stage(msg.body, msg.expected)
: { ok: false, refused: true, reason: "Reload the extension to enable precise draft insertion." };
var composeApi = window.HolmesEmailCompose;
var written = !composeApi
? { ok: false, refused: true, reason: "Reload the extension to enable precise draft insertion." }
: msg.type === "holmes:undoEmailDraft" ? composeApi.undo(msg.token)
: composeApi.stage(msg.body, msg.expected, msg.options);
lastHash = "";
schedule(true);
sendResponse(staged);
sendResponse(written);
}
return false;
}
Expand Down
Loading
Loading