diff --git a/packages/client/src/pages/scratchpad.vue b/packages/client/src/pages/scratchpad.vue index a33003ded..d72c21e6f 100644 --- a/packages/client/src/pages/scratchpad.vue +++ b/packages/client/src/pages/scratchpad.vue @@ -59,6 +59,7 @@ async function run() { os.inputText({ title: q, }).then(({ canceled, result: a }) => { + if (canceled) return; ok(a); }); }); diff --git a/packages/client/src/plugin.ts b/packages/client/src/plugin.ts index 422b6339c..0ab8648a6 100644 --- a/packages/client/src/plugin.ts +++ b/packages/client/src/plugin.ts @@ -18,7 +18,8 @@ export function install(plugin) { return new Promise(ok => { inputText({ title: q, - }).then(({ result: a }) => { + }).then(({ canceled, result: a }) => { + if (canceled) return; ok(a); }); }); diff --git a/packages/client/src/scripts/aiscript/api.ts b/packages/client/src/scripts/aiscript/api.ts index 01b8fd05f..6407d6b0d 100644 --- a/packages/client/src/scripts/aiscript/api.ts +++ b/packages/client/src/scripts/aiscript/api.ts @@ -24,7 +24,11 @@ export function createAiScriptEnv(opts) { return confirm.canceled ? values.FALSE : values.TRUE; }), 'Mk:api': values.FN_NATIVE(async ([ep, param, token]) => { - if (token) utils.assertString(token); + if (token) { + utils.assertString(token); + // In case there is a bug, it could be undefined. + if (typeof token.value !== 'string') throw new Error('invalid token'); + } apiRequests++; if (apiRequests > 16) return values.NULL; const res = await os.api(ep.value, utils.valToJs(param), token ? token.value : (opts.token || null)); diff --git a/packages/client/src/widgets/aiscript.vue b/packages/client/src/widgets/aiscript.vue index 30b16cac2..15357069e 100644 --- a/packages/client/src/widgets/aiscript.vue +++ b/packages/client/src/widgets/aiscript.vue @@ -72,7 +72,8 @@ const run = async (): Promise => { return new Promise(ok => { os.inputText({ title: q, - }).then(({ result: a }) => { + }).then(({ canceled, result: a }) => { + if (canceled) return; ok(a); }); }); diff --git a/packages/client/src/widgets/button.vue b/packages/client/src/widgets/button.vue index 9e4b84899..5a385380a 100644 --- a/packages/client/src/widgets/button.vue +++ b/packages/client/src/widgets/button.vue @@ -60,7 +60,8 @@ const run = async (): Promise => { return new Promise(ok => { os.inputText({ title: q, - }).then(({ result: a }) => { + }).then(({ canceled, result: a }) => { + if (canceled) return; ok(a); }); });