fix: keep compression toast persistent and align summary layout
This commit is contained in:
parent
bc939a0098
commit
b29e6a67f8
@ -130,7 +130,15 @@ async def _generate_summary(web_terminal, prompt: str, retries: int = 5) -> Tupl
|
||||
return f"生成总结失败({last_reason or '未知原因'})", last_reason
|
||||
|
||||
|
||||
def _write_compact_file(project_path: Path, *, compression_index: int, summary_text: str, user_inputs: List[str], last_tools: List[Dict[str, Any]]) -> str:
|
||||
def _write_compact_file(
|
||||
project_path: Path,
|
||||
*,
|
||||
compression_index: int,
|
||||
summary_text: str,
|
||||
user_inputs: List[str],
|
||||
last_tools: List[Dict[str, Any]],
|
||||
latest_user_input: str,
|
||||
) -> str:
|
||||
compact_dir = project_path / "compact_result"
|
||||
compact_dir.mkdir(parents=True, exist_ok=True)
|
||||
filename = f"compact_{datetime.now().strftime('%Y%m%d_%H%M%S')}_{compression_index:03d}.md"
|
||||
@ -166,6 +174,11 @@ def _write_compact_file(project_path: Path, *, compression_index: int, summary_t
|
||||
])
|
||||
else:
|
||||
lines.append("- (无)")
|
||||
lines.extend(["", "## 用户最新的一次输入"])
|
||||
if (latest_user_input or "").strip():
|
||||
lines.append(latest_user_input.strip())
|
||||
else:
|
||||
lines.append("(无)")
|
||||
file_path.write_text("\n".join(lines).strip() + "\n", encoding="utf-8")
|
||||
return str(file_path.relative_to(project_path))
|
||||
|
||||
@ -226,6 +239,7 @@ async def run_deep_compression(
|
||||
|
||||
messages = conv_data.get("messages") or []
|
||||
user_inputs = _collect_user_texts(messages)
|
||||
latest_user_input = user_inputs[-1] if user_inputs else ""
|
||||
last_tools = _collect_last_tool_entries(messages, limit=5, max_content_chars=3000)
|
||||
relative_compact_path = _write_compact_file(
|
||||
Path(workspace.project_path),
|
||||
@ -233,6 +247,7 @@ async def run_deep_compression(
|
||||
summary_text=summary_text,
|
||||
user_inputs=user_inputs,
|
||||
last_tools=last_tools,
|
||||
latest_user_input=latest_user_input,
|
||||
)
|
||||
|
||||
cm.set_compression_state(
|
||||
|
||||
@ -235,6 +235,10 @@ export const conversationMethods = {
|
||||
this.compressing = false;
|
||||
this.compressionMode = '';
|
||||
this.compressionStage = '';
|
||||
if (this.compressionToastId) {
|
||||
this.uiDismissToast(this.compressionToastId);
|
||||
this.compressionToastId = null;
|
||||
}
|
||||
}
|
||||
|
||||
// 应用个性化设置中的默认模型和思考模式
|
||||
@ -400,6 +404,10 @@ export const conversationMethods = {
|
||||
this.compressing = false;
|
||||
this.compressionMode = '';
|
||||
this.compressionStage = '';
|
||||
if (this.compressionToastId) {
|
||||
this.uiDismissToast(this.compressionToastId);
|
||||
this.compressionToastId = null;
|
||||
}
|
||||
}
|
||||
|
||||
debugLog('创建新对话...');
|
||||
|
||||
@ -456,11 +456,16 @@ export const messageMethods = {
|
||||
this.compressionMode = 'manual';
|
||||
this.compressionStage = 'requesting';
|
||||
this.compressionError = '';
|
||||
this.uiPushToast({
|
||||
if (this.compressionToastId) {
|
||||
this.uiDismissToast(this.compressionToastId);
|
||||
this.compressionToastId = null;
|
||||
}
|
||||
this.compressionToastId = this.uiPushToast({
|
||||
title: '压缩中',
|
||||
message: '对话正在压缩,请稍候…',
|
||||
type: 'info',
|
||||
duration: 2500
|
||||
duration: null,
|
||||
closable: false
|
||||
});
|
||||
|
||||
try {
|
||||
@ -526,6 +531,10 @@ export const messageMethods = {
|
||||
type: 'error'
|
||||
});
|
||||
} finally {
|
||||
if (this.compressionToastId) {
|
||||
this.uiDismissToast(this.compressionToastId);
|
||||
this.compressionToastId = null;
|
||||
}
|
||||
this.compressing = false;
|
||||
this.compressionInProgress = false;
|
||||
this.compressionMode = '';
|
||||
|
||||
@ -946,19 +946,32 @@ export const taskPollingMethods = {
|
||||
this.compressionStage = data.stage || '';
|
||||
if (this.compressionInProgress && !wasInProgress) {
|
||||
const modeLabel = this.compressionMode === 'manual' ? '手动' : '自动';
|
||||
this.uiPushToast({
|
||||
if (this.compressionToastId) {
|
||||
this.uiDismissToast(this.compressionToastId);
|
||||
this.compressionToastId = null;
|
||||
}
|
||||
this.compressionToastId = this.uiPushToast({
|
||||
title: '压缩中',
|
||||
message: `对话正在${modeLabel}压缩,请稍候…`,
|
||||
type: 'info',
|
||||
duration: 2600
|
||||
duration: null,
|
||||
closable: false
|
||||
});
|
||||
}
|
||||
if (!this.compressionInProgress) {
|
||||
this.compressionError = data.error || '';
|
||||
if (this.compressionToastId) {
|
||||
this.uiDismissToast(this.compressionToastId);
|
||||
this.compressionToastId = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
async handleCompressionFinished(data: any) {
|
||||
if (this.compressionToastId) {
|
||||
this.uiDismissToast(this.compressionToastId);
|
||||
this.compressionToastId = null;
|
||||
}
|
||||
this.compressionInProgress = false;
|
||||
this.compressionMode = '';
|
||||
this.compressionStage = '';
|
||||
|
||||
@ -44,6 +44,7 @@ export function dataState() {
|
||||
compressionMode: '',
|
||||
compressionStage: '',
|
||||
compressionError: '',
|
||||
compressionToastId: null,
|
||||
skipConversationLoadedEvent: false,
|
||||
skipConversationHistoryReload: false,
|
||||
_scrollListenerReady: false,
|
||||
|
||||
@ -607,6 +607,14 @@ watch(() => props.actions, () => {
|
||||
padding: 0 6px 0 6px;
|
||||
}
|
||||
|
||||
/* 桌面端与正式文本输出左边距保持一致(text-content: 0 20px 0 15px) */
|
||||
@media (min-width: 769px) {
|
||||
.summary-line-text,
|
||||
.steps-container {
|
||||
padding: 0 20px 0 15px;
|
||||
}
|
||||
}
|
||||
|
||||
.steps-wrapper {
|
||||
overflow: hidden;
|
||||
min-height: 0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user