Skip to content

Commit a8e486d

Browse files
klopez4212codex
andcommitted
Merge remote-tracking branch 'origin/main' into kennylopez-composer-rich-preview
Signed-off-by: klopez4212 <[email protected]> Co-authored-by: Codex <[email protected]>
2 parents 0737fbd + 53970a7 commit a8e486d

37 files changed

Lines changed: 3855 additions & 166 deletions

‎patches/@[email protected]‎

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,155 @@ index ef202bd782287091b2a7d0d179fe5d43c4ff73a3..34d5f2b811eb9412c071f3340c575d14
258258
const defaultProps = {
259259
id: idProp,
260260
role: 'radiogroup',
261+
diff --git a/floating-ui-react/hooks/useHoverReferenceInteraction.d.mts b/floating-ui-react/hooks/useHoverReferenceInteraction.d.mts
262+
index 9f3ac4b14b6bd2caeef52ce284e1d22d1ba007fe..f12bffd0ef926ade984240b9a1e2c4b1cc13babc 100644
263+
--- a/floating-ui-react/hooks/useHoverReferenceInteraction.d.mts
264+
+++ b/floating-ui-react/hooks/useHoverReferenceInteraction.d.mts
265+
@@ -25,7 +25,7 @@ export interface UseHoverReferenceInteractionProps {
266+
* Called before each hover-driven open attempt (immediate, delayed, and rest-ms
267+
* paths). Return `false` to veto; any other return value permits the open.
268+
*/
269+
- shouldOpen?: (() => boolean) | undefined;
270+
+ shouldOpen?: ((event: MouseEvent) => boolean) | undefined;
271+
/**
272+
* Regression workaround (#5152): also cancels a pending hover-open from the
273+
* trigger's `mouseout`, backing up a `mouseleave` that Chrome can drop during
274+
diff --git a/floating-ui-react/hooks/useHoverReferenceInteraction.d.ts b/floating-ui-react/hooks/useHoverReferenceInteraction.d.ts
275+
index 7551ed4a6cc55fe7c2c9973670c8dcaff650ba2f..c9a80f623b357233e5eeeadcf0762697175f84d9 100644
276+
--- a/floating-ui-react/hooks/useHoverReferenceInteraction.d.ts
277+
+++ b/floating-ui-react/hooks/useHoverReferenceInteraction.d.ts
278+
@@ -25,7 +25,7 @@ export interface UseHoverReferenceInteractionProps {
279+
* Called before each hover-driven open attempt (immediate, delayed, and rest-ms
280+
* paths). Return `false` to veto; any other return value permits the open.
281+
*/
282+
- shouldOpen?: (() => boolean) | undefined;
283+
+ shouldOpen?: ((event: MouseEvent) => boolean) | undefined;
284+
/**
285+
* Regression workaround (#5152): also cancels a pending hover-open from the
286+
* trigger's `mouseout`, backing up a `mouseleave` that Chrome can drop during
287+
diff --git a/floating-ui-react/hooks/useHoverReferenceInteraction.js b/floating-ui-react/hooks/useHoverReferenceInteraction.js
288+
index 9c5f5bae91441c732a0def38caf2ca655c7d7aae..1be80667032ff899e5cb11db652bf9063077900f 100644
289+
--- a/floating-ui-react/hooks/useHoverReferenceInteraction.js
290+
+++ b/floating-ui-react/hooks/useHoverReferenceInteraction.js
291+
@@ -62,8 +62,8 @@ function useHoverReferenceInteraction(context, props = {}) {
292+
const isClickLikeOpenEvent = (0, _useStableCallback.useStableCallback)(() => {
293+
return (0, _useHoverShared.isClickLikeOpenEvent)(dataRef.current.openEvent?.type, instance.interactedInside);
294+
});
295+
- const checkShouldOpen = (0, _useStableCallback.useStableCallback)(() => {
296+
- return shouldOpenRef.current?.() !== false;
297+
+ const checkShouldOpen = (0, _useStableCallback.useStableCallback)(event => {
298+
+ return shouldOpenRef.current?.(event) !== false;
299+
});
300+
const isOverInactiveTrigger = (0, _useStableCallback.useStableCallback)((currentDomReference, currentTarget, target) => {
301+
const allTriggers = store.context.triggerElements;
302+
@@ -184,7 +184,7 @@ function useHoverReferenceInteraction(context, props = {}) {
303+
// Open immediately when moving between triggers while open, or during
304+
// a hover-driven close transition (including same-trigger re-entry).
305+
if (shouldOpenImmediately) {
306+
- if (checkShouldOpen()) {
307+
+ if (checkShouldOpen(event)) {
308+
store.setOpen(true, (0, _createBaseUIEventDetails.createChangeEventDetails)(_reasons.REASONS.triggerHover, event, triggerNode));
309+
}
310+
return;
311+
@@ -194,12 +194,12 @@ function useHoverReferenceInteraction(context, props = {}) {
312+
}
313+
if (openDelay) {
314+
instance.openChangeTimeout.start(openDelay, () => {
315+
- if (shouldOpen && checkShouldOpen()) {
316+
+ if (shouldOpen && checkShouldOpen(event)) {
317+
store.setOpen(true, (0, _createBaseUIEventDetails.createChangeEventDetails)(_reasons.REASONS.triggerHover, event, triggerNode));
318+
}
319+
});
320+
} else if (shouldOpen) {
321+
- if (checkShouldOpen()) {
322+
+ if (checkShouldOpen(event)) {
323+
store.setOpen(true, (0, _createBaseUIEventDetails.createChangeEventDetails)(_reasons.REASONS.triggerHover, event, triggerNode));
324+
}
325+
}
326+
@@ -312,7 +312,7 @@ function useHoverReferenceInteraction(context, props = {}) {
327+
return;
328+
}
329+
const latestOpen = store.select('open');
330+
- if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) {
331+
+ if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen(nativeEvent)) {
332+
store.setOpen(true, (0, _createBaseUIEventDetails.createChangeEventDetails)(_reasons.REASONS.triggerHover, nativeEvent, trigger));
333+
}
334+
}
335+
diff --git a/floating-ui-react/hooks/useHoverReferenceInteraction.mjs b/floating-ui-react/hooks/useHoverReferenceInteraction.mjs
336+
index 01ec377e5046cf1645dbd2203e8c6dc99a89ea18..659a8dc07135f8a82e03b654d514c4f2a010cb4c 100644
337+
--- a/floating-ui-react/hooks/useHoverReferenceInteraction.mjs
338+
+++ b/floating-ui-react/hooks/useHoverReferenceInteraction.mjs
339+
@@ -56,8 +56,8 @@ export function useHoverReferenceInteraction(context, props = {}) {
340+
const isClickLikeOpenEvent = useStableCallback(() => {
341+
return isClickLikeOpenEventShared(dataRef.current.openEvent?.type, instance.interactedInside);
342+
});
343+
- const checkShouldOpen = useStableCallback(() => {
344+
- return shouldOpenRef.current?.() !== false;
345+
+ const checkShouldOpen = useStableCallback(event => {
346+
+ return shouldOpenRef.current?.(event) !== false;
347+
});
348+
const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
349+
const allTriggers = store.context.triggerElements;
350+
@@ -178,7 +178,7 @@ export function useHoverReferenceInteraction(context, props = {}) {
351+
// Open immediately when moving between triggers while open, or during
352+
// a hover-driven close transition (including same-trigger re-entry).
353+
if (shouldOpenImmediately) {
354+
- if (checkShouldOpen()) {
355+
+ if (checkShouldOpen(event)) {
356+
store.setOpen(true, createChangeEventDetails(REASONS.triggerHover, event, triggerNode));
357+
}
358+
return;
359+
@@ -188,12 +188,12 @@ export function useHoverReferenceInteraction(context, props = {}) {
360+
}
361+
if (openDelay) {
362+
instance.openChangeTimeout.start(openDelay, () => {
363+
- if (shouldOpen && checkShouldOpen()) {
364+
+ if (shouldOpen && checkShouldOpen(event)) {
365+
store.setOpen(true, createChangeEventDetails(REASONS.triggerHover, event, triggerNode));
366+
}
367+
});
368+
} else if (shouldOpen) {
369+
- if (checkShouldOpen()) {
370+
+ if (checkShouldOpen(event)) {
371+
store.setOpen(true, createChangeEventDetails(REASONS.triggerHover, event, triggerNode));
372+
}
373+
}
374+
@@ -306,7 +306,7 @@ export function useHoverReferenceInteraction(context, props = {}) {
375+
return;
376+
}
377+
const latestOpen = store.select('open');
378+
- if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) {
379+
+ if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen(nativeEvent)) {
380+
store.setOpen(true, createChangeEventDetails(REASONS.triggerHover, nativeEvent, trigger));
381+
}
382+
}
383+
diff --git a/menu/submenu-trigger/MenuSubmenuTrigger.js b/menu/submenu-trigger/MenuSubmenuTrigger.js
384+
index 76610266064c56e99741296140b0db02d8b7ab04..66f90d4389411580f5aef91a8198686ee814011b 100644
385+
--- a/menu/submenu-trigger/MenuSubmenuTrigger.js
386+
+++ b/menu/submenu-trigger/MenuSubmenuTrigger.js
387+
@@ -146,7 +146,9 @@ const MenuSubmenuTrigger = exports.MenuSubmenuTrigger = /*#__PURE__*/React.forwa
388+
open: delay,
389+
close: closeDelay
390+
},
391+
- shouldOpen: delay > 0 ? () => parentMenuStore.select('allowMouseEnter') : undefined,
392+
+ // A newly opened parent can appear beneath a stationary pointer.
393+
+ // Zero delay still requires pointer movement before activating its submenu.
394+
+ shouldOpen: event => parentMenuStore.select('allowMouseEnter') || delay === 0 && event.type === 'mousemove',
395+
triggerElementRef,
396+
externalTree: floatingTreeRoot,
397+
isClosing: () => store.select('transitionStatus') === 'ending',
398+
diff --git a/menu/submenu-trigger/MenuSubmenuTrigger.mjs b/menu/submenu-trigger/MenuSubmenuTrigger.mjs
399+
index 243ee5ac67bbb0297a3ede21f3963372c43c0150..341beb1f7a2093e68d1bd65fae62c7712a657d11 100644
400+
--- a/menu/submenu-trigger/MenuSubmenuTrigger.mjs
401+
+++ b/menu/submenu-trigger/MenuSubmenuTrigger.mjs
402+
@@ -139,7 +139,9 @@ export const MenuSubmenuTrigger = /*#__PURE__*/React.forwardRef(function MenuSub
403+
open: delay,
404+
close: closeDelay
405+
},
406+
- shouldOpen: delay > 0 ? () => parentMenuStore.select('allowMouseEnter') : undefined,
407+
+ // A newly opened parent can appear beneath a stationary pointer.
408+
+ // Zero delay still requires pointer movement before activating its submenu.
409+
+ shouldOpen: event => parentMenuStore.select('allowMouseEnter') || delay === 0 && event.type === 'mousemove',
410+
triggerElementRef,
411+
externalTree: floatingTreeRoot,
412+
isClosing: () => store.select('transitionStatus') === 'ending',

‎pnpm-lock.yaml‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/bundled/agents/AgentsPage.test.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const agent = (name: string, n: number): Agent => ({
2828
config: { reply: `${name} says hi` },
2929
skipped: {},
3030
timers: {},
31+
attentionEnabled: true,
3132
attention: {
3233
"interest/default": {
3334
slug: "interest/default",

‎src/bundled/builderlab/adapter-type/Instructions.test.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const agent = (pubkey = first): Agent => ({
2323
config: {},
2424
attention: {},
2525
skipped: {},
26+
attentionEnabled: true,
2627
timers: {},
2728
});
2829
const response = (): HostResponse => ({
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## Attention
2+
3+
Your attention is yours to manage: Interests say what you are responsible for, event watches wake you when a matching event arrives, and timers wake you on a schedule. Use the attention tools. A successful write is authoritative; show again only when a later decision needs the current object or the result is ambiguous.
4+
5+
Every write needs the `expected_state` from your latest show or write of that object, or `object-v1:absent` to create one. A `conflict` means the object changed since you read it: show it again and decide again. `wrong-scope` means the object belongs to another Interest than the one you named.
6+
7+
Use `interest_set`, `watch_add` (only for a new watch), `watch_update` (only supplied fields change), `watch_enable`, `watch_disable`, `watch_rearm` and `watch_remove`. `watch_disable` stops a timer; only `watch_rearm` starts one again. A timer's interval is at least 60 seconds. Remove watches when their purpose is complete, superseded, or no longer relevant; remove an Interest after its watches when it has no remaining purpose. Event watches require an explicit `since` intake floor and `channels`. A watch sees only channels you are a member of; `"all"` means all of those. It sees events that arrive while it is on: an earlier `since` does not replay older ones. When widening a watch, set its `since` floor to the change time. Use `watch_list` with `type`, `status` and `search` when a decision needs a summary. Each matching event watch runs independently. Put reporting destinations in Interest instructions, not watch options.
8+
9+
A watch or timer turn is a one-off session: it does not continue any conversation, and `send` has no default destination in it. Name the `channel` (and `reply`, to answer in a thread) that the Interest instructions give. A watch match is permission to process, not to reply. Unless addressed to you or required to report by the Interest instructions, process silently. Do not answer or decline work assigned to someone else.
10+
11+
Prefer deterministic selectors and `filter` for hard rules; use the Jev classifier only for judgment. Filters can be negated: `!(author == "OWNER_HEX")` excludes the owner's own messages, and `!is_reply` keeps only top-level messages. When a watch reports to the owner, exclude the owner's messages unless they are the signal.
12+
13+
For noisy event watches, add a Jev classifier with `watch_add` or `watch_update`; remove it with `watch_update` and `clear: ["classifier"]`. Jev tests relevance after normal filters. It sees one event, not history, and has no tools. Use named yes/no questions, for example `{"questions":{"release_blocked":{"question":"Does the event say the release cannot proceed until something is fixed?","true":"It reports a release blocker, in any form: a question, an instruction or a status report.","false":"Routine release progress, or a problem that does not stop the release."}}}`. Write questions for the facts the Interest needs, not for message types, and accept any phrasing of those facts. Ask one thing per question. The event passes when any question says yes. Each added question can add extra passes, so keep them few. For "A but not B", write one question that says so. Optional per question: `true` and `false` descriptions, `guidance` for examples and exclusions, and `threshold` (default 0.2; lower passes more). Change a threshold only when eval cases support it. Keep actions in the Interest. Pass uncertain cases. Errors pass events through.
14+
15+
A classifier may not be able to run on this device: every attention tool answer says `classifier: available` or `classifier: unavailable`. You can still save, change and clear classifiers while one is unavailable; they run once it is available. Until then, a classified watch's events pass unchecked, and the turn they start says so in a `<watch-classifier>` block.
16+
17+
Timers run once by default. `max_occurrences` (a count, or `"unbounded"`) and `expires_at` (Unix seconds, or `"unbounded"`) control the budget; remaining budget schedules the next interval automatically. `watch_show` shows `used`, `next_due` and the status, and `watch_list` with `status: "spent"` finds spent timers. The final allowed wake says it is the last. Use `watch_rearm` deliberately for a fresh deadline; it does not reset usage or bypass expiration, so raise a spent timer's limits first (rearm accepts them too). Report tool conflicts or failures; do not blindly retry an ambiguous write. Attention does not grant channel membership or authority to act.

‎src/bundled/claude-code/claude-testing.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export type FakeClaude = {
2222
/** When set, a turn stays open until `finish()`. */
2323
hold: boolean;
2424
killed: boolean;
25+
/** When false, a kill is only a request; the test calls `exit()`. */
26+
exitOnKill: boolean;
2527
emit(message: Record<string, unknown>): void;
2628
finish(result?: Readonly<{ error?: string }>): void;
2729
exit(code: number | null, stderr?: string): void;
@@ -77,6 +79,7 @@ export function fakeSpawn(known = new Set<string>()) {
7779
models: [],
7880
hold: false,
7981
killed: false,
82+
exitOnKill: true,
8083
emit(message) {
8184
if (alive) options.onStdout?.(`${JSON.stringify(message)}\n`);
8285
},
@@ -185,7 +188,7 @@ export function fakeSpawn(known = new Set<string>()) {
185188
end: async () => undefined,
186189
kill: async () => {
187190
fake.killed = true;
188-
fake.exit(null);
191+
if (fake.exitOnKill) fake.exit(null);
189192
},
190193
exited,
191194
};

‎src/bundled/claude-code/lanes.ts‎

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// Janet's lanes for attention turns: an Interest's turns run one at a time, in
2+
// order, and only a few Interests run at once, so a burst of watch matches
3+
// cannot take every process the agent has. A slot is freed after each turn and
4+
// goes to the Interest that has waited longest, so a busy Interest cannot hold
5+
// one while others wait.
6+
7+
/** Interests whose turns run at once. */
8+
export const LANES = 2;
9+
/** Turns one Interest can have waiting, and all Interests together, as in
10+
* Janet; later ones are dropped and logged. */
11+
export const LANE_LIMIT = 8;
12+
export const TOTAL_LIMIT = 32;
13+
14+
type Queued = { task: () => Promise<unknown>; dropped?: () => void };
15+
16+
export class Lanes {
17+
private readonly queues = new Map<string, Queued[]>();
18+
/** Lanes with work waiting for a free slot, longest waiting first. */
19+
private readonly ready: string[] = [];
20+
private readonly running = new Set<string>();
21+
private waiting = 0;
22+
private stopped = false;
23+
24+
constructor(private readonly width = LANES) {}
25+
26+
/** Queues `task` on `lane`, or says why it was not. `dropped` is called
27+
* if the task is dropped while it waits. */
28+
add(
29+
lane: string,
30+
task: () => Promise<unknown>,
31+
dropped?: () => void,
32+
): "queued" | "full" | "stopped" {
33+
if (this.stopped) return "stopped";
34+
const queue = this.queues.get(lane) ?? [];
35+
if (queue.length >= LANE_LIMIT || this.waiting >= TOTAL_LIMIT)
36+
return "full";
37+
queue.push({ task, ...(dropped ? { dropped } : {}) });
38+
this.waiting++;
39+
this.queues.set(lane, queue);
40+
if (!this.running.has(lane) && !this.ready.includes(lane))
41+
this.ready.push(lane);
42+
this.pump();
43+
return "queued";
44+
}
45+
46+
/** Drops every waiting turn; running ones finish. */
47+
clear() {
48+
const queues = [...this.queues.values()];
49+
this.queues.clear();
50+
this.ready.length = 0;
51+
this.waiting = 0;
52+
for (const queue of queues) for (const queued of queue) queued.dropped?.();
53+
}
54+
/** Drops every waiting turn, and takes no more. */
55+
stop() {
56+
this.stopped = true;
57+
this.clear();
58+
}
59+
60+
private pump() {
61+
while (this.running.size < this.width && this.ready.length) {
62+
const lane = this.ready.shift() as string;
63+
const task = this.queues.get(lane)?.shift()?.task;
64+
if (!task) {
65+
this.queues.delete(lane);
66+
continue;
67+
}
68+
this.waiting--;
69+
this.running.add(lane);
70+
void this.turn(lane, task);
71+
}
72+
}
73+
74+
private async turn(lane: string, task: () => Promise<unknown>) {
75+
try {
76+
await task();
77+
} catch (error) {
78+
console.warn("An attention turn failed", error);
79+
}
80+
this.running.delete(lane);
81+
if (this.queues.get(lane)?.length) this.ready.push(lane);
82+
else this.queues.delete(lane);
83+
this.pump();
84+
}
85+
}

0 commit comments

Comments
 (0)