✨ feat(vscode): 重写注释时在卡片下展示模型过程
This commit is contained in:
1 parent
08fb04e3fd
commit
5e8e7b65ee
15 files changed
+369
-83
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import type { ClipboardEvent, DragEvent, KeyboardEvent, ReactElement } from 'react'
|
||||
import type { Ask } from './qa'
|
||||
import type { PendingImage } from './qaImages'
|
||||
import type { RewriteRun } from './rewriteRun'
|
||||
import type { ProfileChoice, QaEntryView } from './types'
|
||||
import { ChevronDown, ChevronRight, CircleStop, LoaderCircle, SendHorizontal, Sparkles, Trash2, TriangleAlert, X } from 'lucide-react'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
@@ -97,8 +98,9 @@ function HistoryItem({ entry, now, onDelete, onOpenImage }: { entry: QaEntryView
|
||||
}
|
||||
|
||||
/** 当前这一轮问的一次,照常颜色:问题,回答逐字长出来(按 Markdown 排),在做的事、出错、停止写在下面 */
|
||||
function CurrentItem({ ask, onOpenImage }: { ask: Ask, onOpenImage: (url: string) => void }): ReactElement {
|
||||
function CurrentItem({ ask, onOpenImage, onStop }: { ask: Ask, onOpenImage: (url: string) => void, onStop?: () => void }): ReactElement {
|
||||
const running = ask.status === 'running'
|
||||
const label = ask.activity ?? (ask.text === '' ? '正在想…' : '正在回答…')
|
||||
return (
|
||||
<div className="cr-qa-entry" data-current="">
|
||||
<div className="cr-qa-head">
|
||||
@@ -116,7 +118,12 @@ function CurrentItem({ ask, onOpenImage }: { ask: Ask, onOpenImage: (url: string
|
||||
{running && (
|
||||
<div className="cr-qa-status" role="status">
|
||||
<LoaderCircle size={12} strokeWidth={1.8} className="cr-qa-spin" aria-hidden />
|
||||
{ask.activity ?? (ask.text === '' ? '正在想…' : '正在回答…')}
|
||||
{onStop ? <span className="min-w-0 flex-1">{label}</span> : label}
|
||||
{onStop && (
|
||||
<button type="button" className="cr-tool" data-tooltip="停止" aria-label="停止" onClick={onStop}>
|
||||
<CircleStop size={14} strokeWidth={1.8} aria-hidden />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{ask.status === 'failed' && (
|
||||
@@ -297,3 +304,25 @@ export function AskThread({ history, asks, open, profiles, now = Date.now(), onS
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 注释块下面的重写过程,样子和展开的「问 AI」一样:左边竖线、问题、流出来的回答、正在读哪个文件。
|
||||
*
|
||||
* 问题是发给模型的那句固定要求。没有输入框,不记历史。写进文件后由调用方拿掉;失败或停下就留在这里。
|
||||
*/
|
||||
export function RewriteThread({ run, onStop }: { run: RewriteRun, onStop: () => void }): ReactElement {
|
||||
const ask: Ask = {
|
||||
askId: 'rewrite',
|
||||
anchor: '',
|
||||
question: run.question,
|
||||
text: run.text,
|
||||
...(run.activity !== undefined && { activity: run.activity }),
|
||||
status: run.status,
|
||||
...(run.error !== undefined && { error: run.error }),
|
||||
}
|
||||
return (
|
||||
<section className="cr-qa" aria-label="按注释规范重写">
|
||||
<CurrentItem ask={ask} onOpenImage={() => {}} onStop={run.status === 'running' ? onStop : undefined} />
|
||||
</section>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user