优化目录候选文件名显示并重新打包

This commit is contained in:
shiyue
2026-09-11 13:56:43 +08:00
parent b8fcc12229
commit 965aefe9a4
6 changed files with 371 additions and 14 deletions

View File

@@ -11556,6 +11556,30 @@
};
}
function getComposerFileSuggestionDisplay(item) {
const rawName = String(item?.name || item?.label || item?.insertion || '').trim();
const normalizedName = rawName
.replace(/^@/, '')
.replace(/\\/g, '/')
.replace(/\/+$/, '');
const segments = normalizedName.split('/').filter(Boolean);
const basename = segments.pop() || normalizedName || rawName;
const parentPath = segments.join('/');
const isDirectory = item?.itemType === 'directory';
const primaryText = `${basename}${isDirectory ? '/' : ''}`;
const parentLabel = parentPath ? `@${parentPath}/` : '';
const fallbackDescription = String(item?.description || '').trim();
const secondaryText = [parentLabel, parentLabel ? '' : fallbackDescription]
.filter(Boolean)
.join(' · ')
|| fallbackDescription;
return {
primaryText,
secondaryText,
fullPath: String(item?.label || item?.insertion || rawName).trim(),
};
}
function showCmdMenu(token, items) {
const safeItems = Array.isArray(items) ? items : [];
if (!token || safeItems.length === 0) {
@@ -11565,6 +11589,8 @@
activeComposerToken = token;
cmdMenuIndex = 0;
cmdMenu.innerHTML = safeItems.map((item, i) => {
const isFileSuggestion = item.kind === 'file';
const fileDisplay = isFileSuggestion ? getComposerFileSuggestionDisplay(item) : null;
const kindLabel = item.kind === 'skill'
? 'Skill'
: item.kind === 'prompt'
@@ -11574,11 +11600,14 @@
: item.kind === 'mcp'
? 'MCP'
: 'Cmd';
return `<div class="cmd-item${i === 0 ? ' active' : ''}" data-index="${i}">
const primaryText = fileDisplay?.primaryText || item.label || item.name || item.insertion || '';
const secondaryText = fileDisplay?.secondaryText || item.description || item.title || '';
const fullPathTitle = fileDisplay?.fullPath ? ` title="${escapeHtmlAttr(fileDisplay.fullPath)}"` : '';
return `<div class="cmd-item${i === 0 ? ' active' : ''}${isFileSuggestion ? ' file-suggestion' : ''}" data-index="${i}"${fullPathTitle}>
<span class="cmd-item-kind">${kindLabel}</span>
<span class="cmd-item-main">
<span class="cmd-item-cmd">${escapeHtml(item.label || item.name || item.insertion || '')}</span>
<span class="cmd-item-desc">${escapeHtml(item.description || item.title || '')}</span>
<span class="cmd-item-cmd">${escapeHtml(primaryText)}</span>
<span class="cmd-item-desc">${escapeHtml(secondaryText)}</span>
</span>
</div>`;
}).join('');

View File

@@ -23,7 +23,7 @@
document.documentElement.dataset.dividerTime = dividerTime;
})();
</script>
<link rel="stylesheet" href="style.css?v=20260818-goal-mode-label">
<link rel="stylesheet" href="style.css?v=20260911-file-suggestion">
<link rel="stylesheet" href="task-board.css?v=__CC_WEB_FRONTEND_ASSET_VERSION__">
<link rel="stylesheet" href="gitea-workflow.css?v=__CC_WEB_GITEA_WORKFLOW_ASSET_VERSION__">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/atom-one-dark.min.css">

View File

@@ -4425,8 +4425,9 @@ html[data-divider-time='hide'] .msg-bubble .agent-message-divider span {
border-radius: 12px;
box-shadow: 0 4px 20px rgba(45, 31, 20, 0.12);
padding: 6px;
min-width: 240px;
max-width: 320px;
width: min(560px, calc(100vw - 32px));
min-width: min(240px, calc(100vw - 32px));
max-width: none;
max-height: min(52vh, 360px);
overflow-y: auto;
overscroll-behavior: contain;
@@ -4486,6 +4487,23 @@ html[data-divider-time='hide'] .msg-bubble .agent-message-divider span {
text-overflow: ellipsis;
white-space: nowrap;
}
.cmd-item.file-suggestion .cmd-item-cmd {
color: var(--text-primary);
overflow: visible;
text-overflow: clip;
white-space: normal;
overflow-wrap: anywhere;
line-height: 1.35;
}
.cmd-item.file-suggestion .cmd-item-desc {
color: var(--text-muted);
font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
font-size: 12px;
white-space: normal;
overflow-wrap: anywhere;
line-height: 1.35;
max-height: 2.7em;
}
/* === Input Area === */
.input-area {
@@ -4932,7 +4950,7 @@ html[data-divider-time='hide'] .msg-bubble .agent-message-divider span {
gap: 10px;
}
.session-item-actions { display: flex; }
.cmd-menu { left: 10px; right: 10px; transform: none; min-width: auto; bottom: 72px; }
.cmd-menu { left: 10px; right: 10px; transform: none; width: auto; min-width: auto; bottom: 72px; }
.option-picker { left: 10px; right: 10px; transform: none; min-width: auto; bottom: 72px; }
.chat-header {
padding: 0 10px;