-
Notifications
You must be signed in to change notification settings - Fork 557
Expand file tree
/
Copy pathInterruptPart.vue
More file actions
74 lines (69 loc) · 2.64 KB
/
Copy pathInterruptPart.vue
File metadata and controls
74 lines (69 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<template>
<ApprovalCard
v-if="part.interruptKind === 'approval' && part.approval"
:approval="toApprovalItem(part.approval)"
:resolution="approvalResolution"
:busy="part.busy"
:error="part.error"
:timeline="timeline"
@allow-once="emit('resolve', part.approval.approvalId, 'allow-once')"
@allow-always="emit('resolve', part.approval.approvalId, 'allow-always')"
@deny="emit('resolve', part.approval.approvalId, 'deny')"
@extend="emit('extend', part.approval.approvalId)"
/>
<ClarifyCard
v-else-if="
part.interruptKind === 'clarify'
&& part.clarify
&& (part.resolution == null || part.resolution === 'replied')
"
:request="part.clarify"
:submitted="part.resolution === 'replied'"
:busy="part.busy"
:error="part.error"
@submit="fields => emit('clarify-submit', fields, part.clarify!)"
@dismiss="emit('clarify-dismiss')"
/>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import ApprovalCard from '@/components/chat/ApprovalCard.vue'
import ClarifyCard from '@/components/chat/ClarifyCard.vue'
import type { ChatApprovalItem, ChatApprovalResolution } from '@/composables/chat/useChatApprovals'
import type { ChatPart, InterruptApprovalData } from '@/types/parts'
const props = defineProps<{
part: Extract<ChatPart, { type: 'interrupt' }>
timeline?: boolean
}>()
const emit = defineEmits<{
resolve: [id: string, decision: 'allow-once' | 'allow-always' | 'deny']
extend: [id: string]
'clarify-submit': [fields: Record<string, string>, request: NonNullable<Extract<ChatPart, { type: 'interrupt' }>['clarify']>]
'clarify-dismiss': []
}>()
/** InterruptApprovalData → ChatApprovalItem: rename approvalId→id; the rest is
* field-identical, so ApprovalCard's prop type stays unchanged. */
function toApprovalItem(data: InterruptApprovalData): ChatApprovalItem {
return {
id: data.approvalId,
namespace: data.namespace === 'plugin' ? 'plugin' : 'exec',
toolName: data.toolName,
command: data.command,
approvalKind: data.approvalKind,
args: data.args,
warning: data.warning,
displayKind: data.displayKind,
displayTarget: data.displayTarget,
destructive: data.destructive,
irreversible: data.irreversible,
backupState: data.backupState,
agent: data.agent,
sessionKey: data.sessionKey,
deadline: data.deadline,
}
}
// 'replied' is a clarify outcome and never reaches an approval part; narrow the
// shared InterruptResolution down to what ApprovalCard accepts.
const approvalResolution = computed<ChatApprovalResolution | null>(() =>
props.part.resolution === 'replied' ? null : props.part.resolution)
</script>