Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
43 changes: 36 additions & 7 deletions .github/workflows/windows-chat-focus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ on:
permissions:
contents: read

env:
# Reproduce the release under investigation with the current Kotlin changes.
# The build job packages this extension version. The test steps check that the
# plugin ZIP really contains it, because the ZIP name does not set it.
ZOO_EXTENSION_VERSION: "3.96.0"

concurrency:
# Skipped label events must not replace a pending build for this PR.
group: windows-chat-focus-${{ github.ref }}-${{ github.event.action == 'labeled' && github.event.label.name != 'live-solheim' && 'ignored-label' || 'validation' }}
Expand All @@ -40,8 +46,6 @@ jobs:
runs-on: ubuntu-24.04
timeout-minutes: 90
env:
# Reproduce the release under investigation with the current Kotlin changes.
ZOO_EXTENSION_VERSION: "3.96.0"
# This job packages the plugin; headful tests use the IDE's bundled JCEF.
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"
steps:
Expand All @@ -65,7 +69,7 @@ jobs:
sudo apt-get install --no-install-recommends build-essential libx11-dev libxkbfile-dev pkg-config
- name: Validate the local streaming fixture and authenticated relay
working-directory: jetbrains_plugin/scripts/ui-harness
run: python3 -m unittest -v test_streaming_fixture.py test_solheim_proxy.py
run: python3 -m unittest -v test_streaming_fixture.py test_solheim_proxy.py test_check_history_store.py
- name: Prepare extension host source
run: ./scripts/setup.sh --skip-deps --verbose
- name: Cache the cross-platform VS Code runtime
Expand All @@ -82,10 +86,10 @@ jobs:
if-no-files-found: error

windows-e2e:
name: Native typing and streaming chat (IDEA ${{ matrix.ide }})
name: Native typing, streaming chat, and shared history (IDEA ${{ matrix.ide }})
needs: build
runs-on: windows-2022
timeout-minutes: 30
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
Expand All @@ -104,8 +108,10 @@ jobs:
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Validate fixture HTTP behavior on Windows
run: python -m unittest discover -s jetbrains_plugin/scripts/ui-harness -p test_streaming_fixture.py -v
- name: Validate fixture HTTP behavior and the history store checker on Windows
run: |
python -m unittest discover -s jetbrains_plugin/scripts/ui-harness -p test_streaming_fixture.py -v
python -m unittest discover -s jetbrains_plugin/scripts/ui-harness -p test_check_history_store.py -v
- uses: actions/download-artifact@v4
with:
name: chat-focus-plugin
Expand Down Expand Up @@ -138,14 +144,36 @@ jobs:
if ($plugins.Count -ne 1) { throw 'Expected exactly one plugin distribution' }
& ./jetbrains_plugin/scripts/ui-harness/run-windows.ps1 `
-IdeDir $env:FOCUS_IDE_DIR -PluginZip $plugins[0].FullName `
-ExpectExtensionVersion $env:ZOO_EXTENSION_VERSION `
-EvidenceDir "$env:GITHUB_WORKSPACE/focus-evidence"
# Issue #6. Two IDEs share ~/.zoo-code. Each one runs a parent task that
# delegates to a subtask. The step fails if the shared history store has a
# shared index file, invalid items, wrong parent/child links, more than three
# task switches in the webview, or an invalid status transition in the IDE logs.
# It does not detect a view that changes to the parent during the subtask and stays there.
- name: Run two IDEs with parent tasks and subtasks against one history store
if: ${{ !cancelled() }}
run: |
$plugins = @(Get-ChildItem focus-plugin -Filter *.zip)
if ($plugins.Count -ne 1) { throw 'Expected exactly one plugin distribution' }
& ./jetbrains_plugin/scripts/ui-harness/run-windows.ps1 -HistoryRace `
-IdeDir $env:FOCUS_IDE_DIR -PluginZip $plugins[0].FullName `
-ExpectExtensionVersion $env:ZOO_EXTENSION_VERSION `
-EvidenceDir "$env:GITHUB_WORKSPACE/history-evidence" -DeadlineSeconds 900
- name: Upload focus traces, screenshots, and run identity
if: always()
uses: actions/upload-artifact@v4
with:
name: windows-chat-focus-${{ matrix.ide }}-${{ github.sha }}
path: focus-evidence/
if-no-files-found: error
- name: Upload shared history evidence
if: always()
uses: actions/upload-artifact@v4
with:
name: windows-history-race-${{ matrix.ide }}-${{ github.sha }}
path: history-evidence/
if-no-files-found: warn

live-solheim:
name: Live Solheim terminal and diff focus (WebStorm 2026.2.1)
Expand Down Expand Up @@ -201,6 +229,7 @@ jobs:
$env:SOLHEIM_API_KEY = $liveKey
& ./jetbrains_plugin/scripts/ui-harness/run-windows.ps1 `
-IdeDir $env:FOCUS_IDE_DIR -PluginZip $plugins[0].FullName `
-ExpectExtensionVersion $env:ZOO_EXTENSION_VERSION `
-Provider solheim -DeadlineSeconds 780 -RequireWindows11:($env:REQUIRE_WINDOWS11 -eq 'true') `
-EvidenceDir "$env:GITHUB_WORKSPACE/live-evidence/run-$iteration"
}
Expand Down
64 changes: 62 additions & 2 deletions jetbrains_plugin/scripts/ui-harness/HarnessDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public final class HarnessDriver implements AppLifecycleListener {
private final java.util.Set<String> approvedCommands = new java.util.HashSet<>();
private final boolean fixtureMode = Boolean.getBoolean("zoo.harness.fixture");
private final boolean diffStress = Boolean.getBoolean("zoo.harness.diffStress");
// Issue #6: two IDEs share one history store. This mode submits one parent task that
// delegates to a subtask, then waits for the parent to resume. It does no focus checks.
private final boolean historyRace = Boolean.getBoolean("zoo.harness.historyRace");
private final String historyTag = System.getProperty("zoo.harness.historyTag", "A");
private final boolean windowsLive = !fixtureMode && System.getProperty("os.name", "").startsWith("Windows");

private String windowsCommand(String step) {
Expand Down Expand Up @@ -248,7 +252,7 @@ private void mark(String step) {
// Manual provider-backed battery: real React textarea, real extension tools.
private JsonObject realSnapshot(Object webview, AtomicReference<String> title) throws Exception {
int id=++realSequence;
String script="(()=>{const snapshot=JSON.stringify((()=>{let e=[...document.querySelectorAll('textarea')].find(x=>x.offsetWidth&&x.offsetHeight);let r=e&&e.getBoundingClientRect();let z=window.__focusE2E||{};let m=z.messages||[];let last=m[m.length-1]||{};return {snapshot:"+id+",input:!!e,value:e?e.value:null,active:e===document.activeElement,windowFocused:document.hasFocus(),disabled:e?e.disabled:null,rect:r?{x:r.x,y:r.y,w:r.width,h:r.height}:null,messages:m.length,events:z.events||0,partial:z.partial||0,lastAsk:last.ask||null,lastTs:last.ts||null,lastText:typeof last.text==='string'?last.text.slice(0,300):null,lastSay:last.say||null,lastPartial:!!last.partial,provider:z.provider||null,body:document.body.innerText.slice(-1200)};})());console.log('ZFE2E:'+snapshot);document.title='ZFE2E:'+snapshot;})();";
String script="(()=>{const snapshot=JSON.stringify((()=>{let e=[...document.querySelectorAll('textarea')].find(x=>x.offsetWidth&&x.offsetHeight);let r=e&&e.getBoundingClientRect();let z=window.__focusE2E||{};let m=z.messages||[];let last=m[m.length-1]||{};return {snapshot:"+id+",input:!!e,value:e?e.value:null,active:e===document.activeElement,windowFocused:document.hasFocus(),disabled:e?e.disabled:null,rect:r?{x:r.x,y:r.y,w:r.width,h:r.height}:null,messages:m.length,events:z.events||0,partial:z.partial||0,taskId:z.taskId||null,tasks:z.tasks||[],lastAsk:last.ask||null,lastTs:last.ts||null,lastText:typeof last.text==='string'?last.text.slice(0,300):null,lastSay:last.say||null,lastPartial:!!last.partial,provider:z.provider||null,body:document.body.innerText.slice(-1200)};})());console.log('ZFE2E:'+snapshot);document.title='ZFE2E:'+snapshot;})();";
runOnEdt(() -> invoke(webview, "executeJavaScript", script));
long resend=System.currentTimeMillis()+1000;
long deadline=System.currentTimeMillis()+30000;
Expand Down Expand Up @@ -318,7 +322,7 @@ private void runRealConversation(Project project) throws Exception {
if (!addTitleHandler(browser, invoke(browser, "getCefBrowser"), title)) {
throw new IllegalStateException("Cannot register JCEF snapshot handler; see IDE log for cause");
}
invoke(webview, "executeJavaScript", "window.__focusE2E={messages:[],events:0,partial:0};window.addEventListener('message',e=>{let d=e.data,z=window.__focusE2E;if(!d)return;z.events++;if(d.type==='state'&&d.state){if(d.state.clineMessages)z.messages=d.state.clineMessages.slice();z.provider=d.state.apiConfiguration&&d.state.apiConfiguration.apiProvider;}if(d.type==='messageUpdated'||d.type==='partialMessage'){let m=d.clineMessage||d.partialMessage;if(m){if(m.partial)z.partial++;let i=z.messages.findIndex(x=>x.ts===m.ts);if(i>=0)z.messages[i]=m;else z.messages.push(m);}}});");
invoke(webview, "executeJavaScript", "window.__focusE2E={messages:[],events:0,partial:0};window.addEventListener('message',e=>{let d=e.data,z=window.__focusE2E;if(!d)return;z.events++;if(d.type==='state'&&d.state){if(d.state.clineMessages)z.messages=d.state.clineMessages.slice();z.taskId=d.state.currentTaskItem?d.state.currentTaskItem.id:null;(z.tasks=z.tasks||[]);if(z.taskId&&z.tasks[z.tasks.length-1]!==z.taskId)z.tasks.push(z.taskId);z.provider=d.state.apiConfiguration&&d.state.apiConfiguration.apiProvider;}if(d.type==='messageUpdated'||d.type==='partialMessage'){let m=d.clineMessage||d.partialMessage;if(m){if(m.partial)z.partial++;let i=z.messages.findIndex(x=>x.ts===m.ts);if(i>=0)z.messages[i]=m;else z.messages.push(m);}}});");
invoke(webview,"executeJavaScript","window.__focusNodeSeq=0;function e2eNode(e){if(!e)return null;if(!e.__e2eid)e.__e2eid=++window.__focusNodeSeq;return e.tagName+'@'+e.__e2eid;}for(let kind of ['keydown','input','focusin','focusout'])document.addEventListener(kind,e=>{if(kind==='keydown'&&!['x','y'].includes(e.key))return;console.info('E2EKEY:'+JSON.stringify({kind,ts:Date.now(),key:e.key||null,mod:e.ctrlKey||e.altKey||e.metaKey||false,node:e2eNode(e.target),active:e2eNode(document.activeElement),hasFocus:document.hasFocus(),length:typeof e.target.value==='string'?e.target.value.length:null}));},true);for(let kind of ['focus','blur'])window.addEventListener(kind,e=>console.info('E2EWINDOW:'+JSON.stringify({kind,ts:Date.now(),active:e2eNode(document.activeElement),hasFocus:document.hasFocus()})),true);");
realSend(webview, "{\"type\":\"webviewDidLaunch\"}");
realSend(webview, "{\"type\":\"mode\",\"text\":\"code\"}");
Expand All @@ -335,6 +339,7 @@ private void runRealConversation(Project project) throws Exception {
realSend(webview, config.toString());
realSend(webview, "{\"type\":\"updateSettings\",\"updatedSettings\":{\"autoApprovalEnabled\":true,\"alwaysAllowReadOnly\":true,\"alwaysAllowWrite\":true,\"alwaysAllowExecute\":true,\"allowedCommands\":[\"printf\",\"sleep\",\"cat\",\"pwd\"],\"terminalShellIntegrationDisabled\":false,\"destructiveCommandGuardEnabled\":false,\"maxRequests\":20,\"telemetrySetting\":\"disabled\"}}");
if (!fixtureMode) realSend(webview, "{\"type\":\"updateSettings\",\"updatedSettings\":{\"alwaysAllowExecute\":false}}");
if (historyRace) realSend(webview, "{\"type\":\"updateSettings\",\"updatedSettings\":{\"alwaysAllowSubtasks\":true}}");
realSend(webview, "{\"type\":\"didShowAnnouncement\"}");
invoke(webview, "executeJavaScript", "[...document.querySelectorAll('button')].find(b=>b.textContent.trim()==='Close')?.click();");
JsonObject snap = null;
Expand All @@ -351,6 +356,21 @@ private void runRealConversation(Project project) throws Exception {
if (!Boolean.TRUE.equals(ready)) throw new IllegalStateException("Chat remained hidden during indexing");
snap = realSnapshot(webview,title);
screenshot("p-configured");
if (historyRace) {
// Start the task with a webview message, not the keyboard. Two IDEs run together,
// and a background IDE window does not get native focus on Windows.
realSend(webview, "{\"type\":\"newTask\",\"text\":\"HISTORY_RACE_PARENT " + historyTag
+ " delegate one subtask, then finish.\"}");
boolean started = false;
for (int i = 0; i < 60 && !started; i++) {
Thread.sleep(1000);
started = realSnapshot(webview, title).get("messages").getAsInt() > 0;
}
if (!started) { fail("realTaskMissing", "No task appeared after the newTask message"); return; }
mark("P-real-conversation-submitted");
waitForHistoryRace(webview, title);
return;
}
if (diffStress) checkDeliberateEditorFocus(project);
// Establish native focus before typing anything. A freshly mounted OSR
// surface may paint after its DOM is ready. Setup clicks are bounded;
Expand Down Expand Up @@ -503,6 +523,46 @@ private void runRealConversation(Project project) throws Exception {
finish(fixtureMode ? "testP-streaming-fixture" : "testP-real-solheim-conversation", firstCompleted&&completed&&commandsCovered&&typingHealthy&&focusHealthy&&firstStreamed&&followupStreamed&&historyGrew&&fixtureChanged?"PASS":"FAIL-REAL-CONVERSATION");
}

/**
* Waits until the parent task resumes and completes after its subtask. The webview shows
* one task at a time. The expected task order is parent, child, parent. A fourth change
* of task fails the test. The test counts task switches only. It cannot see a view
* that changes to the parent during the subtask and stays there until the parent resumes.
*/
private void waitForHistoryRace(Object webview, AtomicReference<String> title) throws Exception {
long deadline = System.currentTimeMillis() + 420_000;
List<String> sequence = new ArrayList<>();
while (System.currentTimeMillis() < deadline) {
JsonObject snap = realSnapshot(webview, title);
// The page records every task id in arrival order. Polling alone can miss the
// parent, because a delegation can finish before the first poll.
List<String> seen = new ArrayList<>();
snap.getAsJsonArray("tasks").forEach(id -> seen.add(id.getAsString()));
if (!seen.equals(sequence)) {
sequence = seen;
record("H_taskSequence_" + sequence.size(), sequence);
}
String ask = snap.get("lastAsk").isJsonNull() ? "" : snap.get("lastAsk").getAsString();
if (!answerCommandAsk(webview, snap, ask)) return;
if (sequence.size() > 3) {
fail("subtaskViewFlipped", "Task view changed " + sequence.size() + " times: " + sequence);
return;
}
String current = snap.get("taskId").isJsonNull() ? null : snap.get("taskId").getAsString();
boolean done = sequence.size() == 3 && sequence.get(2).equals(sequence.get(0))
&& sequence.get(0).equals(current) && "completion_result".equals(ask)
&& !snap.get("lastPartial").getAsBoolean();
if (done) {
// Give the extension time to persist the final history items.
Thread.sleep(5_000);
finish("testH-history-race-" + historyTag, "PASS");
return;
}
Thread.sleep(1_000);
}
fail("historyRaceTimeout", "Parent did not resume after its subtask; task order " + sequence);
}

private void clickInBrowser(Object jbCefBrowser, JsonObject rect) throws Exception {
final Point[] loc = new Point[1];
runOnEdt(() -> {
Expand Down
34 changes: 34 additions & 0 deletions jetbrains_plugin/scripts/ui-harness/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,40 @@ it has no input for an existing release ZIP. Its IDEA matrix is 2026.1.5.1 and
2026.2.1, so those jobs do not establish compatibility with IDEA 2023.3.8.
Record the exact ZIP, IDE version, and evidence directory when comparing builds.

## Shared history race test (issue #6)

`run-windows.ps1 -HistoryRace` starts two IDEs with separate profiles and the same
home directory, so both use one `~/.zoo-code/globalStorage`. Both IDEs start together.
Each IDE starts a parent task with a webview `newTask` message. The test uses no keyboard,
because a background IDE window gets no native focus on Windows. The fixture makes the
parent call `new_task`. It holds both parents at a barrier so the delegations overlap.
It then streams both child tasks and lets each parent resume and finish. `check_history_store.py` then checks the store:

1. No `_index.json` was written.
2. Every `history_item.json` is valid, has a real title, and has `size` above zero.
3. Each parent lists only its own child, and each child names only its own parent.
4. Each child is `completed` and no parent still waits on a child.
5. The provider log shows both barriers released, no disconnect, and six completed streams.
6. The IDE logs hold no invalid status transition, rejected delta, failed persist, or re-delegate error message.

The driver also fails if the webview changes task more than three times. The expected
order is parent, child, parent. The test counts task switches only. It does not detect a
view that changes to the parent during the subtask and stays there until the parent resumes.

The run uses the real user profile store, so the script refuses to start unless
`GITHUB_ACTIONS` is `true`. The Windows CI job has a 60 minute timeout and uploads
the evidence as `windows-history-race-<ide>-<sha>`.

`-ExpectExtensionVersion` (`run-windows.ps1`) makes a run fail when the Zoo Code extension
in the plugin ZIP has another version. CI passes it to the chat focus, shared history,
and live Solheim steps.

`streaming_fixture.py` flags: `--port`, `--log` (required), `--scenario history-race`,
`--chunks`, `--interval` (seconds between chunks), `--barrier` (parents to hold).

The unit tests run without an IDE. Run them from this directory:
`python3 -m unittest test_streaming_fixture test_check_history_store`.

## Linux live setup

Store the Solheim key in a private file outside the repository (mode 0600).
Expand Down
Loading
Loading