Skip to content

Commit 2889b7f

Browse files
committed
Release context claims on preflight abort
1 parent aaa3808 commit 2889b7f

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/chrome/src/ui/sidepanel.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7140,6 +7140,7 @@ async function sendMessage(extraChatParams = {}) {
71407140

71417141
await prepareChatHistoryForTurn(tabId, modeForSend);
71427142
if (isTabAbortRequested(tabId)) {
7143+
await releaseOwnedContextMenuClaim();
71437144
setTabProcessing(tabId, false);
71447145
setTabAbortRequested(tabId, false);
71457146
syncSendButtonState();

src/firefox/src/ui/sidepanel.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6871,6 +6871,7 @@ async function sendMessage(extraChatParams = {}) {
68716871

68726872
await prepareChatHistoryForTurn(tabId, modeForSend);
68736873
if (isTabAbortRequested(tabId)) {
6874+
await releaseOwnedContextMenuClaim();
68746875
setTabProcessing(tabId, false);
68756876
setTabAbortRequested(tabId, false);
68766877
syncSendButtonState();

test/run.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21939,14 +21939,19 @@ test('context-menu ownership and stale-panel persistence guards are wired in bot
2193921939
const sendMessageBody = panel.slice(sendMessageStart, sendMessageEnd);
2194021940
assert.equal(
2194121941
(sendMessageBody.match(/await releaseOwnedContextMenuClaim\(\);/g) || []).length,
21942-
4,
21943-
`${label}: every visibility exit should release the claim and schedule retry`,
21942+
5,
21943+
`${label}: every visibility or preflight-abort exit should release the claim and schedule retry`,
2194421944
);
2194521945
assert.match(
2194621946
sendMessageBody,
2194721947
/if \(!retryOptions\) text = await parseSlashCommands\(text, tabId, \{ permissionSkipContext \}\);[\s\S]*?if \(!renderToCurrentTab\) \{\s*await releaseOwnedContextMenuClaim\(\);/,
2194821948
`${label}: the first visibility failure after refresh and command parsing should relinquish initial ownership`,
2194921949
);
21950+
assert.match(
21951+
sendMessageBody,
21952+
/await prepareChatHistoryForTurn\(tabId, modeForSend\);\s*if \(isTabAbortRequested\(tabId\)\) \{\s*await releaseOwnedContextMenuClaim\(\);/,
21953+
`${label}: aborting preflight should relinquish initial ownership before resetting run state`,
21954+
);
2195021955
assert.match(
2195121956
sendMessageBody,
2195221957
/await prepareChatHistoryForTurn\(tabId, modeForSend\);[\s\S]*?if \(!renderToCurrentTab\) \{\s*await releaseOwnedContextMenuClaim\(\);[\s\S]*?contextMenuClaimOwned = renewedClaim\?\.claimed === true;[\s\S]*?const claimStillVisible[\s\S]*?if \(contextMenuClaimOwned && !claimStillVisible\) \{[\s\S]*?await releaseOwnedContextMenuClaim\(\);[\s\S]*?renderToCurrentTab = document\.visibilityState !== 'hidden'[\s\S]*?if \(!renderToCurrentTab\) \{\s*await releaseOwnedContextMenuClaim\(\);/,

0 commit comments

Comments
 (0)