ai_co_discuss 0.4.21 → 0.4.22
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/package.json +1 -1
- package/web/app.js +13 -10
- package/web/modern.css +1 -1
- package/web/modern.js +51 -51
package/package.json
CHANGED
package/web/app.js
CHANGED
|
@@ -1055,6 +1055,7 @@ async function select_room(room_id) {
|
|
|
1055
1055
|
state.context_dirty = false;
|
|
1056
1056
|
state.topic_dirty = false;
|
|
1057
1057
|
state.pending_submission = null;
|
|
1058
|
+
state.sending_drafts = null;
|
|
1058
1059
|
clear_attachment_drafts();
|
|
1059
1060
|
state.launch.repair = null;
|
|
1060
1061
|
state.launch.room_models = null;
|
|
@@ -1614,10 +1615,9 @@ async function invite_member({ name, access, project_access = "read", session_id
|
|
|
1614
1615
|
/** Clear only the composer that produced the saved message. */
|
|
1615
1616
|
async function finish_message(result, room_id, drafts) {
|
|
1616
1617
|
show_toast(`留言已保存 · #${result.message.id}`);
|
|
1617
|
-
if (state.room?.id !== room_id || state.
|
|
1618
|
+
if (state.room?.id !== room_id || state.sending_drafts !== drafts) return;
|
|
1618
1619
|
// The composer was emptied on send; what is in it now was typed since and stays.
|
|
1619
1620
|
state.pending_submission = null;
|
|
1620
|
-
clear_attachment_drafts();
|
|
1621
1621
|
cancel_reply();
|
|
1622
1622
|
state.query = "";
|
|
1623
1623
|
state.mention_only = false;
|
|
@@ -1639,9 +1639,8 @@ async function finish_message(result, room_id, drafts) {
|
|
|
1639
1639
|
|
|
1640
1640
|
/** A message the site queued: clear the composer; it waits above the composer until the room is idle. */
|
|
1641
1641
|
async function finish_queued(result, room_id, drafts) {
|
|
1642
|
-
if (state.room?.id !== room_id || state.
|
|
1642
|
+
if (state.room?.id !== room_id || state.sending_drafts !== drafts) return;
|
|
1643
1643
|
state.pending_submission = null;
|
|
1644
|
-
clear_attachment_drafts();
|
|
1645
1644
|
cancel_reply();
|
|
1646
1645
|
state.sending_preview = null;
|
|
1647
1646
|
if (state.room.free) state.room = { ...state.room, free: { ...state.room.free, queued_messages: result.queue } };
|
|
@@ -1737,6 +1736,9 @@ async function send_message(event) {
|
|
|
1737
1736
|
const draft = element("message-input").value;
|
|
1738
1737
|
element("message-input").value = "";
|
|
1739
1738
|
const preview = { author: payload.author, text: payload.text, created_at: new Date().toISOString(), files: drafts.map(file => file.file.name) };
|
|
1739
|
+
// The files leave with it and upload in the background; a failed send puts them back too.
|
|
1740
|
+
state.sending_drafts = drafts;
|
|
1741
|
+
state.attachment_drafts = [];
|
|
1740
1742
|
// A message the site will likely queue skips the in-transcript card, which would flash before moving above the composer.
|
|
1741
1743
|
const queue = state.room.free?.queued_messages;
|
|
1742
1744
|
const likely_queued = payload.queue && (queue?.busy || queue?.items?.length);
|
|
@@ -1759,11 +1761,15 @@ async function send_message(event) {
|
|
|
1759
1761
|
// Anything typed meanwhile follows the restored draft, so neither is lost.
|
|
1760
1762
|
const typed = element("message-input").value;
|
|
1761
1763
|
element("message-input").value = typed.trim() ? `${draft}\n\n${typed}` : draft;
|
|
1764
|
+
if (state.sending_drafts === drafts) state.attachment_drafts = [...drafts, ...state.attachment_drafts];
|
|
1762
1765
|
error.notified = true;
|
|
1763
1766
|
}
|
|
1764
1767
|
throw error;
|
|
1765
1768
|
} finally {
|
|
1766
1769
|
state.sending_message = false;
|
|
1770
|
+
// Previews of files not put back into the composer are no longer shown anywhere.
|
|
1771
|
+
if (!state.attachment_drafts.includes(drafts[0])) for (const file of drafts) if (file.preview_url) URL.revokeObjectURL(file.preview_url);
|
|
1772
|
+
if (state.sending_drafts === drafts) state.sending_drafts = null;
|
|
1767
1773
|
sent();
|
|
1768
1774
|
if (!state.sending_preview?.failed) state.sending_preview = null;
|
|
1769
1775
|
state.upload_status = "";
|
|
@@ -1816,7 +1822,7 @@ function attachment_file_icon(file_name) {
|
|
|
1816
1822
|
|
|
1817
1823
|
/** Keep original files in memory until sending; reject an invalid selection as a whole. */
|
|
1818
1824
|
function add_attachments(files) {
|
|
1819
|
-
if (!state.room
|
|
1825
|
+
if (!state.room) return;
|
|
1820
1826
|
const selected = Array.from(files);
|
|
1821
1827
|
if (state.attachment_drafts.length + selected.length > MAX_MESSAGE_ATTACHMENTS) notify("warning", "每条消息最多 10 个附件");
|
|
1822
1828
|
else if (selected.some(file => file.size > MAX_ATTACHMENT_BYTES)) notify("warning", "单个附件最多 20 MiB");
|
|
@@ -1835,7 +1841,6 @@ function clear_attachment_drafts() {
|
|
|
1835
1841
|
|
|
1836
1842
|
/** Remove one unsent file without disturbing the text draft. */
|
|
1837
1843
|
function remove_attachment(id) {
|
|
1838
|
-
if (state.sending_message) return;
|
|
1839
1844
|
const file = state.attachment_drafts.find(item => item.id === id);
|
|
1840
1845
|
if (file?.preview_url) URL.revokeObjectURL(file.preview_url);
|
|
1841
1846
|
state.attachment_drafts = state.attachment_drafts.filter(item => item.id !== id);
|
|
@@ -1849,9 +1854,8 @@ function render_attachment_drafts() {
|
|
|
1849
1854
|
if (!container) return;
|
|
1850
1855
|
container.innerHTML = state.attachment_drafts.map(item => `<div class="attachment-draft">${item.preview_url ? `<img src="${item.preview_url}" alt="">` : ""}
|
|
1851
1856
|
<span>${escape_html(item.file.name)}<small>${attachment_size(item.file.size)}</small></span>
|
|
1852
|
-
<button type="button" data-remove-attachment="${item.id}" aria-label="移除 ${escape_html(item.file.name)}"
|
|
1857
|
+
<button type="button" data-remove-attachment="${item.id}" aria-label="移除 ${escape_html(item.file.name)}">×</button></div>`).join("");
|
|
1853
1858
|
element("attachment-status").textContent = state.upload_status;
|
|
1854
|
-
element("choose-attachments").disabled = state.sending_message;
|
|
1855
1859
|
}
|
|
1856
1860
|
|
|
1857
1861
|
/** Upload once per actual uploader, retaining receipts across ambiguous send failures. */
|
|
@@ -4960,8 +4964,7 @@ function view_snapshot() {
|
|
|
4960
4964
|
archive_pending: [...state.archive_changes.keys()], import_progress: structuredClone(state.import_progress),
|
|
4961
4965
|
directory_pending: [...state.directory_pending.keys()], folder_pending: [...state.folder_moves.keys()], creating_room: state.creating_room,
|
|
4962
4966
|
connected: state.connected, reconnecting: state.reconnecting, observed_until: state.observed_until, backup_pending: Boolean(state.backup_pending), page: state.page, pages: state.pages, query: state.query,
|
|
4963
|
-
attachment_drafts: state.attachment_drafts.map(item => ({ id: item.id, file_name: item.file.name, size: item.file.size, preview_url: item.preview_url,
|
|
4964
|
-
uploading: state.sending_message && !item.uploaded })),
|
|
4967
|
+
attachment_drafts: state.attachment_drafts.map(item => ({ id: item.id, file_name: item.file.name, size: item.file.size, preview_url: item.preview_url })),
|
|
4965
4968
|
upload_status: state.upload_status, sending_message: state.sending_message, sending_preview: state.sending_preview,
|
|
4966
4969
|
mention_only: state.mention_only, host_only: state.host_only, authors: state.authors, card_kinds: state.card_kinds,
|
|
4967
4970
|
source_filter: state.mention_only || state.host_only || state.authors.length > 0 || state.card_kinds.length > 0, messages_loading: Boolean(state.messages_loading), messages_failure: state.messages_failure || "", reply_to: state.reply_to, editing_queued: state.editing_queued?.id ?? null,
|