[feat]:增加rename会话的功能

This commit is contained in:
yiqi-017 committed 2026-05-27 21:36:07 +08:00
1 parent a860cf2d82
commit 6fcdc7f2af
3 files changed
+52 -7

No files matched your search

+41 -5
View File
@@ -233,7 +233,7 @@ const I18N = {
'preset.add.t': '自定义', 'preset.add.d': '任意一句话存为功能',
'composer.placeholder': '输入消息… (Enter 发送, Shift+Enter 换行)',
'search.placeholder': '搜索会话…', 'conv.new': '新对话',
'ctx.pin': '置顶', 'ctx.unpin': '取消置顶', 'ctx.del': '删除',
'ctx.pin': '置顶', 'ctx.unpin': '取消置顶', 'ctx.rename': '重命名', 'ctx.del': '删除',
'common.close': '关闭', 'common.more': '更多', 'common.optional': '选填', 'common.save': '保存',
'modal.preset': '预设功能', 'modal.addModel': '添加模型', 'modal.editModel': '编辑模型', 'modal.settings': '配置',
'modal.customPreset': '自定义预设',
@@ -378,7 +378,7 @@ const I18N = {
'preset.add.t': 'Custom', 'preset.add.d': 'Save any prompt as a function',
'composer.placeholder': 'Type a message… (Enter to send, Shift+Enter for newline)',
'search.placeholder': 'Search chats…', 'conv.new': 'New chat',
'ctx.pin': 'Pin', 'ctx.unpin': 'Unpin', 'ctx.del': 'Delete',
'ctx.pin': 'Pin', 'ctx.unpin': 'Unpin', 'ctx.rename': 'Rename', 'ctx.del': 'Delete',
'common.close': 'Close', 'common.more': 'More', 'common.optional': 'Optional', 'common.save': 'Save',
'modal.preset': 'Presets', 'modal.addModel': 'Add model', 'modal.editModel': 'Edit model', 'modal.settings': 'Settings',
'modal.customPreset': 'Custom preset',
@@ -1692,6 +1692,42 @@ convMenu.addEventListener('click', (e) => {
saveSessions();
patchSession(sess, { pinned: sess.pinned });
renderSessionList();
} else if (sess && act === 'rename') {
convMenu.hidden = true;
const item = convListEl.querySelector(`.conv-item[data-id="${sess.id}"]`);
if (!item) return;
const titleEl = item.querySelector('.ci-title');
if (!titleEl) return;
const oldTitle = sess.title || '';
const inp = document.createElement('input');
inp.className = 'ci-rename-input';
inp.value = oldTitle;
titleEl.replaceWith(inp);
inp.focus();
inp.select();
const finish = (save) => {
if (inp._done) return;
inp._done = true;
const val = inp.value.trim();
if (save && val && val !== oldTitle) {
sess.title = val;
sess.untitled = false;
saveSessions();
patchSession(sess, { title: val, untitled: false });
const history = tokLoadHistory();
const sid = sess.bridgeSessionId || sess.id;
let changed = false;
history.forEach(h => { if (h.sessionId === sid) { h.title = val; changed = true; } });
if (changed) tokSaveHistory(history);
}
renderSessionList();
};
inp.addEventListener('keydown', e => {
if (e.key === 'Enter') { e.preventDefault(); finish(true); }
else if (e.key === 'Escape') { e.preventDefault(); finish(false); }
});
inp.addEventListener('blur', () => finish(true));
return;
} else if (sess && act === 'del') {
closeSession(sess.id);
}
@@ -3463,14 +3499,14 @@ window.ga.startBridge && window.ga.startBridge();
cardMenu.className = 'ctx-menu';
cardMenu.style.left = x + 'px';
cardMenu.style.top = y + 'px';
cardMenu.innerHTML = '<div class="ctx-item danger"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><path d="M10 11v6"/><path d="M14 11v6"/></svg>删除</div>';
cardMenu.querySelector('.ctx-item').onmousedown = (e) => {
cardMenu.innerHTML = `<div class="ctx-item danger"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><path d="M10 11v6"/><path d="M14 11v6"/></svg>${esc(t('ctx.del'))}</div>`;
cardMenu.querySelector('.ctx-item').onclick = (e) => {
e.stopPropagation();
fetch(`http://${location.hostname}:8900/subagent/${sid}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ action: 'kill' }) });
hideCardMenu();
};
document.body.appendChild(cardMenu);
setTimeout(() => document.addEventListener('mousedown', hideCardMenu, { once: true }), 0);
setTimeout(() => document.addEventListener('mousedown', (e) => { if (!cardMenu?.contains(e.target)) hideCardMenu(); }, { once: true }), 0);
}
let drawerEl = null;
+6 -2
View File
@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<title>GenericAgent</title>
<link rel="stylesheet" href="styles.css?v=72">
<link rel="stylesheet" href="styles.css?v=73">
<!-- KaTeX: LaTeX 公式渲染 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css" crossorigin="anonymous">
<!-- highlight.js: 代码高亮 -->
@@ -299,6 +299,10 @@
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="17" x2="12" y2="22"/><path d="M9 4h6l-1 6 3 3v2H7v-2l3-3-1-6z"/></svg>
<span data-i18n="ctx.pin"></span>
</div>
<div class="ctx-item" data-act="rename">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"/></svg>
<span data-i18n="ctx.rename"></span>
</div>
<div class="ctx-item danger" data-act="del">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>
<span data-i18n="ctx.del"></span>
@@ -508,7 +512,7 @@
<script src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.js" crossorigin="anonymous"></script>
<!-- highlight.js -->
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/highlight.min.js" crossorigin="anonymous"></script>
<script src="app.js?v=43"></script>
<script src="app.js?v=44"></script>
<script src="annot.js"></script><!-- DEV 脚手架,可删 -->
</body>
</html>
+5
View File
@@ -901,6 +901,11 @@ html[data-boot-has-sessions] .chat-start{ display:none !important; }
.conv-item.idle .ci-dot{ background:var(--dot-idle); }
.ci-main{ flex:1; min-width:0; }
.ci-title{ font-size:13px; font-weight:600; color:var(--txt-strong); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.ci-rename-input{
font-size:13px; font-weight:600; color:var(--txt-strong); width:100%;
border:1px solid var(--blue); border-radius:4px; padding:1px 4px;
background:var(--field-bg); outline:none;
}
.ci-pin{ width:14px; height:14px; color:var(--blue); margin-right:3px; vertical-align:-3px; flex:0 0 auto; display:inline-block; transform:rotate(45deg); transform-origin:50% 50%; }
.ci-meta{ font-size:11px; color:var(--muted); margin-top:2px; }
.ci-more{