| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- <template>
- <div class="codex-step" :class="[`codex-step--${item.kind}`, { 'is-error': item.kind === 'error' }]">
- <span class="codex-step__node">
- <Icon :icon="icon" :size="13" />
- </span>
- <div class="codex-step__main">
- <div class="codex-step__title">{{ item.title }}</div>
- <div v-if="preview" class="codex-step__preview">{{ preview }}</div>
- <div v-if="open" class="codex-step__expand" :style="bodyStyle">
- <div class="codex-step__cap">{{ item.message.length }} 字 · 点击收起</div>
- <pre class="codex-pre"><code>{{ item.message }}</code></pre>
- </div>
- </div>
- <div class="codex-step__side">
- <span class="codex-step__time">{{ formatCodexTime(item.timestamp) }}</span>
- <button class="codex-step__toggle" type="button" :title="open ? '收起' : '展开详情'" @click="open = !open">
- <Icon :icon="open ? 'mdi:chevron-up' : 'mdi:chevron-down'" :size="14" />
- </button>
- </div>
- </div>
- </template>
- <script lang="ts" setup>
- /**
- * 执行步骤行:执行过程步骤栈里的一条(命令 / 文件变更 / 计划 / 错误 / 审批留痕)。
- *
- * 节点图标按 kind 染色;正文预览取第一行(等宽字体、省略号),点击展开完整内容 ——
- * 过程信息的价值在「可核对」,不在「占据版面」。
- */
- import { computed, ref } from 'vue';
- import Icon from '@/core/components/Icon/src/Icon.vue';
- import type { CodexProcessItem } from '../types/codexTypes';
- import { formatCodexTime } from '../utils/codexFormat';
- const props = withDefaults(defineProps<{ item: CodexProcessItem; defaultOpen?: boolean }>(), {
- defaultOpen: false,
- });
- const open = ref(props.defaultOpen);
- const ICONS: Record<string, string> = {
- lifecycle: 'mdi:progress-clock',
- thought: 'mdi:head-snowflake-outline',
- tool: 'mdi:console-line',
- file: 'mdi:file-document-edit-outline',
- plan: 'mdi:clipboard-text-outline',
- error: 'mdi:alert-circle-outline',
- approval: 'mdi:shield-check-outline',
- };
- const icon = computed(() => ICONS[props.item.kind] ?? 'mdi:information-outline');
- const preview = computed(() => {
- const text = props.item.message.trim();
- if (!text) return '';
- const firstLine = text.split('\n')[0] ?? '';
- return firstLine.length > 120 ? `${firstLine.slice(0, 120)}…` : firstLine;
- });
- const bodyStyle = computed(() => (props.item.message.length > 4000 ? { maxHeight: '420px' } : {}));
- </script>
- <style lang="less">
- .codex-step {
- display: grid;
- grid-template-columns: 22px 1fr auto;
- gap: 10px;
- align-items: start;
- padding: 7px 2px;
- & + & {
- border-top: 1px dashed var(--codex-border);
- }
- &__node {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- width: 22px;
- height: 22px;
- margin-top: 1px;
- color: #fff;
- background: var(--codex-primary);
- border-radius: 6px;
- .codex-step--file & {
- background: var(--codex-warning);
- }
- .codex-step--plan & {
- background: #0e7c86;
- }
- .codex-step--error &,
- .codex-step.is-error & {
- background: var(--codex-error);
- }
- .codex-step--approval & {
- background: var(--codex-success);
- }
- .codex-step.is-error--approval & {
- background: var(--codex-error);
- }
- }
- &__main {
- min-width: 0;
- }
- &__title {
- overflow: hidden;
- font-size: 13px;
- font-weight: 500;
- color: var(--codex-text);
- white-space: nowrap;
- text-overflow: ellipsis;
- .codex-step.is-error & {
- color: var(--codex-error);
- }
- .codex-step--approval & {
- font-weight: 600;
- }
- }
- &__preview {
- margin-top: 2px;
- overflow: hidden;
- font-family: var(--codex-font-mono);
- font-size: 12px;
- color: var(--codex-text-3);
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- &__expand {
- margin-top: 8px;
- .codex-pre {
- max-height: 260px;
- margin: 0;
- }
- }
- &__cap {
- margin-bottom: 4px;
- font-size: 11px;
- color: var(--codex-text-3);
- }
- &__side {
- display: flex;
- align-items: center;
- gap: 4px;
- padding-top: 2px;
- }
- &__time {
- font-size: 11px;
- color: var(--codex-text-3);
- }
- &__toggle {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- width: 22px;
- height: 22px;
- color: var(--codex-text-3);
- background: transparent;
- border: none;
- border-radius: 5px;
- cursor: pointer;
- &:hover {
- color: var(--codex-primary);
- background: var(--codex-bg-hover);
- }
- }
- }
- </style>
|