AI 助手侧栏请求状态按状态着色
- 状态卡新增样式:未发起灰、进行中蓝、完成绿、失败红、已取消橙 - 新增 _apply_sidebar_request_tone(),状态更新时同步切换配色;取消状态以请求 phase 判定 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -788,6 +788,35 @@ QDialog#AiConsultDialog QLabel#AiConsultSideSubtitle {
|
||||
background-color: transparent;
|
||||
font-size: 13px;
|
||||
}
|
||||
QDialog#AiConsultDialog QLabel#AiConsultSideRequestStatus {
|
||||
color: #606163;
|
||||
background-color: #F7F7F7;
|
||||
border: 1px solid #EDEDEE;
|
||||
border-radius: 10px;
|
||||
padding: 10px 12px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
}
|
||||
QDialog#AiConsultDialog QLabel#AiConsultSideRequestStatus[tone="running"] {
|
||||
color: #3347B8;
|
||||
background-color: #EEF1FA;
|
||||
border-color: #C9D1F3;
|
||||
}
|
||||
QDialog#AiConsultDialog QLabel#AiConsultSideRequestStatus[tone="done"] {
|
||||
color: #1F7A4D;
|
||||
background-color: #EAF7F0;
|
||||
border-color: #BFE6D0;
|
||||
}
|
||||
QDialog#AiConsultDialog QLabel#AiConsultSideRequestStatus[tone="failed"] {
|
||||
color: #B42318;
|
||||
background-color: #FFF1F3;
|
||||
border-color: #F5C2C7;
|
||||
}
|
||||
QDialog#AiConsultDialog QLabel#AiConsultSideRequestStatus[tone="cancelled"] {
|
||||
color: #9A5B00;
|
||||
background-color: #FFF7E6;
|
||||
border-color: #F5D9A8;
|
||||
}
|
||||
QDialog#AiConsultDialog QPushButton#AiConsultSideClose {
|
||||
min-width: 28px;
|
||||
max-width: 28px;
|
||||
@@ -7409,6 +7438,27 @@ class AiConsultDialog(QDialog):
|
||||
self.side_request_status.setProperty("diagnosisId", self.diagnosis_id)
|
||||
self.side_request_status.setProperty("task", self._stream_task)
|
||||
self.side_request_status.setProperty("requestId", self._sidebar_request_id)
|
||||
self._apply_sidebar_request_tone(self._sidebar_request_state)
|
||||
|
||||
def _apply_sidebar_request_tone(self, state: str, tone: str = "") -> None:
|
||||
"""按请求状态给侧栏状态卡配色:进行中蓝、完成绿、失败红、取消橙、未发起灰。"""
|
||||
if not tone:
|
||||
if state.startswith("本次请求失败"):
|
||||
tone = "failed"
|
||||
elif self._stream_meta.get("phase") == "cancelled" or "取消" in state or "停止" in state:
|
||||
tone = "cancelled"
|
||||
elif "已完整显示" in state:
|
||||
tone = "done"
|
||||
elif self._stream_started_at is not None and self._stream_ended_at is None:
|
||||
tone = "running"
|
||||
else:
|
||||
tone = "idle"
|
||||
label = self.side_request_status
|
||||
if label.property("tone") == tone:
|
||||
return
|
||||
label.setProperty("tone", tone)
|
||||
label.style().unpolish(label)
|
||||
label.style().polish(label)
|
||||
|
||||
def _stream_cancel_result(self, generation: int, diagnosis_id: int, bubble: Any, worker: _AiStreamWorker, result: Any) -> None:
|
||||
if self._session_closed or generation != self._generation or diagnosis_id != self.diagnosis_id:
|
||||
@@ -7429,6 +7479,7 @@ class AiConsultDialog(QDialog):
|
||||
self._sidebar_request_state = notice
|
||||
prefix = f"{self._sidebar_request_prefix}\n" if self._sidebar_request_prefix else ""
|
||||
self.side_request_status.setText(f"{prefix}{notice}")
|
||||
self._apply_sidebar_request_tone(notice, "cancelled")
|
||||
|
||||
def _flush_stream_chunks(self) -> None:
|
||||
self._flush_timer.stop()
|
||||
|
||||
Reference in New Issue
Block a user