Merge fix/orchestrator-skipped-view-transition into unify/skills-20261111
This commit is contained in:
commit
381aeb3ba0
2 files changed
+43
-2
No files matched your search
@@ -37,7 +37,11 @@
|
|||||||
ui.views[route.screen] = route.view;
|
ui.views[route.screen] = route.view;
|
||||||
}
|
}
|
||||||
if (document.startViewTransition && drawn.screen && !calm.matches) {
|
if (document.startViewTransition && drawn.screen && !calm.matches) {
|
||||||
document.startViewTransition(() => render(true));
|
document.startViewTransition(() => render(true)).ready.catch((error) => {
|
||||||
|
if (error.name !== "AbortError") {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
render(true);
|
render(true);
|
||||||
}
|
}
|
||||||
|
|||||||
+38
-1
@@ -4,7 +4,38 @@ import json
|
|||||||
import subprocess
|
import subprocess
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from hub_support import NAV
|
from hub_support import HUB, NAV
|
||||||
|
|
||||||
|
SCREENS = HUB / "templates" / "page-screens.js"
|
||||||
|
TRANSITION_PROBE = """
|
||||||
|
const fs = require("fs");
|
||||||
|
const vm = require("vm");
|
||||||
|
const code = fs.readFileSync(process.argv[1], "utf8");
|
||||||
|
const unhandled = [];
|
||||||
|
process.on("unhandledRejection", (error) => unhandled.push(error.name));
|
||||||
|
const settle = () => new Promise((resolve) => setImmediate(resolve));
|
||||||
|
function switched(name) {
|
||||||
|
const error = new Error(`transition ${name}`);
|
||||||
|
error.name = name;
|
||||||
|
const started = [];
|
||||||
|
vm.runInNewContext(`${code}\\napply();`, {
|
||||||
|
Nav: {TABS: [], route: () => ({screen: "agents", view: "chord"})}, ui: {views: {}}, drawn: {screen: true}, calm: {matches: false}, h: () => null,
|
||||||
|
window: {location: {hash: "#agents/chord"}, history: {replaceState: () => null}},
|
||||||
|
document: {getElementById: () => ({append: () => null}), startViewTransition: (update) => {
|
||||||
|
started.push(typeof update);
|
||||||
|
return {ready: Promise.reject(error), finished: Promise.resolve(), updateCallbackDone: Promise.resolve()};
|
||||||
|
}},
|
||||||
|
});
|
||||||
|
return started;
|
||||||
|
}
|
||||||
|
(async () => {
|
||||||
|
const started = [...switched("AbortError"), ...switched("InvalidStateError")];
|
||||||
|
for (let round = 0; round < 5; round += 1) {
|
||||||
|
await settle();
|
||||||
|
}
|
||||||
|
console.log(JSON.stringify({started, unhandled}));
|
||||||
|
})().catch((error) => console.log(JSON.stringify({crash: String(error)})));
|
||||||
|
"""
|
||||||
|
|
||||||
NAV_PROBE = """
|
NAV_PROBE = """
|
||||||
const N = require(process.argv[1]);
|
const N = require(process.argv[1]);
|
||||||
@@ -90,5 +121,11 @@ class TestNavModule(unittest.TestCase):
|
|||||||
self.assertEqual(self.data["tabOf"], ["stream", "stream", "stream", "agents", "artifacts", "tasks"])
|
self.assertEqual(self.data["tabOf"], ["stream", "stream", "stream", "agents", "artifacts", "tasks"])
|
||||||
|
|
||||||
|
|
||||||
|
class TestScreenTransition(unittest.TestCase):
|
||||||
|
def test_a_view_transition_skipped_by_the_next_switch_stays_quiet_and_other_failures_still_surface(self):
|
||||||
|
done = subprocess.run(["node", "-e", TRANSITION_PROBE, str(SCREENS)], capture_output=True, text=True, timeout=60, check=True)
|
||||||
|
self.assertEqual(json.loads(done.stdout), {"started": ["function", "function"], "unhandled": ["InvalidStateError"]})
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
Reference in new issue
Block a user