ai_co_discuss 0.4.60 → 0.4.61
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/backend/free_room.py +16 -6
- package/backend/message_queue.py +7 -2
- package/frontend/locales/en/backend.json +1 -1
- package/frontend/locales/en/room.json +3 -1
- package/package.json +1 -1
- package/web/app.js +36 -12
- package/web/i18n.js +2 -2
- package/web/modern.css +1 -1
- package/web/modern.js +33 -33
package/backend/free_room.py
CHANGED
|
@@ -618,9 +618,15 @@ def failure_class_of(connection, execution_id):
|
|
|
618
618
|
|
|
619
619
|
|
|
620
620
|
def quota_held_until(connection, member_id):
|
|
621
|
-
"""Until when a member out of quota waits: its latest execution failed on a usage limit and was not retried; else 0.
|
|
621
|
+
"""Until when a member out of quota waits: its latest execution failed on a usage limit and was not retried; else 0.
|
|
622
|
+
|
|
623
|
+
A new request the owner or the host gives it afterwards ends the wait and is tried at once: the reset time is only
|
|
624
|
+
the software's estimate (extra usage, another plan, another account signed in or an earlier reset lift it sooner),
|
|
625
|
+
and work nobody picks up is worse than one more quick failure, which holds the member again."""
|
|
622
626
|
row = connection.execute("""SELECT f.failed_at,f.reset_at FROM execution_failures f
|
|
623
|
-
WHERE f.failure_class='quota' AND f.execution_id=(SELECT MAX(id) FROM member_executions WHERE member_id=?)
|
|
627
|
+
WHERE f.failure_class='quota' AND f.execution_id=(SELECT MAX(id) FROM member_executions WHERE member_id=?)
|
|
628
|
+
AND NOT EXISTS(SELECT 1 FROM member_requests r WHERE r.member_id=? AND r.status='pending' AND r.created_by IN ('user','host')
|
|
629
|
+
AND r.created_at>=f.failed_at)""", (member_id, member_id)).fetchone()
|
|
624
630
|
until = (row["reset_at"] or row["failed_at"] + QUOTA_HOLD_SECONDS) if row else 0
|
|
625
631
|
return until if until > int(time.time()) else 0
|
|
626
632
|
|
|
@@ -1062,6 +1068,7 @@ def free_view(connection, room_id):
|
|
|
1062
1068
|
member["pending"] = connection.execute("SELECT COUNT(*) FROM member_requests WHERE member_id=? AND status='pending'",
|
|
1063
1069
|
(row["id"],)).fetchone()[0]
|
|
1064
1070
|
member["held_until"] = held_until(connection, row["id"])
|
|
1071
|
+
member["quota_until"] = quota_held_until(connection, row["id"])
|
|
1065
1072
|
members.append(member)
|
|
1066
1073
|
names = {row["id"]: row["name"] for row in connection.execute("SELECT id,name FROM room_members WHERE room_id=?", (room_id,))}
|
|
1067
1074
|
requests = [{**dict(row), "member": names.get(row["member_id"], ""),
|
|
@@ -2643,15 +2650,17 @@ def hand_over_routes(connection, room_id, routes, departed_id):
|
|
|
2643
2650
|
VALUES (?,?,?,?,?,'user',?)""", (room_id, host["id"], message_id, message_id, purpose, int(time.time())))
|
|
2644
2651
|
|
|
2645
2652
|
|
|
2646
|
-
def stop_member_work(connection, member_id, reason, cancel_reason, keep_pending=False):
|
|
2653
|
+
def stop_member_work(connection, member_id, reason, cancel_reason, keep_pending=False, requeue=False):
|
|
2647
2654
|
"""Void a member's live execution and, unless `keep_pending`, every open request, so nothing restarts by itself.
|
|
2648
2655
|
|
|
2649
2656
|
The owner's stop keeps the requests that arrived while the member worked: like interrupting a turn, the member then
|
|
2650
|
-
goes on to the messages sent after it, while a member that leaves drops them all.
|
|
2657
|
+
goes on to the messages sent after it, while a member that leaves drops them all. With `requeue` (the owner sending
|
|
2658
|
+
a message at once) the interrupted turn's own requests go back to pending too, so the next delivery carries them with
|
|
2659
|
+
the new message and nothing the owner asked is left unanswered.
|
|
2651
2660
|
"""
|
|
2652
2661
|
for row in connection.execute("SELECT id FROM member_executions WHERE member_id=? AND status IN ('dispatched','started')",
|
|
2653
2662
|
(member_id,)).fetchall():
|
|
2654
|
-
finish_execution(connection, row["id"], "cancelled", reason, "cancelled", cancel_reason)
|
|
2663
|
+
finish_execution(connection, row["id"], "cancelled", reason, "pending" if requeue else "cancelled", "" if requeue else cancel_reason)
|
|
2655
2664
|
if not keep_pending:
|
|
2656
2665
|
record_cancel_reasons(connection, "member_id=? AND status='pending'", (member_id,), cancel_reason)
|
|
2657
2666
|
connection.execute("UPDATE member_requests SET status='cancelled' WHERE member_id=? AND status='pending'", (member_id,))
|
|
@@ -2808,6 +2817,7 @@ def inbox(connection, room_id, token):
|
|
|
2808
2817
|
member_view["label"] = shown.get(row["name"], row["name"])
|
|
2809
2818
|
member_view["review_capability"] = review_capability(connection, room_id, row["id"], token)
|
|
2810
2819
|
member_view["held_until"] = held_until(connection, row["id"])
|
|
2820
|
+
member_view["quota_until"] = quota_held_until(connection, row["id"])
|
|
2811
2821
|
# The runner compares this with its adapter's effect and reports a change.
|
|
2812
2822
|
reported = connection.execute("SELECT rewind,image_model FROM member_capabilities WHERE member_id=?", (row["id"],)).fetchone()
|
|
2813
2823
|
member_view["rewind"], member_view["image_model"] = (reported[0], reported[1]) if reported else ("", "")
|
|
@@ -3584,7 +3594,7 @@ def interrupt_for_message(connection, room_id, message_id):
|
|
|
3584
3594
|
if blocked:
|
|
3585
3595
|
raise FileExistsError(Text("{value1} 正在执行且无法打断,这条消息继续排队,等它答完后发送", value1='、'.join(blocked)))
|
|
3586
3596
|
for row in busy:
|
|
3587
|
-
stop_member_work(connection, row["member_id"], Text("
|
|
3597
|
+
stop_member_work(connection, row["member_id"], Text("已打断:你立即发送了新消息,它会连同这条一起处理"), "user_stop", keep_pending=True, requeue=True)
|
|
3588
3598
|
if busy:
|
|
3589
3599
|
settle_batches(connection, room_id)
|
|
3590
3600
|
|
package/backend/message_queue.py
CHANGED
|
@@ -25,8 +25,13 @@ def queueing_enabled(connection):
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
def room_busy(connection, room_id):
|
|
28
|
-
"""A member still has an open request, a one-after-another turn waits, or a discussion runs.
|
|
29
|
-
|
|
28
|
+
"""A member still has an open request, a one-after-another turn waits, or a discussion runs.
|
|
29
|
+
|
|
30
|
+
Work the host left running in the background (sent without a handoff, or kept working beside it, as in
|
|
31
|
+
free_room.BACKGROUND_SQL) does not hold the owner's messages: the room goes on without waiting for it."""
|
|
32
|
+
return connection.execute("""SELECT 1 FROM member_requests r WHERE r.room_id=? AND r.status IN ('pending','delivering')
|
|
33
|
+
AND NOT (r.purpose='ask' AND r.created_by='host' AND (r.batch_id=0 OR EXISTS(
|
|
34
|
+
SELECT 1 FROM member_requests k WHERE k.message_id=r.message_id AND k.purpose='keep_working')))
|
|
30
35
|
UNION ALL SELECT 1 FROM free_queue_waiting WHERE room_id=?
|
|
31
36
|
UNION ALL SELECT 1 FROM discussion_sessions WHERE room_id=? AND status='active' LIMIT 1""",
|
|
32
37
|
(room_id, room_id, room_id)).fetchone() is not None
|
|
@@ -534,7 +534,7 @@
|
|
|
534
534
|
"用户取消讨论安排": "The user cancelled the discussion plan.",
|
|
535
535
|
"评审未投递:{reason}": "Review was not delivered: {reason}",
|
|
536
536
|
"专家 {name} 的讨论请求失败:{reason}。请决定跳过、重排或暂停。": "The discussion request for expert {name} failed: {reason}. Decide whether to skip, reorder, or pause.",
|
|
537
|
-
"
|
|
537
|
+
"已打断:你立即发送了新消息,它会连同这条一起处理": "Interrupted: you sent a new message right away; it takes this one up again together with it",
|
|
538
538
|
"成员已离开": "The member left.",
|
|
539
539
|
"成员已移除": "The member was removed.",
|
|
540
540
|
"主持人已更换": "The host changed.",
|
|
@@ -747,5 +747,7 @@
|
|
|
747
747
|
"这个会话的末尾没有可显示的对话。": "The end of this session has no messages to show.",
|
|
748
748
|
"正在读取会话预览…": "Loading the session preview…",
|
|
749
749
|
"在左侧选择一个会话查看预览。": "Select a session on the left to preview it.",
|
|
750
|
-
"接入此会话": "Resume this session"
|
|
750
|
+
"接入此会话": "Resume this session",
|
|
751
|
+
"额度已用尽,预计 {value1} 恢复;给它发新消息会立即再试": "Out of quota, expected back at {value1}; a new message to it is tried at once",
|
|
752
|
+
"保存(Enter)": "Save (Enter)"
|
|
751
753
|
}
|
package/package.json
CHANGED
package/web/app.js
CHANGED
|
@@ -1071,7 +1071,10 @@ async function refresh_room_content(room_id, version, versions) {
|
|
|
1071
1071
|
cache_room_entry(room_views, room_id, room);
|
|
1072
1072
|
state.room = merge_room_folder(room, versions.folder, versions.archive, versions.directory);
|
|
1073
1073
|
render_room();
|
|
1074
|
-
|
|
1074
|
+
// With a transcript already shown, the new room state waits for the new transcript and both show in one snapshot:
|
|
1075
|
+
// the room's requests and working cards laid out against the old messages, then again against the new ones, made
|
|
1076
|
+
// the page collapse and refill for a moment after every send. A room opened for the first time shows at once.
|
|
1077
|
+
if (!history_read || !state.messages.length) publish_view();
|
|
1075
1078
|
load_room_models();
|
|
1076
1079
|
});
|
|
1077
1080
|
const history_read = state.tab === "discussion" ? load_message_history(room_id, version).then((result) => {
|
|
@@ -1082,6 +1085,7 @@ async function refresh_room_content(room_id, version, versions) {
|
|
|
1082
1085
|
if (history_read && !state.messages.length && state.message_history?.key !== history_key) { state.messages_loading = true; publish_view(); }
|
|
1083
1086
|
try {
|
|
1084
1087
|
await Promise.all([room_read, history_read]);
|
|
1088
|
+
if (current()) publish_view();
|
|
1085
1089
|
} catch (error) {
|
|
1086
1090
|
if (current()) { state.messages_loading = false; state.messages_failure = error.message; publish_view(); }
|
|
1087
1091
|
throw error;
|
|
@@ -1779,14 +1783,21 @@ async function finish_message(result, room_id, drafts) {
|
|
|
1779
1783
|
element("search-input").value = "";
|
|
1780
1784
|
element("mention-filter").setAttribute("aria-pressed", "false");
|
|
1781
1785
|
state.page = 1;
|
|
1782
|
-
|
|
1783
|
-
//
|
|
1784
|
-
//
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1786
|
+
// The sending card stays, now showing the saved number, until the room is read again: the saved card then takes its
|
|
1787
|
+
// place in the same render as the room's other changes (its request, the host's working card). Swapping it in first
|
|
1788
|
+
// and the rest a moment later laid the transcript out twice, and on a phone the page jumped and flashed in between.
|
|
1789
|
+
const saved_id = result.message.id;
|
|
1790
|
+
if (state.sending_preview) state.sending_preview = { ...state.sending_preview, saved_id };
|
|
1791
|
+
publish_view();
|
|
1792
|
+
refresh_room().catch(() => {}).finally(() => {
|
|
1793
|
+
if (state.sending_preview?.saved_id !== saved_id) return;
|
|
1794
|
+
release_files(state.sending_preview.release || []);
|
|
1795
|
+
state.sending_preview = null;
|
|
1796
|
+
if (state.room?.id === room_id && !state.messages.some(message => message.id === saved_id)) {
|
|
1797
|
+
render_messages({ messages: [...state.messages, { ...result.message, just_sent: true }], total: state.message_total + 1, page: 1, pages: 1 });
|
|
1798
|
+
}
|
|
1799
|
+
publish_view();
|
|
1800
|
+
});
|
|
1790
1801
|
}
|
|
1791
1802
|
|
|
1792
1803
|
/** A message the site queued: clear the composer; it waits above the composer until the room is idle. */
|
|
@@ -1924,7 +1935,8 @@ async function send_message(event) {
|
|
|
1924
1935
|
const only_host = named.size === 1 && (state.room.free?.members || []).some(member => named.has(member.name) && member.role === "host" && member.status === "active");
|
|
1925
1936
|
const likely_queued = payload.queue && !only_host && (queue?.busy || queue?.items?.length);
|
|
1926
1937
|
state.sending_preview = likely_queued ? null : preview;
|
|
1927
|
-
|
|
1938
|
+
// The rows already queued, so the first snapshot listing a new one swaps it in for this row (see publish_view).
|
|
1939
|
+
state.queueing_preview = likely_queued ? { ...preview, queued_ids: (queue.items || []).map(item => item.id) } : null;
|
|
1928
1940
|
let sent;
|
|
1929
1941
|
state.sending_done = new Promise(resolve => { sent = resolve; });
|
|
1930
1942
|
publish_view();
|
|
@@ -1952,11 +1964,14 @@ async function send_message(event) {
|
|
|
1952
1964
|
throw error;
|
|
1953
1965
|
} finally {
|
|
1954
1966
|
state.sending_message = false;
|
|
1967
|
+
// A saved message's card stays until the saved card replaces it (finish_message), and keeps its file previews till then.
|
|
1968
|
+
const kept = saved && state.sending_preview?.saved_id ? state.sending_preview : null;
|
|
1969
|
+
if (kept) kept.release = drafts;
|
|
1955
1970
|
// Previews of files not kept by a failed card are no longer shown anywhere.
|
|
1956
|
-
if (!state.failed_sends.some((failed) => failed.drafts === drafts)) release_files(drafts);
|
|
1971
|
+
else if (!state.failed_sends.some((failed) => failed.drafts === drafts)) release_files(drafts);
|
|
1957
1972
|
if (state.sending_drafts === drafts) state.sending_drafts = null;
|
|
1958
1973
|
sent(saved);
|
|
1959
|
-
state.sending_preview = null;
|
|
1974
|
+
if (!kept) state.sending_preview = null;
|
|
1960
1975
|
state.queueing_preview = null;
|
|
1961
1976
|
state.upload_status = "";
|
|
1962
1977
|
element("send-message").disabled = false;
|
|
@@ -5450,6 +5465,15 @@ async function initialize() {
|
|
|
5450
5465
|
|
|
5451
5466
|
/** Publish a presentation snapshot shared by the legacy and Vue renderers. */
|
|
5452
5467
|
function publish_view() {
|
|
5468
|
+
// A sent message's card gives way in the same snapshot that first holds the saved message.
|
|
5469
|
+
if (state.sending_preview?.saved_id && state.messages.some(message => message.id === state.sending_preview.saved_id)) {
|
|
5470
|
+
release_files(state.sending_preview.release || []);
|
|
5471
|
+
state.sending_preview = null;
|
|
5472
|
+
}
|
|
5473
|
+
// Likewise a queued message's row gives way in the first snapshot listing it in the queue: a room refresh started by
|
|
5474
|
+
// a live update can bring it before the site's answer to the send, and both rows showed until that answer came.
|
|
5475
|
+
const queueing = state.queueing_preview;
|
|
5476
|
+
if (queueing && state.room?.free?.queued_messages?.items?.some(item => !queueing.queued_ids.includes(item.id))) state.queueing_preview = null;
|
|
5453
5477
|
document.dispatchEvent(new CustomEvent("discuss:view"));
|
|
5454
5478
|
}
|
|
5455
5479
|
|