Merge branch 'dev' into test

This commit is contained in:
sophie committed 2026-05-20 09:57:06 +08:00
commit 67c16b5121
3 files changed
+92 -11

No files matched your search

@@ -0,0 +1,71 @@
"""ensure agents table has primary key on id
Revision ID: f7a8b9c0d1e2
Revises: f6d4e5f6a7b8
Create Date: 2026-05-20 00:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
revision = 'f7a8b9c0d1e2'
down_revision = 'f6d4e5f6a7b8'
branch_labels = None
depends_on = None
def upgrade():
conn = op.get_bind()
inspector = sa.inspect(conn)
if 'agents' not in inspector.get_table_names():
return
pk = inspector.get_pk_constraint('agents') or {}
constrained_columns = pk.get('constrained_columns') or []
if constrained_columns:
return
duplicate_count = conn.execute(
sa.text(
"""
SELECT COUNT(*)
FROM (
SELECT id
FROM agents
GROUP BY id
HAVING COUNT(*) > 1
) t
"""
)
).scalar_one()
if duplicate_count > 0:
raise RuntimeError(
"Cannot add PRIMARY KEY to agents.id because duplicate id values exist. "
"Please deduplicate agents.id first, then rerun migration."
)
null_count = conn.execute(
sa.text("SELECT COUNT(*) FROM agents WHERE id IS NULL")
).scalar_one()
if null_count > 0:
raise RuntimeError(
"Cannot add PRIMARY KEY to agents.id because NULL id values exist. "
"Please fix NULL ids first, then rerun migration."
)
op.execute('ALTER TABLE agents ADD CONSTRAINT agents_pkey PRIMARY KEY (id)')
def downgrade():
conn = op.get_bind()
inspector = sa.inspect(conn)
if 'agents' not in inspector.get_table_names():
return
pk = inspector.get_pk_constraint('agents') or {}
pk_name = pk.get('name')
cols = pk.get('constrained_columns') or []
if pk_name == 'agents_pkey' and cols == ['id']:
op.drop_constraint('agents_pkey', 'agents', type_='primary')
@@ -0,0 +1,21 @@
"""merge heads after agents pk fix
Revision ID: f8b9c0d1e2f3
Revises: c0ae052bd24e, f7a8b9c0d1e2
Create Date: 2026-05-20 00:30:00.000000
"""
revision = 'f8b9c0d1e2f3'
down_revision = ('c0ae052bd24e', 'f7a8b9c0d1e2')
branch_labels = None
depends_on = None
def upgrade():
pass
def downgrade():
pass
-11
View File
@@ -1128,16 +1128,6 @@ const scrollChatToBottom = async () => {
});
};
const scrollToMessage = async (index: number) => {
await nextTick();
const container = chatScrollContainer.value;
if (!container) return;
const el = container.querySelector(`[data-msg-index="${index}"]`) as HTMLElement | null;
if (el) {
el.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
};
const scrollToUserQuestion = async () => {
if (scrollToBottomFrame !== null) {
window.cancelAnimationFrame(scrollToBottomFrame);
@@ -1308,7 +1298,6 @@ const handleSend = async (textOrEvent?: string | Event) => {
return;
}
const userMsgIndex = messages.value.length;
await sendMessage(content, agentId, selectedKb.value);
if (!conversationId.value && history.value.length === 0) {