@elaraai/e3-ui-components 1.0.26 → 1.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/decision/facets.d.ts.map +1 -1
- package/dist/decision/handle-runtime.d.ts +3 -2
- package/dist/decision/handle-runtime.d.ts.map +1 -1
- package/dist/decision/queue.d.ts.map +1 -1
- package/dist/diff/index.d.ts.map +1 -1
- package/dist/hooks/useDatasetValue.d.ts.map +1 -1
- package/dist/index.cjs +615 -243
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +594 -222
- package/dist/index.js.map +1 -1
- package/dist/platform/bind-runtime.d.ts +32 -8
- package/dist/platform/bind-runtime.d.ts.map +1 -1
- package/dist/platform/func-runtime.d.ts +24 -3
- package/dist/platform/func-runtime.d.ts.map +1 -1
- package/dist/platform/record-runtime.d.ts +26 -3
- package/dist/platform/record-runtime.d.ts.map +1 -1
- package/package.json +13 -13
package/dist/index.js
CHANGED
|
@@ -18,16 +18,17 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
var _focused, _cleanup, _setup, _a, _provider, _providerCalled, _b, _online, _cleanup2, _setup2, _c, _gcTimeout, _d, _initialState, _revertState, _cache, _client, _retryer, _defaultOptions, _abortSignalConsumed, _Query_instances, isInitialPausedFetch_fn, dispatch_fn, _e, _client2, _observers, _mutationCache, _retryer2, _Mutation_instances, dispatch_fn2, _f, _mutations, _scopes, _mutationId, _g, _queries, _h, _queryCache, _mutationCache2, _defaultOptions2, _queryDefaults, _mutationDefaults, _mountCount, _unsubscribeFocus, _unsubscribeOnline, _i, _j;
|
|
21
|
-
import { variant, EastError, ConflictError, equalFor,
|
|
21
|
+
import { variant, SortedMap, compareFor, EastError, fromEastTypeValue, East, none as none$1, some, OptionType, BooleanType, NullType, ConflictError, equalFor, toEastTypeValue, PatchType, diffFor, applyFor, encodeBeast2For, decodeBeast2For, BlobType, StructType, StringType, walkPatch, pathToString, pathDisplay, printFor, isVariant, prunePatchFor, detectConflictsFor, mergeWithResolutionsFor, validatePatchFor, ArrayType } from "@elaraai/east";
|
|
22
22
|
import { EastTypeType } from "@elaraai/east/internal";
|
|
23
|
-
import { bindPlatformFn, funcBindPlatformFn, recordBindPlatformFn, Diff, Ontology, FuncBindHandleType, Experiment, decisionBindPlatformFn, DecisionQueue, DecisionJournal, decodeManifest } from "@elaraai/e3-ui/internal";
|
|
24
|
-
import { registerReactiveTracker, registerPlatformImplementation } from "@elaraai/east-ui-components/platform";
|
|
23
|
+
import { DataBindModeType, DataBindPrimitives, bindPlatformFn, FuncBindPrimitives, FuncErrorType, FuncStatusType, funcBindPlatformFn, RecordBindPrimitives, recordBindPlatformFn, Diff, Ontology, FuncBindHandleType, Experiment, decisionBindPlatformFn, DecisionBindPrimitives, DecisionConstraintType, DiffBindingType, CommitStateType, VerdictType, AnswerType, judgementInputType, DecisionType, DecisionQueue, DecisionJournal, decodeManifest } from "@elaraai/e3-ui/internal";
|
|
24
|
+
import { registerReactiveTracker, registerPlatformImplementation, getSomeorUndefined as getSomeorUndefined$1, StateRuntime, buildSliceHandle, DEFAULT_SLICE_STATE, getRegisteredPlatformImplementations } from "@elaraai/east-ui-components/platform";
|
|
25
|
+
import { TreePathType, DatasetStatusType } from "@elaraai/e3-types";
|
|
25
26
|
import { workspaceStatus, datasetListAt, datasetList, dataflowExecuteLaunch, datasetSet, datasetGet, ApiError, workspaceFunctionCall, workspaceFunctionList, workspaceRecordHistory, workspaceRecordMutate, workspaceRecordDescribe, repoCreate, repoGc, repoGcStart, repoGcStatus, repoList, repoRemove, repoStatus, packageExport, packageGet, packageImport, packageList, packageRemove, workspaceCreate, workspaceDeploy, workspaceExport, workspaceGet, workspaceList, workspaceRemove, datasetGetStatus, datasetListRecursive, datasetListRecursivePaths, datasetListWithStatus, taskExecutionList, taskGet, taskList, dataflowCancel, dataflowExecute, dataflowExecutePoll, dataflowGraph, taskLogs } from "@elaraai/e3-api-client";
|
|
26
27
|
import { jsx as jsx$1, Fragment, jsxs } from "react/jsx-runtime";
|
|
27
28
|
import * as React from "react";
|
|
28
29
|
import React__default, { useId, useMemo, useContext, createContext, useRef, useEffect, useState, useCallback, useSyncExternalStore, memo, forwardRef, useLayoutEffect, Fragment as Fragment$1, Component } from "react";
|
|
29
30
|
import { Box, Flex, Text, HStack, Input, useSlotRecipe, useRecipe, VStack, useToken, Drawer, Portal, Field, NativeSelect, Textarea, chakra, Tooltip, SegmentGroup, Menu, HoverCard, useChakraContext, Spinner, Code, Clipboard, IconButton, Badge, Button, Tabs, useTabs } from "@chakra-ui/react";
|
|
30
|
-
import { implementUIComponent, getSomeorUndefined, formatPredicate, SliceEditPopover, SlicePredicateBuilder,
|
|
31
|
+
import { implementUIComponent, getSomeorUndefined, formatPredicate, SliceEditPopover, SlicePredicateBuilder, EastChakraSelect, EastChakraStringInput, EastChakraDateTimeInput, EastChakraFloatInput, EastChakraIntegerInput, formatTick, useSliceReactivity, SliceRailCluster, EastChakraComponent, ClauseChip, StateImpl, NavImpl, SliceImpl, SliceApplyImpl, OverlayImpl, ClipboardImpl, DownloadImpl, ShareImpl, createUIStore, UIStoreProvider } from "@elaraai/east-ui-components";
|
|
31
32
|
import { createPortal } from "react-dom";
|
|
32
33
|
import { sliceMatches } from "@elaraai/east-ui/internal";
|
|
33
34
|
import { QueryClient as QueryClient$1, QueryClientProvider, useMutation, useQuery } from "@tanstack/react-query";
|
|
@@ -2916,6 +2917,17 @@ class BindRuntime {
|
|
|
2916
2917
|
__publicField(this, "fallbackWarningEmitted", /* @__PURE__ */ new Set());
|
|
2917
2918
|
// List cache helpers.
|
|
2918
2919
|
__publicField(this, "listCache", /* @__PURE__ */ new Map());
|
|
2920
|
+
// Compiled-handle cache (issue #106 perf). The bind impl compiles N
|
|
2921
|
+
// East.function methods per bind, and binds re-run on every reactive frame.
|
|
2922
|
+
// The compiled IR is a pure function of (sourceType, sourcePath, patch, mode)
|
|
2923
|
+
// — same key ⇒ same methods — and the methods resolve cache/workspace LIVE,
|
|
2924
|
+
// so a cached handle still re-binds correctly across renders / cache swaps.
|
|
2925
|
+
// Keyed *structurally* (each bind builds a fresh EastTypeValue from IR, so a
|
|
2926
|
+
// by-identity cache would miss every render — same reason as helpersCache).
|
|
2927
|
+
__publicField(this, "handleCache", new SortedMap(
|
|
2928
|
+
void 0,
|
|
2929
|
+
compareFor(EastTypeType)
|
|
2930
|
+
));
|
|
2919
2931
|
this.staged = staged;
|
|
2920
2932
|
this.staged.onPersistError((_key, err) => this.emitWriteError(err));
|
|
2921
2933
|
}
|
|
@@ -2946,6 +2958,7 @@ class BindRuntime {
|
|
|
2946
2958
|
clearCache() {
|
|
2947
2959
|
this.cache = null;
|
|
2948
2960
|
this.clearPendingWrites();
|
|
2961
|
+
this.handleCache.clear();
|
|
2949
2962
|
}
|
|
2950
2963
|
// ----- pending writes queue -------------------------------------------
|
|
2951
2964
|
/** Subscribe to write-queue errors. Returns an unsubscribe fn. */
|
|
@@ -3072,13 +3085,14 @@ class BindRuntime {
|
|
|
3072
3085
|
}
|
|
3073
3086
|
// ----- bind-handle construction --------------------------------------
|
|
3074
3087
|
/**
|
|
3075
|
-
* Build a bind handle
|
|
3076
|
-
*
|
|
3077
|
-
*
|
|
3088
|
+
* Build a `Data.bind` handle. Its methods are thin IR-bearing
|
|
3089
|
+
* `East.function`s over the `data_*` primitives, capturing only the
|
|
3090
|
+
* plain-data `{source, patch, mode}` descriptor — so the handle is ordinary
|
|
3091
|
+
* serializable East data (issue #106) and re-binds to the decoder's cache.
|
|
3092
|
+
* Public so tests can call it directly without East's compile/dispatch.
|
|
3078
3093
|
*
|
|
3079
|
-
* @throws `EastError` if the cache is uninitialized, the
|
|
3080
|
-
*
|
|
3081
|
-
* referenced path is not in it.
|
|
3094
|
+
* @throws `EastError` if the cache is uninitialized, the workspace is not
|
|
3095
|
+
* configured, or `allowed` is non-null and any referenced path is not in it.
|
|
3082
3096
|
*/
|
|
3083
3097
|
buildBindHandle(sourceType, sourcePath, patchPath, mode, allowed) {
|
|
3084
3098
|
const cache3 = this.requireCache();
|
|
@@ -3102,6 +3116,106 @@ class BindRuntime {
|
|
|
3102
3116
|
}
|
|
3103
3117
|
}
|
|
3104
3118
|
}
|
|
3119
|
+
const { patchType } = getBindingHelpers(sourceType);
|
|
3120
|
+
this.registerBindingTypes(ws, sourcePath, {
|
|
3121
|
+
workspace: ws,
|
|
3122
|
+
sourceType,
|
|
3123
|
+
patchType,
|
|
3124
|
+
mode,
|
|
3125
|
+
hasPatchDataset: patchPath !== void 0
|
|
3126
|
+
});
|
|
3127
|
+
const descKey = `${datasetPathToString(sourcePath)}\0${patchPath !== void 0 ? datasetPathToString(patchPath) : ""}\0${mode}`;
|
|
3128
|
+
let byDesc = this.handleCache.get(sourceType);
|
|
3129
|
+
if (byDesc) {
|
|
3130
|
+
const hit = byDesc.get(descKey);
|
|
3131
|
+
if (hit) return hit;
|
|
3132
|
+
} else {
|
|
3133
|
+
byDesc = /* @__PURE__ */ new Map();
|
|
3134
|
+
this.handleCache.set(sourceType, byDesc);
|
|
3135
|
+
}
|
|
3136
|
+
const T2 = fromEastTypeValue(sourceType);
|
|
3137
|
+
const srcExpr = East.value(sourcePath, TreePathType);
|
|
3138
|
+
const patchExpr = East.value(patchPath !== void 0 ? some(patchPath) : none$1, OptionType(TreePathType));
|
|
3139
|
+
const modeExpr = East.value(variant(mode, null), DataBindModeType);
|
|
3140
|
+
const platform = this.buildPrimitives();
|
|
3141
|
+
const P2 = DataBindPrimitives;
|
|
3142
|
+
const handle = {
|
|
3143
|
+
read: East.compile(East.function([], T2, ($3) => {
|
|
3144
|
+
$3.return(P2.read([T2], srcExpr, patchExpr, modeExpr));
|
|
3145
|
+
}), platform),
|
|
3146
|
+
write: East.compile(East.function([T2], NullType, ($3, v3) => {
|
|
3147
|
+
$3.return(P2.write([T2], srcExpr, patchExpr, modeExpr, v3));
|
|
3148
|
+
}), platform),
|
|
3149
|
+
writeAndStart: East.compile(East.function([T2], NullType, ($3, v3) => {
|
|
3150
|
+
$3.return(P2.writeAndStart([T2], srcExpr, patchExpr, modeExpr, v3));
|
|
3151
|
+
}), platform),
|
|
3152
|
+
start: East.compile(East.function([], NullType, ($3) => {
|
|
3153
|
+
$3.return(P2.start([T2], srcExpr, patchExpr, modeExpr));
|
|
3154
|
+
}), platform),
|
|
3155
|
+
source: East.compile(East.function([], T2, ($3) => {
|
|
3156
|
+
$3.return(P2.source([T2], srcExpr, patchExpr, modeExpr));
|
|
3157
|
+
}), platform),
|
|
3158
|
+
pending: East.compile(East.function([], BooleanType, ($3) => {
|
|
3159
|
+
$3.return(P2.pending([T2], srcExpr, patchExpr, modeExpr));
|
|
3160
|
+
}), platform),
|
|
3161
|
+
commit: East.compile(East.function([], NullType, ($3) => {
|
|
3162
|
+
$3.return(P2.commit([T2], srcExpr, patchExpr, modeExpr));
|
|
3163
|
+
}), platform),
|
|
3164
|
+
discard: East.compile(East.function([], NullType, ($3) => {
|
|
3165
|
+
$3.return(P2.discard([T2], srcExpr, patchExpr, modeExpr));
|
|
3166
|
+
}), platform),
|
|
3167
|
+
has: East.compile(East.function([], BooleanType, ($3) => {
|
|
3168
|
+
$3.return(P2.has([T2], srcExpr, patchExpr, modeExpr));
|
|
3169
|
+
}), platform),
|
|
3170
|
+
status: East.compile(East.function([], DatasetStatusType, ($3) => {
|
|
3171
|
+
$3.return(P2.status([T2], srcExpr, patchExpr, modeExpr));
|
|
3172
|
+
}), platform),
|
|
3173
|
+
binding: {
|
|
3174
|
+
source: sourcePath,
|
|
3175
|
+
patch: patchPath !== void 0 ? some(patchPath) : none$1,
|
|
3176
|
+
mode: variant(mode, null)
|
|
3177
|
+
}
|
|
3178
|
+
};
|
|
3179
|
+
byDesc.set(descKey, handle);
|
|
3180
|
+
return handle;
|
|
3181
|
+
}
|
|
3182
|
+
/**
|
|
3183
|
+
* The low-level primitives backing handle methods, bound to THIS runtime.
|
|
3184
|
+
* Registered globally (extension registry) and included by the scoped
|
|
3185
|
+
* platform (e3 `ui()` tasks) so a decoded handle re-binds here. Each impl
|
|
3186
|
+
* recovers the `{source, patch, mode}` descriptor from its args and delegates
|
|
3187
|
+
* to {@link buildRawHandle}, reusing the full mode×patch logic verbatim.
|
|
3188
|
+
*/
|
|
3189
|
+
buildPrimitives() {
|
|
3190
|
+
const raw = (sourceType, sourceArg, patchOpt, modeVariant) => {
|
|
3191
|
+
const { patchPath, mode } = resolveOptions(patchOpt, modeVariant);
|
|
3192
|
+
return this.buildRawHandle(sourceType, sourceArg, patchPath, mode);
|
|
3193
|
+
};
|
|
3194
|
+
const P2 = DataBindPrimitives;
|
|
3195
|
+
return [
|
|
3196
|
+
P2.read.implement((t4) => (s2, p2, m2) => raw(t4, s2, p2, m2).read()),
|
|
3197
|
+
P2.source.implement((t4) => (s2, p2, m2) => raw(t4, s2, p2, m2).source()),
|
|
3198
|
+
P2.write.implement((t4) => (s2, p2, m2, v3) => raw(t4, s2, p2, m2).write(v3)),
|
|
3199
|
+
P2.writeAndStart.implement((t4) => (s2, p2, m2, v3) => raw(t4, s2, p2, m2).writeAndStart(v3)),
|
|
3200
|
+
P2.start.implement((t4) => (s2, p2, m2) => raw(t4, s2, p2, m2).start()),
|
|
3201
|
+
P2.pending.implement((t4) => (s2, p2, m2) => raw(t4, s2, p2, m2).pending()),
|
|
3202
|
+
P2.commit.implement((t4) => (s2, p2, m2) => raw(t4, s2, p2, m2).commit()),
|
|
3203
|
+
P2.discard.implement((t4) => (s2, p2, m2) => raw(t4, s2, p2, m2).discard()),
|
|
3204
|
+
P2.has.implement((t4) => (s2, p2, m2) => raw(t4, s2, p2, m2).has()),
|
|
3205
|
+
P2.status.implement((t4) => (s2, p2, m2) => raw(t4, s2, p2, m2).status())
|
|
3206
|
+
];
|
|
3207
|
+
}
|
|
3208
|
+
/**
|
|
3209
|
+
* Build the raw (host-closure) bind handle for a single
|
|
3210
|
+
* `(sourcePath, mode, patch?)` triple. The mode×patch matrix lives here; the
|
|
3211
|
+
* serializable {@link buildBindHandle} wraps each method as an `East.function`
|
|
3212
|
+
* over a primitive that delegates back here. Re-registers binding types on
|
|
3213
|
+
* every call (decode self-heal). Public so tests can drive the raw closures.
|
|
3214
|
+
*/
|
|
3215
|
+
buildRawHandle(sourceType, sourcePath, patchPath, mode) {
|
|
3216
|
+
const cache3 = this.requireCache();
|
|
3217
|
+
const ws = cache3.getConfig().workspace;
|
|
3218
|
+
if (!ws) throw new Error("ReactiveDatasetCache workspace not configured");
|
|
3105
3219
|
const { patchType, decodeT, encodeT, decodePatch, encodePatch, apply: apply2, diff: diff2 } = getBindingHelpers(sourceType);
|
|
3106
3220
|
this.registerBindingTypes(ws, sourcePath, {
|
|
3107
3221
|
workspace: ws,
|
|
@@ -3416,10 +3530,16 @@ function awaitPendingWrites() {
|
|
|
3416
3530
|
function clearPendingWrites() {
|
|
3417
3531
|
defaultBindRuntime.clearPendingWrites();
|
|
3418
3532
|
}
|
|
3419
|
-
const BindPlatform = [
|
|
3533
|
+
const BindPlatform = [
|
|
3534
|
+
defaultBindRuntime.buildPlatform(null),
|
|
3535
|
+
...defaultBindRuntime.buildPrimitives()
|
|
3536
|
+
];
|
|
3420
3537
|
function createScopedBindPlatform(manifest) {
|
|
3421
3538
|
const allowed = new Set(manifest.paths.map((p2) => datasetPathToString(p2)));
|
|
3422
|
-
return [
|
|
3539
|
+
return [
|
|
3540
|
+
defaultBindRuntime.buildPlatform(allowed),
|
|
3541
|
+
...defaultBindRuntime.buildPrimitives()
|
|
3542
|
+
];
|
|
3423
3543
|
}
|
|
3424
3544
|
async function preloadReactiveDatasetList(workspace, path2) {
|
|
3425
3545
|
return defaultBindRuntime.preloadList(workspace, path2);
|
|
@@ -3649,6 +3769,11 @@ class FuncRuntime extends TrackedChannelStore {
|
|
|
3649
3769
|
__publicField(this, "workspace", null);
|
|
3650
3770
|
// Signature lists are fetched once per workspace and cached.
|
|
3651
3771
|
__publicField(this, "signatureLists", /* @__PURE__ */ new Map());
|
|
3772
|
+
// Compiled-handle cache (issue #106 perf): buildHandle compiles 6 East.functions
|
|
3773
|
+
// per bind, and binds re-run every reactive frame. The method IR is a pure
|
|
3774
|
+
// function of the function name (which fixes the handle type), and the methods
|
|
3775
|
+
// resolve workspace/api LIVE, so a cached handle still re-binds. Cleared on clear().
|
|
3776
|
+
__publicField(this, "handleCache", /* @__PURE__ */ new Map());
|
|
3652
3777
|
}
|
|
3653
3778
|
createEntry() {
|
|
3654
3779
|
return { status: "idle", launchSeq: 0 };
|
|
@@ -3666,6 +3791,7 @@ class FuncRuntime extends TrackedChannelStore {
|
|
|
3666
3791
|
this.workspace = null;
|
|
3667
3792
|
this.clearChannels();
|
|
3668
3793
|
this.signatureLists.clear();
|
|
3794
|
+
this.handleCache.clear();
|
|
3669
3795
|
}
|
|
3670
3796
|
/** The deployed signature list for a workspace (fetched once). */
|
|
3671
3797
|
signatures(workspace) {
|
|
@@ -3769,9 +3895,15 @@ class FuncRuntime extends TrackedChannelStore {
|
|
|
3769
3895
|
}
|
|
3770
3896
|
})();
|
|
3771
3897
|
}
|
|
3772
|
-
/**
|
|
3773
|
-
|
|
3774
|
-
|
|
3898
|
+
/**
|
|
3899
|
+
* The 6 low-level primitives backing handle methods, bound to THIS runtime.
|
|
3900
|
+
* Registered globally (extension registry) and included by the scoped
|
|
3901
|
+
* platform (e3 `ui()` tasks) so a decoded handle re-binds to whatever runtime
|
|
3902
|
+
* resolves the primitives on the decode side. The host effects (launch /
|
|
3903
|
+
* channel reads + reactive tracking) live here, keyed only on the plain-data
|
|
3904
|
+
* function name; the output type rides as a type-arg.
|
|
3905
|
+
*/
|
|
3906
|
+
buildPrimitives() {
|
|
3775
3907
|
const runtime = this;
|
|
3776
3908
|
const resolveWorkspace = () => {
|
|
3777
3909
|
if (!runtime.workspace) {
|
|
@@ -3779,42 +3911,91 @@ class FuncRuntime extends TrackedChannelStore {
|
|
|
3779
3911
|
}
|
|
3780
3912
|
return runtime.workspace;
|
|
3781
3913
|
};
|
|
3782
|
-
const channel = () => {
|
|
3914
|
+
const channel = (name) => {
|
|
3783
3915
|
const key = funcChannelKey(resolveWorkspace(), name);
|
|
3784
3916
|
return { key, entry: runtime.entry(key) };
|
|
3785
3917
|
};
|
|
3786
|
-
return
|
|
3787
|
-
call:
|
|
3788
|
-
|
|
3918
|
+
return [
|
|
3919
|
+
// call: recover per-arg input types from the ArgsStruct type-arg + the
|
|
3920
|
+
// values from the passed struct (field order), and the output type from O.
|
|
3921
|
+
FuncBindPrimitives.call.implement((argsStructType, outputType) => (nameArg, argsStruct) => {
|
|
3922
|
+
const fields = argsStructType.value;
|
|
3923
|
+
const obj = argsStruct;
|
|
3924
|
+
const inputs = fields.map((f2) => f2.type);
|
|
3925
|
+
const args = fields.map((f2) => obj[f2.name]);
|
|
3926
|
+
runtime.launch(resolveWorkspace(), nameArg, { inputs, output: outputType }, args);
|
|
3789
3927
|
return null;
|
|
3790
|
-
},
|
|
3791
|
-
read
|
|
3792
|
-
const { key, entry } = channel();
|
|
3928
|
+
}),
|
|
3929
|
+
FuncBindPrimitives.read.implement((_outputType) => (nameArg) => {
|
|
3930
|
+
const { key, entry } = channel(nameArg);
|
|
3793
3931
|
runtime.track(key);
|
|
3794
3932
|
return entry.result !== void 0 ? variant("some", entry.result) : variant("none", null);
|
|
3795
|
-
},
|
|
3796
|
-
status
|
|
3797
|
-
const { key, entry } = channel();
|
|
3933
|
+
}),
|
|
3934
|
+
FuncBindPrimitives.status.implement((nameArg) => {
|
|
3935
|
+
const { key, entry } = channel(nameArg);
|
|
3798
3936
|
runtime.track(key);
|
|
3799
3937
|
return variant(entry.status, null);
|
|
3800
|
-
},
|
|
3801
|
-
error
|
|
3802
|
-
const { key, entry } = channel();
|
|
3938
|
+
}),
|
|
3939
|
+
FuncBindPrimitives.error.implement((nameArg) => {
|
|
3940
|
+
const { key, entry } = channel(nameArg);
|
|
3803
3941
|
runtime.track(key);
|
|
3804
3942
|
return entry.status === "failed" && entry.error !== void 0 ? variant("some", entry.error) : variant("none", null);
|
|
3805
|
-
},
|
|
3806
|
-
pending
|
|
3807
|
-
const { key, entry } = channel();
|
|
3943
|
+
}),
|
|
3944
|
+
FuncBindPrimitives.pending.implement((nameArg) => {
|
|
3945
|
+
const { key, entry } = channel(nameArg);
|
|
3808
3946
|
runtime.track(key);
|
|
3809
3947
|
return entry.status === "running";
|
|
3810
|
-
},
|
|
3811
|
-
cancel
|
|
3812
|
-
const { key } = channel();
|
|
3948
|
+
}),
|
|
3949
|
+
FuncBindPrimitives.cancel.implement((nameArg) => {
|
|
3950
|
+
const { key } = channel(nameArg);
|
|
3813
3951
|
runtime.cancelChannel(key);
|
|
3814
3952
|
return null;
|
|
3815
|
-
}
|
|
3953
|
+
})
|
|
3954
|
+
];
|
|
3955
|
+
}
|
|
3956
|
+
/**
|
|
3957
|
+
* Build the handle value for one `Func.bind` evaluation. The methods are
|
|
3958
|
+
* thin IR-bearing `East.function`s over {@link buildPrimitives}, capturing
|
|
3959
|
+
* only the function name (and the signature types via type-args) — so the
|
|
3960
|
+
* handle is ordinary serializable East data (issue #106).
|
|
3961
|
+
*/
|
|
3962
|
+
buildHandle(handleType, name) {
|
|
3963
|
+
const cached = this.handleCache.get(name);
|
|
3964
|
+
if (cached) return cached;
|
|
3965
|
+
const sig = signatureOfFuncHandleType(handleType);
|
|
3966
|
+
const inputsEast = sig.inputs.map((t4) => fromEastTypeValue(t4));
|
|
3967
|
+
const outputEast = fromEastTypeValue(sig.output);
|
|
3968
|
+
const ArgsStruct = StructType(Object.fromEntries(inputsEast.map((t4, i) => [`arg${i}`, t4])));
|
|
3969
|
+
const nameExpr = East.value(name, StringType);
|
|
3970
|
+
const platform = this.buildPrimitives();
|
|
3971
|
+
const { call, read, status, error: error3, pending, cancel } = FuncBindPrimitives;
|
|
3972
|
+
const handle = {
|
|
3973
|
+
call: East.compile(East.function(inputsEast, NullType, ($3, ...args) => {
|
|
3974
|
+
const obj = {};
|
|
3975
|
+
args.forEach((a2, i) => {
|
|
3976
|
+
obj[`arg${i}`] = a2;
|
|
3977
|
+
});
|
|
3978
|
+
$3.return(call([ArgsStruct, outputEast], nameExpr, East.value(obj, ArgsStruct)));
|
|
3979
|
+
}), platform),
|
|
3980
|
+
read: East.compile(East.function([], OptionType(outputEast), ($3) => {
|
|
3981
|
+
$3.return(read([outputEast], nameExpr));
|
|
3982
|
+
}), platform),
|
|
3983
|
+
status: East.compile(East.function([], FuncStatusType, ($3) => {
|
|
3984
|
+
$3.return(status(nameExpr));
|
|
3985
|
+
}), platform),
|
|
3986
|
+
error: East.compile(East.function([], OptionType(FuncErrorType), ($3) => {
|
|
3987
|
+
$3.return(error3(nameExpr));
|
|
3988
|
+
}), platform),
|
|
3989
|
+
pending: East.compile(East.function([], BooleanType, ($3) => {
|
|
3990
|
+
$3.return(pending(nameExpr));
|
|
3991
|
+
}), platform),
|
|
3992
|
+
cancel: East.compile(East.function([], NullType, ($3) => {
|
|
3993
|
+
$3.return(cancel(nameExpr));
|
|
3994
|
+
}), platform),
|
|
3816
3995
|
binding: { name }
|
|
3817
3996
|
};
|
|
3997
|
+
this.handleCache.set(name, handle);
|
|
3998
|
+
return handle;
|
|
3818
3999
|
}
|
|
3819
4000
|
// ----- platform building -------------------------------------------------
|
|
3820
4001
|
/** Build a `Func.bind` PlatformFunction bound to this runtime. Pass
|
|
@@ -3841,9 +4022,15 @@ function initializeFunctionApi(api3, workspace) {
|
|
|
3841
4022
|
function clearFunctionApi() {
|
|
3842
4023
|
defaultFuncRuntime.clear();
|
|
3843
4024
|
}
|
|
3844
|
-
const FuncPlatform = [
|
|
4025
|
+
const FuncPlatform = [
|
|
4026
|
+
defaultFuncRuntime.buildPlatform(null),
|
|
4027
|
+
...defaultFuncRuntime.buildPrimitives()
|
|
4028
|
+
];
|
|
3845
4029
|
function createScopedFuncPlatform(functions2) {
|
|
3846
|
-
return [
|
|
4030
|
+
return [
|
|
4031
|
+
defaultFuncRuntime.buildPlatform(new Set(functions2)),
|
|
4032
|
+
...defaultFuncRuntime.buildPrimitives()
|
|
4033
|
+
];
|
|
3847
4034
|
}
|
|
3848
4035
|
function createInMemoryFunctionApi(functions2) {
|
|
3849
4036
|
const defs2 = functions2.map((def) => ({
|
|
@@ -7653,6 +7840,12 @@ class RecordRuntime extends TrackedChannelStore {
|
|
|
7653
7840
|
// otherwise spin); cleared on the next commit / on clear() so a later
|
|
7654
7841
|
// mutation retries.
|
|
7655
7842
|
__publicField(this, "historyFailed", /* @__PURE__ */ new Set());
|
|
7843
|
+
// Compiled-handle cache (issue #106 perf): buildHandle compiles 8 + (one per
|
|
7844
|
+
// mutation) East.functions per bind, and binds re-run every reactive frame.
|
|
7845
|
+
// The method IR is a pure function of the record name (which fixes the handle
|
|
7846
|
+
// type), and the methods resolve cache/api/ws LIVE, so a cached handle still
|
|
7847
|
+
// re-binds. Cleared on clear().
|
|
7848
|
+
__publicField(this, "handleCache", /* @__PURE__ */ new Map());
|
|
7656
7849
|
}
|
|
7657
7850
|
createEntry() {
|
|
7658
7851
|
return { status: "idle", launchSeq: 0 };
|
|
@@ -7675,6 +7868,7 @@ class RecordRuntime extends TrackedChannelStore {
|
|
|
7675
7868
|
this.histories.clear();
|
|
7676
7869
|
this.historyInFlight.clear();
|
|
7677
7870
|
this.historyFailed.clear();
|
|
7871
|
+
this.handleCache.clear();
|
|
7678
7872
|
}
|
|
7679
7873
|
resolveWorkspace() {
|
|
7680
7874
|
if (!this.workspace) {
|
|
@@ -7793,89 +7987,163 @@ class RecordRuntime extends TrackedChannelStore {
|
|
|
7793
7987
|
if (current && current.inflight === run) delete current.inflight;
|
|
7794
7988
|
});
|
|
7795
7989
|
}
|
|
7796
|
-
/**
|
|
7797
|
-
|
|
7798
|
-
|
|
7799
|
-
|
|
7990
|
+
/**
|
|
7991
|
+
* The low-level primitives backing handle methods, bound to THIS runtime.
|
|
7992
|
+
* Registered globally (extension registry) and included by the scoped
|
|
7993
|
+
* platform (e3 `ui()` tasks) so a decoded handle re-binds here. The host
|
|
7994
|
+
* effects (dataset-cache reads + reactive tracking + mutation launch) live
|
|
7995
|
+
* here, keyed only on the plain-data record name; the state type rides as a
|
|
7996
|
+
* type-arg on `record_read`, and per-mutation arg types come from the
|
|
7997
|
+
* `record_mutate` ArgsStruct type-arg.
|
|
7998
|
+
*/
|
|
7999
|
+
buildPrimitives() {
|
|
7800
8000
|
const runtime = this;
|
|
7801
|
-
const path2 = recordPath(name);
|
|
7802
8001
|
const requireCache = () => {
|
|
7803
8002
|
if (!runtime.cache) {
|
|
7804
8003
|
throw new Error("Record.bind: no dataset cache configured — mount a provider first");
|
|
7805
8004
|
}
|
|
7806
8005
|
return runtime.cache;
|
|
7807
8006
|
};
|
|
7808
|
-
|
|
7809
|
-
|
|
8007
|
+
return [
|
|
8008
|
+
RecordBindPrimitives.read.implement((stateType) => {
|
|
8009
|
+
const decode = decodeBeast2For(stateType);
|
|
8010
|
+
return (nameArg) => {
|
|
8011
|
+
const ws = runtime.resolveWorkspace();
|
|
8012
|
+
const path2 = recordPath(nameArg);
|
|
8013
|
+
trackDatasetPath(ws, path2);
|
|
8014
|
+
const bytes = requireCache().read(ws, path2);
|
|
8015
|
+
if (bytes === void 0) {
|
|
8016
|
+
throw new Error(`Record.bind: record state not loaded: ${datasetCacheKey(ws, path2)} (it should be preloaded via the UI task manifest)`);
|
|
8017
|
+
}
|
|
8018
|
+
return decode(bytes);
|
|
8019
|
+
};
|
|
8020
|
+
}),
|
|
8021
|
+
RecordBindPrimitives.status.implement((nameArg) => {
|
|
8022
|
+
const ws = runtime.resolveWorkspace();
|
|
8023
|
+
const path2 = recordPath(nameArg);
|
|
8024
|
+
trackDatasetPath(ws, path2);
|
|
8025
|
+
return requireCache().getStatus(ws, path2);
|
|
8026
|
+
}),
|
|
8027
|
+
RecordBindPrimitives.history.implement((nameArg) => {
|
|
8028
|
+
const name = nameArg;
|
|
7810
8029
|
const ws = runtime.resolveWorkspace();
|
|
7811
8030
|
const key = recordChannelKey(ws, name);
|
|
7812
8031
|
runtime.track(key);
|
|
8032
|
+
const cached = runtime.histories.get(key);
|
|
8033
|
+
if (cached === void 0) {
|
|
8034
|
+
if (!runtime.historyFailed.has(key)) runtime.fetchHistory(ws, name, key);
|
|
8035
|
+
return none$1;
|
|
8036
|
+
}
|
|
8037
|
+
return some(cached);
|
|
8038
|
+
}),
|
|
8039
|
+
RecordBindPrimitives.start.implement((nameArg) => {
|
|
8040
|
+
const ws = runtime.resolveWorkspace();
|
|
8041
|
+
const cache3 = requireCache();
|
|
8042
|
+
const inflight = runtime.entry(recordChannelKey(ws, nameArg)).inflight;
|
|
8043
|
+
void Promise.resolve(inflight).catch(() => void 0).then(() => cache3.launchDataflow(ws)).catch(() => void 0);
|
|
8044
|
+
return null;
|
|
8045
|
+
}),
|
|
8046
|
+
RecordBindPrimitives.mutatePending.implement((nameArg) => {
|
|
8047
|
+
const ws = runtime.resolveWorkspace();
|
|
8048
|
+
const key = recordChannelKey(ws, nameArg);
|
|
8049
|
+
runtime.track(key);
|
|
7813
8050
|
return runtime.entry(key).status === "running";
|
|
7814
|
-
},
|
|
7815
|
-
|
|
8051
|
+
}),
|
|
8052
|
+
RecordBindPrimitives.mutateStatus.implement((nameArg) => {
|
|
7816
8053
|
const ws = runtime.resolveWorkspace();
|
|
7817
|
-
const key = recordChannelKey(ws,
|
|
8054
|
+
const key = recordChannelKey(ws, nameArg);
|
|
7818
8055
|
runtime.track(key);
|
|
7819
8056
|
return variant(runtime.entry(key).status, null);
|
|
7820
|
-
},
|
|
7821
|
-
|
|
8057
|
+
}),
|
|
8058
|
+
RecordBindPrimitives.mutateError.implement((nameArg) => {
|
|
7822
8059
|
const ws = runtime.resolveWorkspace();
|
|
7823
|
-
const key = recordChannelKey(ws,
|
|
8060
|
+
const key = recordChannelKey(ws, nameArg);
|
|
7824
8061
|
runtime.track(key);
|
|
7825
8062
|
const entry = runtime.entry(key);
|
|
7826
8063
|
return entry.status === "failed" && entry.error !== void 0 ? some(entry.error) : none$1;
|
|
7827
|
-
},
|
|
7828
|
-
|
|
8064
|
+
}),
|
|
8065
|
+
RecordBindPrimitives.mutateCancel.implement((nameArg) => {
|
|
7829
8066
|
const ws = runtime.resolveWorkspace();
|
|
7830
|
-
runtime.cancelChannel(recordChannelKey(ws,
|
|
8067
|
+
runtime.cancelChannel(recordChannelKey(ws, nameArg), (e3) => {
|
|
7831
8068
|
delete e3.error;
|
|
7832
8069
|
delete e3.inflight;
|
|
7833
8070
|
});
|
|
7834
8071
|
return null;
|
|
7835
|
-
}
|
|
8072
|
+
}),
|
|
8073
|
+
RecordBindPrimitives.mutate.implement((argsStructType) => (recordNameArg, mutationNameArg, argsStruct) => {
|
|
8074
|
+
const fields = argsStructType.value;
|
|
8075
|
+
const obj = argsStruct;
|
|
8076
|
+
const argTypes = fields.map((f2) => f2.type);
|
|
8077
|
+
const args = fields.map((f2) => obj[f2.name]);
|
|
8078
|
+
runtime.launchMutation(runtime.resolveWorkspace(), recordNameArg, mutationNameArg, argTypes, args);
|
|
8079
|
+
return null;
|
|
8080
|
+
})
|
|
8081
|
+
];
|
|
8082
|
+
}
|
|
8083
|
+
/**
|
|
8084
|
+
* Build the handle value for one `Record.bind` evaluation. Every method —
|
|
8085
|
+
* top-level AND nested `mutate.*` (incl. the dynamic per-mutation closures) —
|
|
8086
|
+
* is a thin IR-bearing `East.function` over {@link buildPrimitives}, capturing
|
|
8087
|
+
* only the record name (+ per-mutation name), so the handle is ordinary
|
|
8088
|
+
* serializable East data (issue #106).
|
|
8089
|
+
*/
|
|
8090
|
+
buildHandle(handleType, name) {
|
|
8091
|
+
const cached = this.handleCache.get(name);
|
|
8092
|
+
if (cached) return cached;
|
|
8093
|
+
const sig = signatureOfRecordHandleType(handleType);
|
|
8094
|
+
const stateTypeEast = fromEastTypeValue(sig.stateType);
|
|
8095
|
+
const fields = handleType.value;
|
|
8096
|
+
const fnOut = (list, n2) => fromEastTypeValue(list.find((f2) => f2.name === n2).type.value.output);
|
|
8097
|
+
const statusRet = fnOut(fields, "status");
|
|
8098
|
+
const historyRet = fnOut(fields, "history");
|
|
8099
|
+
const mfields = fields.find((f2) => f2.name === "mutate").type.value;
|
|
8100
|
+
const nameExpr = East.value(name, StringType);
|
|
8101
|
+
const platform = this.buildPrimitives();
|
|
8102
|
+
const P2 = RecordBindPrimitives;
|
|
8103
|
+
const mutate = {
|
|
8104
|
+
pending: East.compile(East.function([], fnOut(mfields, "pending"), ($3) => {
|
|
8105
|
+
$3.return(P2.mutatePending(nameExpr));
|
|
8106
|
+
}), platform),
|
|
8107
|
+
status: East.compile(East.function([], fnOut(mfields, "status"), ($3) => {
|
|
8108
|
+
$3.return(P2.mutateStatus(nameExpr));
|
|
8109
|
+
}), platform),
|
|
8110
|
+
error: East.compile(East.function([], fnOut(mfields, "error"), ($3) => {
|
|
8111
|
+
$3.return(P2.mutateError(nameExpr));
|
|
8112
|
+
}), platform),
|
|
8113
|
+
cancel: East.compile(East.function([], NullType, ($3) => {
|
|
8114
|
+
$3.return(P2.mutateCancel(nameExpr));
|
|
8115
|
+
}), platform)
|
|
7836
8116
|
};
|
|
7837
8117
|
for (const [mutationName, argTypes] of sig.mutations) {
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
return
|
|
7852
|
-
},
|
|
7853
|
-
status: () => {
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
const ws = runtime.resolveWorkspace();
|
|
7860
|
-
const key = recordChannelKey(ws, name);
|
|
7861
|
-
runtime.track(key);
|
|
7862
|
-
const cached = runtime.histories.get(key);
|
|
7863
|
-
if (cached === void 0) {
|
|
7864
|
-
if (!runtime.historyFailed.has(key)) runtime.fetchHistory(ws, name, key);
|
|
7865
|
-
return none$1;
|
|
7866
|
-
}
|
|
7867
|
-
return some(cached);
|
|
7868
|
-
},
|
|
8118
|
+
const argTypesEast = argTypes.map((t4) => fromEastTypeValue(t4));
|
|
8119
|
+
const ArgsStruct = StructType(Object.fromEntries(argTypesEast.map((t4, i) => [`arg${i}`, t4])));
|
|
8120
|
+
const mutationNameExpr = East.value(mutationName, StringType);
|
|
8121
|
+
mutate[mutationName] = East.compile(East.function(argTypesEast, NullType, ($3, ...args) => {
|
|
8122
|
+
const obj = {};
|
|
8123
|
+
args.forEach((a2, i) => {
|
|
8124
|
+
obj[`arg${i}`] = a2;
|
|
8125
|
+
});
|
|
8126
|
+
$3.return(P2.mutate([ArgsStruct], nameExpr, mutationNameExpr, East.value(obj, ArgsStruct)));
|
|
8127
|
+
}), platform);
|
|
8128
|
+
}
|
|
8129
|
+
const handle = {
|
|
8130
|
+
read: East.compile(East.function([], stateTypeEast, ($3) => {
|
|
8131
|
+
$3.return(P2.read([stateTypeEast], nameExpr));
|
|
8132
|
+
}), platform),
|
|
8133
|
+
status: East.compile(East.function([], statusRet, ($3) => {
|
|
8134
|
+
$3.return(P2.status(nameExpr));
|
|
8135
|
+
}), platform),
|
|
8136
|
+
history: East.compile(East.function([], historyRet, ($3) => {
|
|
8137
|
+
$3.return(P2.history(nameExpr));
|
|
8138
|
+
}), platform),
|
|
7869
8139
|
mutate,
|
|
7870
|
-
start: () => {
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
const inflight = runtime.entry(recordChannelKey(ws, name)).inflight;
|
|
7874
|
-
void Promise.resolve(inflight).catch(() => void 0).then(() => cache3.launchDataflow(ws)).catch(() => void 0);
|
|
7875
|
-
return null;
|
|
7876
|
-
},
|
|
8140
|
+
start: East.compile(East.function([], NullType, ($3) => {
|
|
8141
|
+
$3.return(P2.start(nameExpr));
|
|
8142
|
+
}), platform),
|
|
7877
8143
|
binding: { name, mutations: [...sig.mutations.keys()] }
|
|
7878
8144
|
};
|
|
8145
|
+
this.handleCache.set(name, handle);
|
|
8146
|
+
return handle;
|
|
7879
8147
|
}
|
|
7880
8148
|
// ----- platform building -------------------------------------------------
|
|
7881
8149
|
/** Build a `Record.bind` PlatformFunction bound to this runtime. Pass
|
|
@@ -7902,9 +8170,15 @@ function initializeRecordApi(api3, cache3, workspace) {
|
|
|
7902
8170
|
function clearRecordApi() {
|
|
7903
8171
|
defaultRecordRuntime.clear();
|
|
7904
8172
|
}
|
|
7905
|
-
const RecordPlatform = [
|
|
8173
|
+
const RecordPlatform = [
|
|
8174
|
+
defaultRecordRuntime.buildPlatform(null),
|
|
8175
|
+
...defaultRecordRuntime.buildPrimitives()
|
|
8176
|
+
];
|
|
7906
8177
|
function createScopedRecordPlatform(records) {
|
|
7907
|
-
return [
|
|
8178
|
+
return [
|
|
8179
|
+
defaultRecordRuntime.buildPlatform(new Set(records)),
|
|
8180
|
+
...defaultRecordRuntime.buildPrimitives()
|
|
8181
|
+
];
|
|
7908
8182
|
}
|
|
7909
8183
|
function createInMemoryRecordApi(cache3, workspace, defs2) {
|
|
7910
8184
|
const compiled = /* @__PURE__ */ new Map();
|
|
@@ -9182,7 +9456,7 @@ const EastChakraDiff = memo(function EastChakraDiff2({ value }) {
|
|
|
9182
9456
|
return /* @__PURE__ */ jsx$1(
|
|
9183
9457
|
Box,
|
|
9184
9458
|
{
|
|
9185
|
-
layerStyle: "
|
|
9459
|
+
layerStyle: "surface.frameless",
|
|
9186
9460
|
p: "28px",
|
|
9187
9461
|
textAlign: "center",
|
|
9188
9462
|
color: "fg.subtle",
|
|
@@ -9209,9 +9483,8 @@ const EastChakraDiff = memo(function EastChakraDiff2({ value }) {
|
|
|
9209
9483
|
return /* @__PURE__ */ jsxs(
|
|
9210
9484
|
Box,
|
|
9211
9485
|
{
|
|
9212
|
-
layerStyle: "
|
|
9486
|
+
layerStyle: "surface.frameless",
|
|
9213
9487
|
fontFamily: "body",
|
|
9214
|
-
borderColor: inConflictMode ? "fg.warning" : "border.strong",
|
|
9215
9488
|
children: [
|
|
9216
9489
|
/* @__PURE__ */ jsxs(Box, { css: es.root, children: [
|
|
9217
9490
|
/* @__PURE__ */ jsx$1(Box, { css: es.lbl, children: "Pending changes" }),
|
|
@@ -60730,7 +61003,7 @@ function LoadingSkeleton() {
|
|
|
60730
61003
|
const sk = useRecipe({ key: "skeleton" });
|
|
60731
61004
|
const line2 = (w2, h2) => /* @__PURE__ */ jsx$1(Box, { css: sk({ variant: "line" }), width: w2, height: h2 });
|
|
60732
61005
|
const block = (h2) => /* @__PURE__ */ jsx$1(Box, { css: sk({ variant: "block" }), width: "100%", minHeight: h2 });
|
|
60733
|
-
return /* @__PURE__ */ jsxs(Box, { layerStyle: "
|
|
61006
|
+
return /* @__PURE__ */ jsxs(Box, { layerStyle: "surface.frameless", overflow: "visible", children: [
|
|
60734
61007
|
/* @__PURE__ */ jsxs(Box, { layerStyle: "header.bar", display: "flex", alignItems: "center", gap: "3.5", children: [
|
|
60735
61008
|
line2("260px", "20px"),
|
|
60736
61009
|
/* @__PURE__ */ jsx$1(Box, { flex: "1" }),
|
|
@@ -60932,14 +61205,14 @@ const EastChakraExperiment = memo(function EastChakraExperiment2({ value }) {
|
|
|
60932
61205
|
const which = data4.error ? "dataset" : configsBind.error ? "configs" : journalBind.error ? "journal" : null;
|
|
60933
61206
|
const bindError = data4.error ?? configsBind.error ?? journalBind.error;
|
|
60934
61207
|
const bindMsg = bindError instanceof Error ? bindError.message : bindError != null ? String(bindError) : null;
|
|
60935
|
-
if (bindMsg) return /* @__PURE__ */ jsx$1(Box, { layerStyle: "
|
|
61208
|
+
if (bindMsg) return /* @__PURE__ */ jsx$1(Box, { layerStyle: "surface.frameless", p: "6", children: /* @__PURE__ */ jsxs(Text, { textStyle: "body.sm", color: "fg.danger", children: [
|
|
60936
61209
|
"Couldn’t load the experiment ",
|
|
60937
61210
|
which,
|
|
60938
61211
|
": ",
|
|
60939
61212
|
bindMsg
|
|
60940
61213
|
] }) });
|
|
60941
|
-
if (noConfigs) return /* @__PURE__ */ jsx$1(Box, { layerStyle: "
|
|
60942
|
-
if (failed2 && experiment.error) return /* @__PURE__ */ jsx$1(Box, { layerStyle: "
|
|
61214
|
+
if (noConfigs) return /* @__PURE__ */ jsx$1(Box, { layerStyle: "surface.frameless", p: "6", children: /* @__PURE__ */ jsx$1(Text, { textStyle: "body.sm", color: "fg.muted", children: "No questions to show — bind a non-empty configs list." }) });
|
|
61215
|
+
if (failed2 && experiment.error) return /* @__PURE__ */ jsx$1(Box, { layerStyle: "surface.frameless", p: "6", children: /* @__PURE__ */ jsx$1(RunError, { error: experiment.error }) });
|
|
60943
61216
|
return /* @__PURE__ */ jsx$1(LoadingSkeleton, {});
|
|
60944
61217
|
}
|
|
60945
61218
|
const { spec: vs, answer: a2, refusal: ref, overlap: ov, refute: vr, dose: vd, journal, verdict } = view;
|
|
@@ -60960,7 +61233,7 @@ const EastChakraExperiment = memo(function EastChakraExperiment2({ value }) {
|
|
|
60960
61233
|
const anyPrecomputedDesign = configs.some((c2) => c2.design.type === "some");
|
|
60961
61234
|
const showValidate = hasDesign || anyPrecomputedDesign;
|
|
60962
61235
|
const tabKeys = [...["answer", "trust", "dose"], ...showValidate ? ["validate"] : []];
|
|
60963
|
-
return /* @__PURE__ */ jsx$1(GuidanceProvider, { on: guidance, vars: helpVars, children: /* @__PURE__ */ jsxs(Box, { layerStyle: "
|
|
61236
|
+
return /* @__PURE__ */ jsx$1(GuidanceProvider, { on: guidance, vars: helpVars, children: /* @__PURE__ */ jsxs(Box, { layerStyle: "surface.frameless", overflow: "visible", children: [
|
|
60964
61237
|
/* @__PURE__ */ jsxs(Box, { layerStyle: "header.bar", display: "flex", alignItems: "center", gap: "3.5", children: [
|
|
60965
61238
|
configs.length > 1 ? /* @__PURE__ */ jsxs(Menu.Root, { children: [
|
|
60966
61239
|
/* @__PURE__ */ jsx$1(Menu.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs(Box, { as: "button", bg: "transparent", border: "0", p: "0", cursor: "pointer", display: "inline-flex", alignItems: "center", gap: "2", textAlign: "start", children: [
|
|
@@ -61612,23 +61885,23 @@ function hashString2(s2) {
|
|
|
61612
61885
|
for (let i = 0; i < s2.length; i++) h2 = (h2 << 5) + h2 + s2.charCodeAt(i) | 0;
|
|
61613
61886
|
return (h2 >>> 0).toString(36);
|
|
61614
61887
|
}
|
|
61615
|
-
function
|
|
61616
|
-
|
|
61617
|
-
const
|
|
61618
|
-
|
|
61619
|
-
|
|
61620
|
-
|
|
61621
|
-
|
|
61622
|
-
|
|
61623
|
-
|
|
61624
|
-
|
|
61625
|
-
|
|
61626
|
-
|
|
61627
|
-
|
|
61628
|
-
|
|
61629
|
-
|
|
61630
|
-
|
|
61631
|
-
|
|
61888
|
+
function readSelectionAt(selectionKey) {
|
|
61889
|
+
StateRuntime.trackKey(selectionKey);
|
|
61890
|
+
const bytes = StateRuntime.getStore().read(selectionKey);
|
|
61891
|
+
return bytes === void 0 ? none$1 : decodeSelection(bytes);
|
|
61892
|
+
}
|
|
61893
|
+
function writeSelectionAt(selectionKey, value) {
|
|
61894
|
+
StateRuntime.getStore().write(selectionKey, encodeSelection(value));
|
|
61895
|
+
return null;
|
|
61896
|
+
}
|
|
61897
|
+
function hostQueue(decisions) {
|
|
61898
|
+
return decisions.flatMap((b2) => viewFor(b2).read());
|
|
61899
|
+
}
|
|
61900
|
+
function readJudgementsAt(judgements) {
|
|
61901
|
+
return viewFor(judgements).read();
|
|
61902
|
+
}
|
|
61903
|
+
function judgementForAt(judgements, caseId) {
|
|
61904
|
+
return readJudgementsAt(judgements).get(caseId) ?? {
|
|
61632
61905
|
caseId,
|
|
61633
61906
|
answers: /* @__PURE__ */ new Map(),
|
|
61634
61907
|
knowledge: none$1,
|
|
@@ -61636,101 +61909,190 @@ function buildDecisionHandle(decisions, judgements, sliceInit) {
|
|
|
61636
61909
|
verdict: none$1,
|
|
61637
61910
|
resolvedAt: none$1
|
|
61638
61911
|
};
|
|
61639
|
-
|
|
61640
|
-
|
|
61641
|
-
|
|
61642
|
-
|
|
61643
|
-
|
|
61644
|
-
|
|
61645
|
-
|
|
61646
|
-
|
|
61647
|
-
|
|
61648
|
-
|
|
61649
|
-
|
|
61650
|
-
|
|
61651
|
-
|
|
61912
|
+
}
|
|
61913
|
+
function stageJudgementAt(judgements, caseId, change) {
|
|
61914
|
+
const dict = new Map(readJudgementsAt(judgements));
|
|
61915
|
+
dict.set(caseId, { ...judgementForAt(judgements, caseId), ...change });
|
|
61916
|
+
viewFor(judgements).write(dict);
|
|
61917
|
+
return null;
|
|
61918
|
+
}
|
|
61919
|
+
function removeFromOwningView(decisions, caseId) {
|
|
61920
|
+
for (const binding of decisions) {
|
|
61921
|
+
const view = viewFor(binding);
|
|
61922
|
+
const rows = view.read();
|
|
61923
|
+
if (rows.some((d2) => d2.id === caseId)) {
|
|
61924
|
+
view.write(rows.filter((d2) => d2.id !== caseId));
|
|
61652
61925
|
}
|
|
61653
|
-
}
|
|
61926
|
+
}
|
|
61927
|
+
}
|
|
61928
|
+
const decisionHandleCache = /* @__PURE__ */ new Map();
|
|
61929
|
+
function typeToken(tv) {
|
|
61930
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
61931
|
+
return JSON.stringify(tv, (_k, v3) => {
|
|
61932
|
+
if (typeof v3 === "object" && v3 !== null) {
|
|
61933
|
+
if (seen.has(v3)) return "<cyc>";
|
|
61934
|
+
seen.add(v3);
|
|
61935
|
+
}
|
|
61936
|
+
return typeof v3 === "bigint" ? `${v3}n` : v3;
|
|
61937
|
+
});
|
|
61938
|
+
}
|
|
61939
|
+
function compileDecisionMethods(constraintType, decisions, judgements, selectionKey) {
|
|
61940
|
+
const platform = getRegisteredPlatformImplementations();
|
|
61941
|
+
const c2 = fromEastTypeValue(constraintType);
|
|
61942
|
+
const decisionsExpr = East.value(decisions, ArrayType(DiffBindingType));
|
|
61943
|
+
const judgementsExpr = East.value(judgements, DiffBindingType);
|
|
61944
|
+
const selKeyExpr = East.value(selectionKey, StringType);
|
|
61945
|
+
const {
|
|
61946
|
+
queue,
|
|
61947
|
+
selected: selected2,
|
|
61948
|
+
select: select2,
|
|
61949
|
+
clearSelection,
|
|
61950
|
+
decision,
|
|
61951
|
+
update: update2,
|
|
61952
|
+
judgement,
|
|
61953
|
+
answer,
|
|
61954
|
+
addKnowledge,
|
|
61955
|
+
inject,
|
|
61956
|
+
resolve: resolve2,
|
|
61957
|
+
commitState
|
|
61958
|
+
} = DecisionBindPrimitives;
|
|
61959
|
+
return {
|
|
61960
|
+
queue: East.compile(East.function([], ArrayType(DecisionType), ($3) => {
|
|
61961
|
+
$3.return(queue(decisionsExpr));
|
|
61962
|
+
}), platform),
|
|
61963
|
+
selected: East.compile(East.function([], OptionType(StringType), ($3) => {
|
|
61964
|
+
$3.return(selected2(selKeyExpr));
|
|
61965
|
+
}), platform),
|
|
61966
|
+
select: East.compile(East.function([StringType], NullType, ($3, id3) => {
|
|
61967
|
+
$3.return(select2(selKeyExpr, id3));
|
|
61968
|
+
}), platform),
|
|
61969
|
+
clearSelection: East.compile(East.function([], NullType, ($3) => {
|
|
61970
|
+
$3.return(clearSelection(selKeyExpr));
|
|
61971
|
+
}), platform),
|
|
61972
|
+
decision: East.compile(East.function([], OptionType(DecisionType), ($3) => {
|
|
61973
|
+
$3.return(decision(decisionsExpr, selKeyExpr));
|
|
61974
|
+
}), platform),
|
|
61975
|
+
update: East.compile(East.function([DecisionType], NullType, ($3, edited) => {
|
|
61976
|
+
$3.return(update2(decisionsExpr, edited));
|
|
61977
|
+
}), platform),
|
|
61978
|
+
judgement: East.compile(East.function([StringType], judgementInputType(c2), ($3, id3) => {
|
|
61979
|
+
$3.return(judgement([c2], judgementsExpr, id3));
|
|
61980
|
+
}), platform),
|
|
61981
|
+
answer: East.compile(East.function([StringType, StringType, AnswerType], NullType, ($3, id3, prompt, ans) => {
|
|
61982
|
+
$3.return(answer(judgementsExpr, id3, prompt, ans));
|
|
61983
|
+
}), platform),
|
|
61984
|
+
addKnowledge: East.compile(East.function([StringType, StringType], NullType, ($3, id3, text) => {
|
|
61985
|
+
$3.return(addKnowledge(judgementsExpr, id3, text));
|
|
61986
|
+
}), platform),
|
|
61987
|
+
inject: East.compile(East.function([StringType, c2], NullType, ($3, id3, con) => {
|
|
61988
|
+
$3.return(inject([c2], judgementsExpr, id3, con));
|
|
61989
|
+
}), platform),
|
|
61990
|
+
resolve: East.compile(East.function([StringType, VerdictType], NullType, ($3, id3, verdict) => {
|
|
61991
|
+
$3.return(resolve2(decisionsExpr, judgementsExpr, selKeyExpr, id3, verdict));
|
|
61992
|
+
}), platform),
|
|
61993
|
+
commitState: East.compile(East.function([StringType], CommitStateType, ($3, id3) => {
|
|
61994
|
+
$3.return(commitState(decisionsExpr, judgementsExpr, id3));
|
|
61995
|
+
}), platform)
|
|
61996
|
+
};
|
|
61997
|
+
}
|
|
61998
|
+
function buildDecisionHandle(decisions, judgements, sliceInit, constraintType) {
|
|
61999
|
+
const cType = constraintType ?? toEastTypeValue(DecisionConstraintType);
|
|
62000
|
+
const selectionKey = deriveSelectionKey(decisions);
|
|
61654
62001
|
const slice3 = buildSliceHandle(
|
|
61655
62002
|
deriveSliceKey(decisions, sliceInit),
|
|
61656
62003
|
DECISION_SLICE_CONFIG,
|
|
61657
62004
|
sliceInit ?? DEFAULT_SLICE_STATE,
|
|
61658
|
-
() =>
|
|
62005
|
+
() => hostQueue(decisions),
|
|
61659
62006
|
none$1
|
|
61660
62007
|
);
|
|
62008
|
+
const journal = () => {
|
|
62009
|
+
const entries = [...readJudgementsAt(judgements).values()].filter((j2) => j2.verdict.type === "some");
|
|
62010
|
+
const at = (j2) => j2.resolvedAt.type === "some" ? j2.resolvedAt.value.getTime() : 0;
|
|
62011
|
+
return entries.sort((a2, b2) => at(b2) - at(a2));
|
|
62012
|
+
};
|
|
62013
|
+
const cacheKey = `${hashString2(stableStringify({ decisions, judgements }))}|${typeToken(cType)}`;
|
|
62014
|
+
let methods = decisionHandleCache.get(cacheKey);
|
|
62015
|
+
if (methods === void 0) {
|
|
62016
|
+
methods = compileDecisionMethods(cType, decisions, judgements, selectionKey);
|
|
62017
|
+
decisionHandleCache.set(cacheKey, methods);
|
|
62018
|
+
}
|
|
61661
62019
|
return {
|
|
61662
62020
|
decisions,
|
|
61663
62021
|
judgements,
|
|
61664
62022
|
sliceInit: sliceInit !== void 0 ? some(sliceInit) : none$1,
|
|
61665
62023
|
slice: slice3,
|
|
61666
|
-
|
|
61667
|
-
|
|
61668
|
-
select: (caseId) => writeSelection(some(caseId)),
|
|
61669
|
-
clearSelection: () => writeSelection(none$1),
|
|
61670
|
-
decision: () => {
|
|
61671
|
-
const selection2 = readSelection();
|
|
61672
|
-
if (selection2.type === "none") return none$1;
|
|
61673
|
-
const found = queue().find((d2) => d2.id === selection2.value);
|
|
61674
|
-
return found === void 0 ? none$1 : some(found);
|
|
61675
|
-
},
|
|
61676
|
-
update: (edited) => {
|
|
61677
|
-
for (const binding of decisions) {
|
|
61678
|
-
const view = viewFor(binding);
|
|
61679
|
-
const rows = view.read();
|
|
61680
|
-
if (rows.some((d2) => d2.id === edited.id)) {
|
|
61681
|
-
view.write(rows.map((d2) => d2.id === edited.id ? edited : d2));
|
|
61682
|
-
}
|
|
61683
|
-
}
|
|
61684
|
-
return null;
|
|
61685
|
-
},
|
|
61686
|
-
judgement: judgementFor,
|
|
61687
|
-
answer: (caseId, prompt, response) => {
|
|
61688
|
-
const answers = new Map(judgementFor(caseId).answers);
|
|
61689
|
-
answers.set(prompt, response);
|
|
61690
|
-
return stageJudgement(caseId, { answers });
|
|
61691
|
-
},
|
|
61692
|
-
addKnowledge: (caseId, text) => stageJudgement(caseId, { knowledge: some(text) }),
|
|
61693
|
-
inject: (caseId, constraint) => {
|
|
61694
|
-
const constraints = judgementFor(caseId).constraints.filter((c2) => c2.type !== constraint.type).concat([constraint]);
|
|
61695
|
-
return stageJudgement(caseId, { constraints });
|
|
61696
|
-
},
|
|
61697
|
-
resolve: (caseId, verdict) => {
|
|
61698
|
-
stageJudgement(caseId, { verdict: some(verdict), resolvedAt: some(/* @__PURE__ */ new Date()) });
|
|
61699
|
-
removeFromOwningView(caseId);
|
|
61700
|
-
writeSelection(none$1);
|
|
61701
|
-
return null;
|
|
61702
|
-
},
|
|
61703
|
-
journal: () => {
|
|
61704
|
-
const entries = [...readJudgements().values()].filter((j2) => j2.verdict.type === "some");
|
|
61705
|
-
const at = (j2) => j2.resolvedAt.type === "some" ? j2.resolvedAt.value.getTime() : 0;
|
|
61706
|
-
return entries.sort((a2, b2) => at(b2) - at(a2));
|
|
61707
|
-
},
|
|
61708
|
-
commitState: (caseId) => {
|
|
61709
|
-
const decision = queue().find((d2) => d2.id === caseId);
|
|
61710
|
-
const prompts = (decision == null ? void 0 : decision.prompts) ?? [];
|
|
61711
|
-
const answers = judgementFor(caseId).answers;
|
|
61712
|
-
const responses = prompts.map((p2) => {
|
|
61713
|
-
var _a2;
|
|
61714
|
-
return (_a2 = answers.get(p2.id)) == null ? void 0 : _a2.type;
|
|
61715
|
-
});
|
|
61716
|
-
if (responses.some((r2) => r2 === "no")) return variant("blocked", null);
|
|
61717
|
-
if (responses.some((r2) => r2 === "unknown")) return variant("handoff", null);
|
|
61718
|
-
const unanswered = responses.filter((r2) => r2 === void 0).length;
|
|
61719
|
-
if (unanswered > 0) return variant("gated", BigInt(unanswered));
|
|
61720
|
-
return variant("ready", null);
|
|
61721
|
-
}
|
|
62024
|
+
journal,
|
|
62025
|
+
...methods
|
|
61722
62026
|
};
|
|
61723
62027
|
}
|
|
61724
62028
|
const DecisionBindPlatform = [
|
|
61725
|
-
// Generic over the constraint contract — the
|
|
61726
|
-
//
|
|
61727
|
-
decisionBindPlatformFn.implement((
|
|
62029
|
+
// Generic over the constraint contract — the resolver receives the contract
|
|
62030
|
+
// type value and threads it into the IR-bearing judgement / inject methods.
|
|
62031
|
+
decisionBindPlatformFn.implement((constraintType) => (decisionsArg, judgementsArg, sliceInitArg) => buildDecisionHandle(
|
|
61728
62032
|
decisionsArg,
|
|
61729
62033
|
judgementsArg,
|
|
61730
|
-
getSomeorUndefined(sliceInitArg)
|
|
61731
|
-
|
|
62034
|
+
getSomeorUndefined$1(sliceInitArg),
|
|
62035
|
+
constraintType
|
|
62036
|
+
)),
|
|
62037
|
+
// ── issue #106 primitives — host I/O backing the IR-bearing handle methods.
|
|
62038
|
+
// Each is a faithful lift of the original closure body, taking the plain-data
|
|
62039
|
+
// descriptor(s) + the selection key as arguments. ──
|
|
62040
|
+
DecisionBindPrimitives.queue.implement((decisions) => hostQueue(decisions)),
|
|
62041
|
+
DecisionBindPrimitives.selected.implement((selectionKey) => readSelectionAt(selectionKey)),
|
|
62042
|
+
DecisionBindPrimitives.select.implement((selectionKey, caseId) => writeSelectionAt(selectionKey, some(caseId))),
|
|
62043
|
+
DecisionBindPrimitives.clearSelection.implement((selectionKey) => writeSelectionAt(selectionKey, none$1)),
|
|
62044
|
+
DecisionBindPrimitives.decision.implement((decisions, selectionKey) => {
|
|
62045
|
+
const sel = readSelectionAt(selectionKey);
|
|
62046
|
+
if (sel.type === "none") return none$1;
|
|
62047
|
+
const found = hostQueue(decisions).find((d2) => d2.id === sel.value);
|
|
62048
|
+
return found === void 0 ? none$1 : some(found);
|
|
62049
|
+
}),
|
|
62050
|
+
DecisionBindPrimitives.update.implement((decisions, edited) => {
|
|
62051
|
+
const e3 = edited;
|
|
62052
|
+
for (const binding of decisions) {
|
|
62053
|
+
const view = viewFor(binding);
|
|
62054
|
+
const rows = view.read();
|
|
62055
|
+
if (rows.some((d2) => d2.id === e3.id)) {
|
|
62056
|
+
view.write(rows.map((d2) => d2.id === e3.id ? e3 : d2));
|
|
62057
|
+
}
|
|
62058
|
+
}
|
|
62059
|
+
return null;
|
|
62060
|
+
}),
|
|
62061
|
+
DecisionBindPrimitives.judgement.implement((_c2) => (judgements, caseId) => judgementForAt(judgements, caseId)),
|
|
62062
|
+
DecisionBindPrimitives.answer.implement((judgements, caseId, prompt, response) => {
|
|
62063
|
+
const answers = new Map(judgementForAt(judgements, caseId).answers);
|
|
62064
|
+
answers.set(prompt, response);
|
|
62065
|
+
return stageJudgementAt(judgements, caseId, { answers });
|
|
62066
|
+
}),
|
|
62067
|
+
DecisionBindPrimitives.addKnowledge.implement((judgements, caseId, text) => stageJudgementAt(judgements, caseId, { knowledge: some(text) })),
|
|
62068
|
+
DecisionBindPrimitives.inject.implement((_c2) => (judgements, caseId, constraint) => {
|
|
62069
|
+
const con = constraint;
|
|
62070
|
+
const constraints = judgementForAt(judgements, caseId).constraints.filter((x2) => x2.type !== con.type).concat([con]);
|
|
62071
|
+
return stageJudgementAt(judgements, caseId, { constraints });
|
|
62072
|
+
}),
|
|
62073
|
+
DecisionBindPrimitives.resolve.implement((decisions, judgements, selectionKey, caseId, verdict) => {
|
|
62074
|
+
stageJudgementAt(judgements, caseId, { verdict: some(verdict), resolvedAt: some(/* @__PURE__ */ new Date()) });
|
|
62075
|
+
removeFromOwningView(decisions, caseId);
|
|
62076
|
+
writeSelectionAt(selectionKey, none$1);
|
|
62077
|
+
return null;
|
|
62078
|
+
}),
|
|
62079
|
+
DecisionBindPrimitives.commitState.implement((decisions, judgements, caseId) => {
|
|
62080
|
+
const cid = caseId;
|
|
62081
|
+
const decision = hostQueue(decisions).find((d2) => d2.id === cid);
|
|
62082
|
+
const prompts = (decision == null ? void 0 : decision.prompts) ?? [];
|
|
62083
|
+
const answers = judgementForAt(judgements, cid).answers;
|
|
62084
|
+
const responses = prompts.map((p2) => {
|
|
62085
|
+
var _a2;
|
|
62086
|
+
return (_a2 = answers.get(p2.id)) == null ? void 0 : _a2.type;
|
|
62087
|
+
});
|
|
62088
|
+
if (responses.some((r2) => r2 === "no")) return variant("blocked", null);
|
|
62089
|
+
if (responses.some((r2) => r2 === "unknown")) return variant("handoff", null);
|
|
62090
|
+
const unanswered = responses.filter((r2) => r2 === void 0).length;
|
|
62091
|
+
if (unanswered > 0) return variant("gated", BigInt(unanswered));
|
|
62092
|
+
return variant("ready", null);
|
|
62093
|
+
})
|
|
61732
62094
|
];
|
|
61733
|
-
registerPlatformImplementation
|
|
62095
|
+
registerPlatformImplementation(DecisionBindPlatform);
|
|
61734
62096
|
function useHandleVersion(handle) {
|
|
61735
62097
|
const staged = getStagedStore();
|
|
61736
62098
|
const cache3 = getReactiveDatasetCache();
|
|
@@ -61766,7 +62128,7 @@ function useDecisionHandle(ref) {
|
|
|
61766
62128
|
() => ref ? buildDecisionHandle(
|
|
61767
62129
|
[...ref.decisions],
|
|
61768
62130
|
ref.judgements,
|
|
61769
|
-
getSomeorUndefined(ref.slice)
|
|
62131
|
+
getSomeorUndefined$1(ref.slice)
|
|
61770
62132
|
) : null,
|
|
61771
62133
|
[ref]
|
|
61772
62134
|
);
|
|
@@ -62116,6 +62478,9 @@ const OptionsFacet = memo(function OptionsFacet2({ decision, narrow }) {
|
|
|
62116
62478
|
const options2 = rankOptions(decision);
|
|
62117
62479
|
const maxUp = Math.max(...options2.map((o2) => Math.max(o2.value, 0)), 1e-9);
|
|
62118
62480
|
const maxDown = Math.max(...options2.map((o2) => Math.abs(o2.downside ?? 0)), 1e-9);
|
|
62481
|
+
const valueAxis = getSomeorUndefined(decision.valueAxis);
|
|
62482
|
+
const upLabel = (valueAxis == null ? void 0 : valueAxis.label) ?? "Uplift";
|
|
62483
|
+
const signed2 = (valueAxis == null ? void 0 : valueAxis.signed) ?? true;
|
|
62119
62484
|
if (narrow) {
|
|
62120
62485
|
const meter = (label, frac, display, tone) => /* @__PURE__ */ jsxs(Box, { display: "grid", gridTemplateColumns: "80px 1fr 64px", alignItems: "center", gap: "8px", children: [
|
|
62121
62486
|
/* @__PURE__ */ jsx$1(Text, { ...caption, whiteSpace: "nowrap", children: label }),
|
|
@@ -62134,7 +62499,7 @@ const OptionsFacet = memo(function OptionsFacet2({ decision, narrow }) {
|
|
|
62134
62499
|
" ",
|
|
62135
62500
|
/* @__PURE__ */ jsx$1(Text, { as: "span", fontWeight: o2.recommended ? "semibold" : "normal", children: o2.label })
|
|
62136
62501
|
] }),
|
|
62137
|
-
meter(
|
|
62502
|
+
meter(upLabel, o2.value / maxUp, fmt(decision, o2.value, signed2), signed2 ? "success" : "neutral"),
|
|
62138
62503
|
meter("If wrong", (o2.downside ?? 0) / maxDown, o2.downside !== void 0 ? fmt(decision, o2.downside, true) : "—", "danger")
|
|
62139
62504
|
] }, o2.rank))
|
|
62140
62505
|
] });
|
|
@@ -62147,7 +62512,7 @@ const OptionsFacet = memo(function OptionsFacet2({ decision, narrow }) {
|
|
|
62147
62512
|
" evaluated"
|
|
62148
62513
|
] }),
|
|
62149
62514
|
/* @__PURE__ */ jsx$1(Text, { ...caption, textAlign: "center", children: "If wrong" }),
|
|
62150
|
-
/* @__PURE__ */ jsx$1(Text, { ...caption, textAlign: "right", children:
|
|
62515
|
+
/* @__PURE__ */ jsx$1(Text, { ...caption, textAlign: "right", children: upLabel })
|
|
62151
62516
|
] }),
|
|
62152
62517
|
options2.map((o2) => {
|
|
62153
62518
|
const downFrac = Math.min(Math.abs(o2.downside ?? 0) / maxDown, 1);
|
|
@@ -62172,8 +62537,8 @@ const OptionsFacet = memo(function OptionsFacet2({ decision, narrow }) {
|
|
|
62172
62537
|
/* @__PURE__ */ jsx$1(Box, { height: "12px", width: `${Math.round(downFrac * 100)}%`, bg: "fg.danger", opacity: 0.55 })
|
|
62173
62538
|
] }) }),
|
|
62174
62539
|
/* @__PURE__ */ jsx$1(Box, { display: "flex", alignItems: "center", gap: "6px", height: "16px", borderLeftWidth: "1px", borderColor: "border.strong", children: o2.value > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
62175
|
-
/* @__PURE__ */ jsx$1(Box, { height: "12px", width: `${Math.round(upFrac * 100)}%`, bg: "fg.success", opacity: 0.6 }),
|
|
62176
|
-
/* @__PURE__ */ jsx$1(Text, { fontSize: "10.5px", fontFamily: "mono", color: "fg.success", flexShrink: 0, children: fmt(decision, o2.value,
|
|
62540
|
+
/* @__PURE__ */ jsx$1(Box, { height: "12px", width: `${Math.round(upFrac * 100)}%`, bg: signed2 ? "fg.success" : "fg.subtle", opacity: 0.6 }),
|
|
62541
|
+
/* @__PURE__ */ jsx$1(Text, { fontSize: "10.5px", fontFamily: "mono", color: signed2 ? "fg.success" : "fg.muted", flexShrink: 0, children: fmt(decision, o2.value, signed2) })
|
|
62177
62542
|
] }) })
|
|
62178
62543
|
]
|
|
62179
62544
|
},
|
|
@@ -62358,7 +62723,8 @@ function useLeverPayloads(ref) {
|
|
|
62358
62723
|
return (constraint == null ? void 0 : constraint.type) === "Variant" ? constraint.cases ?? {} : {};
|
|
62359
62724
|
}, [ref, workspace]);
|
|
62360
62725
|
}
|
|
62361
|
-
const Row = memo(function Row2({ decision, handle, selected: selected2, narrow, leverPayloads, modify,
|
|
62726
|
+
const Row = memo(function Row2({ decision, handle, selected: selected2, narrow, leverPayloads, modify, evidence, defaultFacet, facetInclude, apply: apply2, reject: reject2, leaving, storageKey }) {
|
|
62727
|
+
var _a2, _b2;
|
|
62362
62728
|
const dq = useSlotRecipe({ key: "decisionQueue" });
|
|
62363
62729
|
const status = useSlotRecipe({ key: "status" });
|
|
62364
62730
|
const tabs = useSlotRecipe({ key: "facetTabs" });
|
|
@@ -62366,10 +62732,15 @@ const Row = memo(function Row2({ decision, handle, selected: selected2, narrow,
|
|
|
62366
62732
|
const rs = dq({});
|
|
62367
62733
|
const ts = tabs({});
|
|
62368
62734
|
const st = status({ status: URGENCY_TONE[decision.urgency.type], size: "md" });
|
|
62369
|
-
const
|
|
62735
|
+
const visibleFacets = useMemo(
|
|
62736
|
+
() => FACETS.filter((f2) => f2.key === "modify" ? modify !== void 0 : facetInclude === null || facetInclude.has(f2.key)),
|
|
62737
|
+
[modify, facetInclude]
|
|
62738
|
+
);
|
|
62739
|
+
const effectiveDefault = visibleFacets.some((f2) => f2.key === defaultFacet) ? defaultFacet : ((_a2 = visibleFacets[0]) == null ? void 0 : _a2.key) ?? defaultFacet;
|
|
62740
|
+
const [facet, setFacet] = useState(effectiveDefault);
|
|
62370
62741
|
useEffect(() => {
|
|
62371
|
-
if (!selected2) setFacet(
|
|
62372
|
-
}, [selected2,
|
|
62742
|
+
if (!selected2) setFacet(effectiveDefault);
|
|
62743
|
+
}, [selected2, effectiveDefault]);
|
|
62373
62744
|
const gate = handle.commitStateFor(decision.id);
|
|
62374
62745
|
const applyEnabled = gate === null || gate.type === "ready";
|
|
62375
62746
|
const gatePulse = !applyEnabled && decision.prompts.length > 0;
|
|
@@ -62388,10 +62759,10 @@ const Row = memo(function Row2({ decision, handle, selected: selected2, narrow,
|
|
|
62388
62759
|
return modify(decision, handle.update);
|
|
62389
62760
|
}, [selected2, facet, modify, decision, handle.update]);
|
|
62390
62761
|
const canvas = useMemo(() => {
|
|
62391
|
-
if (!selected2 || facet !== "evidence" || !
|
|
62392
|
-
return
|
|
62393
|
-
}, [selected2, facet,
|
|
62394
|
-
const facetTabs = /* @__PURE__ */ jsx$1(Box, { css: ts.root, ...narrow ? { display: "flex", width: "100%" } : {}, children:
|
|
62762
|
+
if (!selected2 || facet !== "evidence" || !evidence) return null;
|
|
62763
|
+
return evidence(decision);
|
|
62764
|
+
}, [selected2, facet, evidence, decision]);
|
|
62765
|
+
const facetTabs = /* @__PURE__ */ jsx$1(Box, { css: ts.root, ...narrow ? { display: "flex", width: "100%" } : {}, children: visibleFacets.map((f2) => /* @__PURE__ */ jsx$1(
|
|
62395
62766
|
Box,
|
|
62396
62767
|
{
|
|
62397
62768
|
as: "button",
|
|
@@ -62437,7 +62808,8 @@ const Row = memo(function Row2({ decision, handle, selected: selected2, narrow,
|
|
|
62437
62808
|
deadlineSuffix(decision)
|
|
62438
62809
|
] })
|
|
62439
62810
|
] });
|
|
62440
|
-
const
|
|
62811
|
+
const valueSigned = ((_b2 = getSomeorUndefined(decision.valueAxis)) == null ? void 0 : _b2.signed) ?? true;
|
|
62812
|
+
const valueText = /* @__PURE__ */ jsx$1(Text, { fontFamily: "mono", fontWeight: "semibold", textAlign: "right", ...valueSigned && decision.value >= 0 && selected2 ? { color: "fg.success" } : {}, children: decisionValue(decision, decision.value, valueSigned && selected2) });
|
|
62441
62813
|
return /* @__PURE__ */ jsxs(Box, { css: rs.rowShell, ...leaving ? { "data-leaving": leaving } : {}, children: [
|
|
62442
62814
|
narrow ? /* @__PURE__ */ jsxs(Box, { px: "14px", py: "10px", children: [
|
|
62443
62815
|
/* @__PURE__ */ jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "baseline", children: [
|
|
@@ -62459,7 +62831,7 @@ const Row = memo(function Row2({ decision, handle, selected: selected2, narrow,
|
|
|
62459
62831
|
] })
|
|
62460
62832
|
] }),
|
|
62461
62833
|
selected2 && /* @__PURE__ */ jsxs(Box, { px: narrow ? "14px" : "18px", py: "12px", borderTopWidth: "1px", borderColor: "border.subtle", bg: "bg.canvas", children: [
|
|
62462
|
-
facet === "evidence" && /* @__PURE__ */ jsx$1(EvidenceFacet, { decision, children: canvas != null && /* @__PURE__ */ jsx$1(EastChakraComponent, { value: canvas, storageKey: `${storageKey}-
|
|
62834
|
+
facet === "evidence" && /* @__PURE__ */ jsx$1(EvidenceFacet, { decision, children: canvas != null && /* @__PURE__ */ jsx$1(EastChakraComponent, { value: canvas, storageKey: `${storageKey}-evidence-${decision.id}` }) }),
|
|
62463
62835
|
facet === "options" && /* @__PURE__ */ jsx$1(OptionsFacet, { decision, narrow }),
|
|
62464
62836
|
facet === "judgement" && /* @__PURE__ */ jsx$1(JudgementFacet, { decision, handle, leverPayloads }),
|
|
62465
62837
|
facet === "modify" && probe != null && /* @__PURE__ */ jsx$1(EastChakraComponent, { value: probe, storageKey: `${storageKey}-modify-${decision.id}` })
|
|
@@ -62567,11 +62939,15 @@ const EastChakraDecisionQueue = memo(function EastChakraDecisionQueue2({ value,
|
|
|
62567
62939
|
() => getSomeorUndefined(value.modify),
|
|
62568
62940
|
[value.modify]
|
|
62569
62941
|
);
|
|
62570
|
-
const
|
|
62571
|
-
() => getSomeorUndefined(value.
|
|
62572
|
-
[value.
|
|
62942
|
+
const evidence = useMemo(
|
|
62943
|
+
() => getSomeorUndefined(value.evidence),
|
|
62944
|
+
[value.evidence]
|
|
62573
62945
|
);
|
|
62574
62946
|
const defaultFacet = ((_a2 = getSomeorUndefined(value.defaultFacet)) == null ? void 0 : _a2.type) ?? "evidence";
|
|
62947
|
+
const facetInclude = useMemo(() => {
|
|
62948
|
+
const facets = getSomeorUndefined(value.facets);
|
|
62949
|
+
return facets === void 0 ? null : new Set(facets.map((f2) => f2.type));
|
|
62950
|
+
}, [value.facets]);
|
|
62575
62951
|
const defaultExpanded = getSomeorUndefined(value.defaultExpanded);
|
|
62576
62952
|
const selectedId = handle.selected ?? (defaultExpanded == null ? void 0 : defaultExpanded.id) ?? null;
|
|
62577
62953
|
const resolve2 = useCallback((ds, hook2, reason) => {
|
|
@@ -62617,9 +62993,9 @@ const EastChakraDecisionQueue = memo(function EastChakraDecisionQueue2({ value,
|
|
|
62617
62993
|
return m2;
|
|
62618
62994
|
}, [exiting]);
|
|
62619
62995
|
if (decisions === null) {
|
|
62620
|
-
return /* @__PURE__ */ jsx$1(Box, { layerStyle: "
|
|
62996
|
+
return /* @__PURE__ */ jsx$1(Box, { layerStyle: "surface.frameless", p: "16px", children: /* @__PURE__ */ jsx$1(Text, { color: "fg.muted", fontSize: "13px", children: "Loading decisions…" }) });
|
|
62621
62997
|
}
|
|
62622
|
-
return /* @__PURE__ */ jsxs(Box, { ref: rootRef, layerStyle: "
|
|
62998
|
+
return /* @__PURE__ */ jsxs(Box, { ref: rootRef, layerStyle: "surface.frameless", overflow: "hidden", children: [
|
|
62623
62999
|
/* @__PURE__ */ jsxs(Box, { css: es.root, children: [
|
|
62624
63000
|
/* @__PURE__ */ jsx$1(Box, { css: es.lbl, children: heading }),
|
|
62625
63001
|
sliceHandle !== null && railAffordances !== void 0 && /* @__PURE__ */ jsx$1(Box, { display: "flex", alignItems: "center", minWidth: "0", flex: "1", justifyContent: "flex-end", marginRight: "10px", children: /* @__PURE__ */ jsx$1(
|
|
@@ -62658,8 +63034,9 @@ const EastChakraDecisionQueue = memo(function EastChakraDecisionQueue2({ value,
|
|
|
62658
63034
|
narrow,
|
|
62659
63035
|
leverPayloads,
|
|
62660
63036
|
modify,
|
|
62661
|
-
|
|
63037
|
+
evidence,
|
|
62662
63038
|
defaultFacet,
|
|
63039
|
+
facetInclude,
|
|
62663
63040
|
apply: apply2,
|
|
62664
63041
|
reject: reject2,
|
|
62665
63042
|
leaving: exitingReasons.get(d2.id),
|
|
@@ -63091,12 +63468,7 @@ function useDatasetValue(apiUrl, repo, workspace, datasetPath, options2) {
|
|
|
63091
63468
|
queryKey: ["datasetValue", apiUrl, repo, workspace, datasetPath, hash2 ?? null],
|
|
63092
63469
|
queryFn: async () => {
|
|
63093
63470
|
const result = await datasetGet(apiUrl, repo, workspace, pathParts, reqOpts);
|
|
63094
|
-
const t02 = performance.now();
|
|
63095
63471
|
const decoded = decodeBeast2For(type, { platform: platformImpls })(result.data);
|
|
63096
|
-
const kind = (type == null ? void 0 : type.type) ?? "unknown";
|
|
63097
|
-
console.log(
|
|
63098
|
-
`[east-value] decode ${kind} ${(result.data.length / 1024).toFixed(1)}KB in ${(performance.now() - t02).toFixed(1)}ms (${datasetPath})`
|
|
63099
|
-
);
|
|
63100
63472
|
return { decoded, sizeBytes: result.data.length };
|
|
63101
63473
|
},
|
|
63102
63474
|
enabled: enabled && !!workspace && !!datasetPath && hash2 != null,
|