ai_co_discuss 0.5.13 → 0.5.14
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/.agents/skills/discuss-participant/SKILL.md +1 -1
- package/docs/en/guide/scheduling.md +1 -0
- package/docs/en/guide/working.md +6 -6
- package/docs/guide/scheduling.md +1 -0
- package/docs/guide/working.md +6 -6
- package/frontend/locales/en/room.json +2 -0
- package/package.json +1 -1
- package/runner/free_runner.mjs +7 -3
- package/web/admin.js +1 -1
- package/web/app.js +143 -54
- package/web/i18n.js +1 -1
- package/web/modern.css +1 -1
- package/web/modern.js +38 -38
package/web/app.js
CHANGED
|
@@ -72,15 +72,22 @@ const RESUME_LOADING_MAX_MS = 15000;
|
|
|
72
72
|
const TOAST_DURATION_MS = 3500;
|
|
73
73
|
// How long an archived room can be taken back before the archive is saved.
|
|
74
74
|
const ARCHIVE_UNDO_MS = 4000;
|
|
75
|
-
// The destroy effect: the wave across the element, each particle's random start and fade,
|
|
76
|
-
// the grain size in CSS pixels, about how many grains it keeps at most, and how many elements and text lines it draws at most.
|
|
77
75
|
// After this long still cleaning, a destroy says where to follow it.
|
|
78
76
|
const DESTROY_SLOW_MS = 20_000;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
const
|
|
77
|
+
// The destroy effect: how long the eroding edge takes to cross, how wide its soft band is (percent of the element), how
|
|
78
|
+
// long a grain of dust lives, dust per square CSS pixel swept, the share of bare background that sheds, the share of
|
|
79
|
+
// larger grains, the most grains at once, the mask tile and its cell size, and how many elements and text lines feed colours.
|
|
80
|
+
const DUST_WAVE_MS = 1100;
|
|
81
|
+
const DUST_BAND_PERCENT = 12;
|
|
82
|
+
const DUST_LIFE_MS = 1100;
|
|
83
|
+
const DUST_DENSITY = 0.02;
|
|
84
|
+
const DUST_BACKGROUND_SHARE = 0.04;
|
|
85
|
+
const DUST_BIG_SHARE = 0.15;
|
|
86
|
+
const DUST_PARTICLE_LIMIT = 14000;
|
|
87
|
+
const DUST_GRAIN_PX = 96;
|
|
88
|
+
// How far each grain's colour is lifted toward white.
|
|
89
|
+
const DUST_GLOW = 0.35;
|
|
90
|
+
const DUST_GRAIN_CELL = 3;
|
|
84
91
|
const DUST_ELEMENT_LIMIT = 1500;
|
|
85
92
|
const DUST_TEXT_LIMIT = 800;
|
|
86
93
|
const HOUR_MS = 3_600_000;
|
|
@@ -354,6 +361,8 @@ state.import_progress = null;
|
|
|
354
361
|
state.directory_pending = new Map();
|
|
355
362
|
// Rooms whose destruction this page started: listed, dimmed, until their receipt is complete; and the website's receipts.
|
|
356
363
|
state.destroying = new Map();
|
|
364
|
+
// Rooms whose destroy effect is playing right now.
|
|
365
|
+
state.dissolving = new Set();
|
|
357
366
|
state.destructions = [];
|
|
358
367
|
// Rooms already warned in this page that they destroy themselves within a day.
|
|
359
368
|
state.expiry_warned = new Set();
|
|
@@ -952,18 +961,29 @@ async function delete_channel(id) {
|
|
|
952
961
|
|
|
953
962
|
/** Play the destroy effect on the room's row, and on the middle pane when it is open, then take it off the page. */
|
|
954
963
|
async function dissolve_room(id) {
|
|
964
|
+
state.dissolving.add(id);
|
|
965
|
+
try { await dissolve_room_now(id); } finally { state.dissolving.delete(id); }
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
/** The effect itself and leaving the room; dissolve_room keeps a receipt from taking the room away meanwhile. */
|
|
969
|
+
async function dissolve_room_now(id) {
|
|
955
970
|
// Wait one frame so the confirmation has begun to close; the effect draws the page itself, not what covers it.
|
|
956
971
|
await new Promise(resolve => requestAnimationFrame(resolve));
|
|
957
972
|
const row = document.querySelector(`[data-drag-room="${CSS.escape(id)}"]`);
|
|
958
973
|
// A preview of the room's files (docked, floating, or folded into its capsule) dissolves too, then closes with the room.
|
|
959
974
|
const previews = [...document.querySelectorAll(`[data-preview-room="${CSS.escape(id)}"]`)];
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
975
|
+
// An open room goes as one: its conversation and its right-hand progress panel dissolve together.
|
|
976
|
+
const open = state.room?.id === id;
|
|
977
|
+
const targets = [row, open ? document.querySelector(".channel-main") : null, open ? document.querySelector(".channel-member-rail") : null, ...previews].filter(Boolean);
|
|
978
|
+
// The page moves on the moment the room has eroded away, so the last dust drifts over what comes next.
|
|
979
|
+
await dust_away(targets, async () => {
|
|
980
|
+
state.rooms = state.rooms.filter(item => item.id !== id);
|
|
981
|
+
// Like archiving the open room: the page goes to the new-room welcome, not into another room.
|
|
982
|
+
if (state.room?.id === id) await open_welcome();
|
|
983
|
+
render_rooms();
|
|
984
|
+
publish_view();
|
|
985
|
+
for (const target of targets) target.style.visibility = "";
|
|
986
|
+
});
|
|
967
987
|
}
|
|
968
988
|
|
|
969
989
|
/** Set how many days without a message a room may stay before it destroys itself; 0 keeps it. */
|
|
@@ -1030,7 +1050,8 @@ async function retry_destruction(id) {
|
|
|
1030
1050
|
function settle_destructions() {
|
|
1031
1051
|
for (const [id, { room }] of state.destroying) {
|
|
1032
1052
|
const record = state.destructions.find(item => item.room_id === id);
|
|
1033
|
-
|
|
1053
|
+
// A receipt that arrives while the room is still dissolving waits for it, so nothing switches away mid-effect.
|
|
1054
|
+
if (record?.status !== "done" || state.dissolving.has(id)) continue;
|
|
1034
1055
|
state.destroying.delete(id);
|
|
1035
1056
|
announce_receipt(room, record);
|
|
1036
1057
|
}
|
|
@@ -1076,61 +1097,121 @@ function warn_expiring_rooms() {
|
|
|
1076
1097
|
}
|
|
1077
1098
|
|
|
1078
1099
|
/**
|
|
1079
|
-
* Dissolve
|
|
1080
|
-
*
|
|
1081
|
-
*
|
|
1100
|
+
* Dissolve elements into drifting dust, left to right. The page itself erodes under a moving grain mask, so whatever it
|
|
1101
|
+
* shows (text, images, a document preview) breaks up as it is; dust rises from the eroding edge, coloured from what
|
|
1102
|
+
* was there, at one density for every element. Once the edge has crossed, each element is hidden and `on_eroded` runs
|
|
1103
|
+
* (the caller replaces the elements there) while the dust finishes drifting. With motion off or nothing visible,
|
|
1104
|
+
* `on_eroded` runs at once. Resolves when the dust has settled.
|
|
1082
1105
|
*/
|
|
1083
|
-
function dust_away(
|
|
1084
|
-
const
|
|
1085
|
-
if (!
|
|
1086
|
-
const ratio = Math.min(window.devicePixelRatio || 1, 2);
|
|
1106
|
+
async function dust_away(elements, on_eroded = () => {}) {
|
|
1107
|
+
const items = elements.map(element => ({ element, rect: element.getBoundingClientRect(), from: 0 })).filter(item => item.rect.width && item.rect.height);
|
|
1108
|
+
if (!items.length || document.documentElement.dataset.motion === "off" || document.hidden) return on_eroded();
|
|
1109
|
+
const width = window.innerWidth, height = window.innerHeight, ratio = Math.min(window.devicePixelRatio || 1, 2);
|
|
1110
|
+
// Where each colour was, read from the page drawn once; the dust takes the colour of the spot it leaves.
|
|
1111
|
+
const source = document.createElement("canvas");
|
|
1112
|
+
source.width = width;
|
|
1113
|
+
source.height = height;
|
|
1114
|
+
const painter = source.getContext("2d", { willReadFrequently: true });
|
|
1115
|
+
const view = { left: 0, top: 0, right: width, bottom: height, width, height };
|
|
1116
|
+
for (const { element } of items) paint_element(painter, element, view);
|
|
1117
|
+
const colours = painter.getImageData(0, 0, width, height).data;
|
|
1087
1118
|
const canvas = document.createElement("canvas");
|
|
1088
|
-
canvas.width = Math.ceil(
|
|
1089
|
-
canvas.height = Math.ceil(
|
|
1090
|
-
Object.assign(canvas.style, { position: "fixed",
|
|
1091
|
-
|
|
1092
|
-
const context = canvas.getContext("2d", { willReadFrequently: true });
|
|
1119
|
+
canvas.width = Math.ceil(width * ratio);
|
|
1120
|
+
canvas.height = Math.ceil(height * ratio);
|
|
1121
|
+
Object.assign(canvas.style, { position: "fixed", inset: "0", width: `${width}px`, height: `${height}px`, pointerEvents: "none", zIndex: "60" });
|
|
1122
|
+
const context = canvas.getContext("2d");
|
|
1093
1123
|
context.scale(ratio, ratio);
|
|
1094
|
-
paint_element(context, element, rect);
|
|
1095
|
-
const image = context.getImageData(0, 0, canvas.width, canvas.height).data;
|
|
1096
|
-
const step = Math.max(1, Math.round(DUST_STEP * ratio));
|
|
1097
|
-
let particles = [];
|
|
1098
|
-
for (let y = 0; y < canvas.height; y += step) for (let x = 0; x < canvas.width; x += step) {
|
|
1099
|
-
const at = (y * canvas.width + x) * 4;
|
|
1100
|
-
if (image[at + 3] < 40) continue;
|
|
1101
|
-
particles.push({ x: x / ratio, y: y / ratio, color: `rgba(${image[at]},${image[at + 1]},${image[at + 2]},`,
|
|
1102
|
-
delay: (x / canvas.width) * DUST_WAVE_MS + Math.random() * DUST_JITTER_MS,
|
|
1103
|
-
dx: 20 + Math.random() * 60, dy: -30 - Math.random() * 60, phase: Math.random() * 6.28 });
|
|
1104
|
-
}
|
|
1105
|
-
// Fine grains, thinned at random so even a whole conversation stays near DUST_PARTICLE_LIMIT particles.
|
|
1106
|
-
if (particles.length > DUST_PARTICLE_LIMIT) particles = particles.filter(() => Math.random() < DUST_PARTICLE_LIMIT / particles.length);
|
|
1107
1124
|
document.body.append(canvas);
|
|
1108
|
-
|
|
1109
|
-
|
|
1125
|
+
const grain = dust_grain();
|
|
1126
|
+
// The span every element lies in, which the one edge crosses, and the soft band behind that edge in CSS pixels.
|
|
1127
|
+
const span = { left: Math.min(...items.map(item => item.rect.left)), right: Math.max(...items.map(item => item.rect.right)) };
|
|
1128
|
+
span.width = span.right - span.left;
|
|
1129
|
+
const band = span.width * DUST_BAND_PERCENT / 100;
|
|
1130
|
+
for (const { element } of items) {
|
|
1131
|
+
Object.assign(element.style, { maskImage: `url(${grain}), linear-gradient(90deg, transparent 0%, #000 0%)`, maskSize: `${DUST_GRAIN_PX}px ${DUST_GRAIN_PX}px, 100% 100%`,
|
|
1132
|
+
maskRepeat: "repeat, no-repeat", maskComposite: "intersect", webkitMaskImage: `url(${grain}), linear-gradient(90deg, transparent 0%, #000 0%)`,
|
|
1133
|
+
webkitMaskSize: `${DUST_GRAIN_PX}px ${DUST_GRAIN_PX}px, 100% 100%`, webkitMaskRepeat: "repeat, no-repeat", webkitMaskComposite: "source-in" });
|
|
1134
|
+
}
|
|
1135
|
+
const particles = [];
|
|
1136
|
+
const start = performance.now();
|
|
1137
|
+
let last = start, eroded = null;
|
|
1138
|
+
// The elements leave together, once the edge has crossed them all; the dust keeps drifting over what replaces them.
|
|
1139
|
+
const erode = () => {
|
|
1140
|
+
for (const { element } of items) {
|
|
1141
|
+
element.style.visibility = "hidden";
|
|
1142
|
+
for (const name of ["maskImage", "maskSize", "maskRepeat", "maskComposite", "webkitMaskImage", "webkitMaskSize", "webkitMaskRepeat", "webkitMaskComposite"]) element.style[name] = "";
|
|
1143
|
+
}
|
|
1144
|
+
return Promise.resolve(on_eroded()).catch(error => notify("error", error.message));
|
|
1145
|
+
};
|
|
1110
1146
|
return new Promise(resolve => {
|
|
1111
1147
|
const frame = now => {
|
|
1112
|
-
const elapsed = now - start;
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1148
|
+
const elapsed = now - start, seconds = Math.min(0.05, (now - last) / 1000);
|
|
1149
|
+
last = now;
|
|
1150
|
+
// The edge eases in and out; a soft band behind it keeps a few grains before they go.
|
|
1151
|
+
const wave = Math.min(1, elapsed / DUST_WAVE_MS), front = wave < 0.5 ? 2 * wave * wave : 1 - (-2 * wave + 2) ** 2 / 2;
|
|
1152
|
+
const sweep = span.left + front * (span.width + band);
|
|
1153
|
+
// Once eroded, the elements hold what replaced them: the mask and the shedding stop, the dust drifts on.
|
|
1154
|
+
for (const item of eroded ? [] : items) {
|
|
1155
|
+
const { element, rect } = item;
|
|
1156
|
+
// One edge sweeps across all the elements together, so the row, the conversation and the panels go as one piece.
|
|
1157
|
+
const to = (sweep - rect.left) / rect.width * 100, from = to - band / rect.width * 100;
|
|
1158
|
+
element.style.maskImage = element.style.webkitMaskImage = `url(${grain}), linear-gradient(90deg, transparent ${from}%, #000 ${to}%)`;
|
|
1159
|
+
// Dust in proportion to the area just swept, so every element sheds it equally densely.
|
|
1160
|
+
const edge = Math.min(rect.right, Math.max(rect.left, sweep));
|
|
1161
|
+
const left = rect.left + rect.width * item.from, swept = Math.max(0, edge - left);
|
|
1162
|
+
item.from = Math.min(1, (edge - rect.left) / rect.width);
|
|
1163
|
+
for (let count = Math.round(swept * rect.height * DUST_DENSITY); count > 0 && particles.length < DUST_PARTICLE_LIMIT; count--) {
|
|
1164
|
+
const x = left + Math.random() * swept, y = rect.top + Math.random() * rect.height;
|
|
1165
|
+
const at = ((Math.min(height - 1, Math.max(0, y | 0))) * width + Math.min(width - 1, Math.max(0, x | 0))) * 4;
|
|
1166
|
+
// Bare background sheds less than text and cards, so the content is what visibly flies apart.
|
|
1167
|
+
if (colours[at + 3] < 40 && Math.random() > DUST_BACKGROUND_SHARE) continue;
|
|
1168
|
+
// Lifted toward white so the dust glows against the dark page instead of melting into it.
|
|
1169
|
+
const lift = channel => Math.round(channel + (255 - channel) * DUST_GLOW);
|
|
1170
|
+
const colour = colours[at + 3] < 40 ? "190,196,208" : `${lift(colours[at])},${lift(colours[at + 1])},${lift(colours[at + 2])}`;
|
|
1171
|
+
const big = Math.random() < DUST_BIG_SHARE;
|
|
1172
|
+
particles.push({ x, y, colour, vx: 40 + Math.random() * 140, vy: -30 - Math.random() * 120, lift: 40 + Math.random() * 80,
|
|
1173
|
+
size: big ? 3 + Math.random() * 2.5 : 1.4 + Math.random() * 1.8, born: elapsed, life: DUST_LIFE_MS * (0.6 + Math.random() * 0.8),
|
|
1174
|
+
wobble: Math.random() * 6.28 });
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
context.clearRect(0, 0, width, height);
|
|
1178
|
+
for (let index = particles.length - 1; index >= 0; index--) {
|
|
1179
|
+
const particle = particles[index], age = (elapsed - particle.born) / particle.life;
|
|
1180
|
+
if (age >= 1) { particles.splice(index, 1); continue; }
|
|
1181
|
+
particle.vy -= particle.lift * seconds;
|
|
1182
|
+
particle.x += (particle.vx + Math.sin(particle.wobble + age * 8) * 30) * seconds;
|
|
1183
|
+
particle.y += particle.vy * seconds;
|
|
1184
|
+
context.fillStyle = `rgba(${particle.colour},${((1 - age) ** 1.4).toFixed(3)})`;
|
|
1185
|
+
context.fillRect(particle.x, particle.y, particle.size, particle.size);
|
|
1120
1186
|
}
|
|
1187
|
+
if (wave >= 1 && !eroded) eroded = erode();
|
|
1121
1188
|
// A page sent to the background ends the effect at once rather than stalling what follows.
|
|
1122
|
-
if (
|
|
1123
|
-
|
|
1189
|
+
if ((wave < 1 || particles.length) && !document.hidden) return requestAnimationFrame(frame);
|
|
1190
|
+
canvas.remove();
|
|
1191
|
+
(eroded || erode()).then(resolve);
|
|
1124
1192
|
};
|
|
1125
1193
|
requestAnimationFrame(frame);
|
|
1126
1194
|
});
|
|
1127
1195
|
}
|
|
1128
1196
|
|
|
1197
|
+
/** A tile of random grains (as a data URL) whose transparency the eroding edge thresholds into dust. */
|
|
1198
|
+
function dust_grain() {
|
|
1199
|
+
if (dust_grain.url) return dust_grain.url;
|
|
1200
|
+
const canvas = document.createElement("canvas");
|
|
1201
|
+
canvas.width = canvas.height = DUST_GRAIN_PX;
|
|
1202
|
+
const context = canvas.getContext("2d");
|
|
1203
|
+
for (let y = 0; y < DUST_GRAIN_PX; y += DUST_GRAIN_CELL) for (let x = 0; x < DUST_GRAIN_PX; x += DUST_GRAIN_CELL) {
|
|
1204
|
+
context.fillStyle = `rgba(0,0,0,${Math.random().toFixed(2)})`;
|
|
1205
|
+
context.fillRect(x, y, DUST_GRAIN_CELL, DUST_GRAIN_CELL);
|
|
1206
|
+
}
|
|
1207
|
+
return (dust_grain.url = canvas.toDataURL());
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1129
1210
|
/** Draw an element's visible backgrounds and text runs onto a canvas placed at `origin`, as the destroy effect's source. */
|
|
1130
1211
|
function paint_element(context, element, origin) {
|
|
1131
1212
|
const visible = box => box.width && box.height && box.bottom > origin.top && box.top < origin.bottom && box.right > origin.left && box.left < origin.right;
|
|
1132
1213
|
const opaque = color => color && color !== "transparent" && !/,\s*0\)$/.test(color);
|
|
1133
|
-
for (const node of [
|
|
1214
|
+
for (const node of [...element.querySelectorAll("*")].slice(0, DUST_ELEMENT_LIMIT)) {
|
|
1134
1215
|
const box = node.getBoundingClientRect();
|
|
1135
1216
|
if (!visible(box)) continue;
|
|
1136
1217
|
const style = getComputedStyle(node);
|
|
@@ -1674,7 +1755,8 @@ async function refresh_room({ room: read_room = true } = {}) {
|
|
|
1674
1755
|
render_rooms();
|
|
1675
1756
|
publish_view();
|
|
1676
1757
|
if (directory.last_room !== undefined && !state.room) state.last_room = directory.last_room;
|
|
1677
|
-
|
|
1758
|
+
// A room being destroyed leaves on its own once it has dissolved; a refresh meanwhile does not switch away under it.
|
|
1759
|
+
if (state.room && !state.rooms.some((item) => item.id === state.room.id) && !state.destroying.has(state.room.id)) return select_room(visible_rooms()[0]?.id);
|
|
1678
1760
|
if (!state.room || !read_room) {
|
|
1679
1761
|
if (!state.room && !state.welcome && visible_rooms().length) return select_room(opening_room());
|
|
1680
1762
|
render_rooms();
|
|
@@ -2489,6 +2571,10 @@ async function finish_message(result, job) {
|
|
|
2489
2571
|
url: `/api/rooms/${encodeURIComponent(room_id)}/attachments/${encodeURIComponent(item.uploaded)}/content` }));
|
|
2490
2572
|
const sent_message = { ...result.message, text: job.payload.text || "", attachments, reply_to: job.payload.reply_to ?? result.message.reply_to ?? null,
|
|
2491
2573
|
...(job.payload.attachment_start ? { attachment_start: job.payload.attachment_start } : {}), source: "user", just_sent: true };
|
|
2574
|
+
// The card draws `rendered_text`, which only render_messages prepares; a receipt shown before the transcript read
|
|
2575
|
+
// needs it too, or the card shows its header with an empty body.
|
|
2576
|
+
sent_message.rendered_text = link_attachment_placeholders(render_room_markdown(sent_message.text), attachments);
|
|
2577
|
+
sent_message.rendered_summary = render_room_markdown(sent_message.summary || "");
|
|
2492
2578
|
const members = predicted_recipients(job.payload, state.room, state.launch?.room_models);
|
|
2493
2579
|
if (members.length) {
|
|
2494
2580
|
job.saved_message = sent_message;
|
|
@@ -7476,6 +7562,9 @@ async function share_delivered_files(responses, room_id, folders) {
|
|
|
7476
7562
|
for (const named of share_named_paths(message.text)) {
|
|
7477
7563
|
const relative = named.replaceAll("\\", "/").replace(/^\.\//, "");
|
|
7478
7564
|
if (/^([a-z]:)?\//i.test(relative) || relative.split("/").includes("..")) continue;
|
|
7565
|
+
// An answer attaching a file of the same name shows only the attachment, as in the room (user 2026-11-22).
|
|
7566
|
+
const name = relative.split("/").at(-1).toLowerCase();
|
|
7567
|
+
if ((message.attachments || []).some(file => String(file.file_name).toLowerCase() === name)) continue;
|
|
7479
7568
|
for (let root = 0; root < roots; root++) {
|
|
7480
7569
|
const result = await read_room_files(room_id, relative, 0, "", root).catch(() => null);
|
|
7481
7570
|
if (result?.kind !== "file" || Date.parse(result.modified_at) < started.get(message.execution_id) * 1000) continue;
|