android-midscene-automation 1.1.5 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +13 -0
  3. package/package.json +1 -1
  4. package/server/appium-config.test.ts +5 -1
  5. package/server/appium-recorder/ai-recognition.ts +9 -0
  6. package/server/appium-recorder/appium-runner.ts +13 -2
  7. package/server/appium-recorder/element-tap.test.ts +61 -0
  8. package/server/appium-recorder/request-timeout.test.ts +34 -0
  9. package/server/appium-recorder/request-timeout.ts +7 -3
  10. package/server/config.ts +7 -3
  11. package/src/App.vue +1 -0
  12. package/src/appium-recorder/AppiumPage.vue +9 -4
  13. package/src/appium-recorder/components/AiRecognitionSettings.vue +141 -84
  14. package/src/appium-recorder/components/FlowCanvas.vue +39 -1
  15. package/src/appium-recorder/components/FlowNodeCard.vue +11 -1
  16. package/src/appium-recorder/components/FlowRoundedEdge.vue +20 -2
  17. package/src/appium-recorder/components/FlowStepEditor.vue +114 -85
  18. package/src/appium-recorder/components/LoopSettings.vue +12 -10
  19. package/src/appium-recorder/components/NestedConditionBranches.vue +5 -1
  20. package/src/appium-recorder/components/RecordedSteps.vue +14 -0
  21. package/src/appium-recorder/components/TextClickSettings.vue +11 -11
  22. package/src/appium-recorder/components/VariableExtractionSettings.vue +6 -4
  23. package/src/appium-recorder/flow-appearance.ts +9 -2
  24. package/src/appium-recorder/flow-graph.ts +13 -7
  25. package/src/components/config/AppiumConfigPanel.vue +2 -2
  26. package/src/components/config/FlowAppearanceSettings.vue +12 -5
  27. package/src/config/use-model-config.ts +2 -1
  28. package/src/pages/ConfigPage.vue +6 -6
  29. package/src/style.css +28 -18
  30. package/src/types.ts +1 -1
@@ -19,6 +19,17 @@ const branch = computed(() => isAiBranchEnabled(props.step));
19
19
  const untilMatch = computed(() => props.step.aiObservation?.mode === 'untilMatch');
20
20
  const branchChoice = ref(branch.value);
21
21
  const fallbackEnabled = shallowRef(Boolean(props.step.aiInvalidResultBranch));
22
+ const activeSections = ref<string[]>(['prompt']);
23
+ const observationSummary = computed(() => {
24
+ if (!props.step.aiObservation) return '单帧识别';
25
+ const mode = props.step.aiObservation.mode === 'untilMatch' ? '命中即结束' : '统一分析';
26
+ return `${mode} · ${props.step.aiObservation.durationMs / 1000} 秒`;
27
+ });
28
+ const branchSummary = computed(() => {
29
+ if (!branch.value) return '未启用';
30
+ if (!props.step.aiInvalidResultBranch) return '已启用';
31
+ return `已启用 · 无效结果进入${props.step.aiInvalidResultBranch === 'yes' ? '左侧' : '右侧'}`;
32
+ });
22
33
  watch(branch, value => { branchChoice.value = value; });
23
34
  watch(() => props.step.aiInvalidResultBranch, value => { fallbackEnabled.value = Boolean(value); });
24
35
  let controller: AbortController | undefined;
@@ -82,7 +93,10 @@ async function save(enabled: boolean, observation?: AiObservationConfig) {
82
93
  const value = validateAiRecognitionPrompt(prompt.value);
83
94
  if (enabled || (observation ?? props.step.aiObservation)?.mode === 'untilMatch') {
84
95
  const validation = await validateAiBranchQuestion(value, signal);
85
- if (!validation.result) throw new Error(`${enabled ? '无法进入分支' : '命中条件无效'}:${validation.reason || '请填写可用 true/false 判断的问题'}`);
96
+ if (!validation.result) {
97
+ const reason = validation.reason || '提示词不是可直接判断 true/false 的封闭条件';
98
+ throw new Error(`${enabled ? '无法进入分支' : '命中条件无效'}:${reason}\n开放式输出包括:输出时长或时间点、列举或提取内容、描述画面、说明失败原因或判断依据,以及指定“XX秒”“HH:MM:SS”“播放失败”等格式。\n修改建议:删除额外输出要求,只保留一个可回答“是/否”的判断问题及其成立、不成立条件;需要详细内容时请关闭分支并使用普通识别。`);
99
+ }
86
100
  }
87
101
  if (signal.aborted) return;
88
102
  emit('update', { value, aiBranchEnabled: enabled, ...(observation ? { aiObservation: observation } : {}), flow: { ...props.step.flow, nodeKind: enabled ? 'condition' : 'action' } });
@@ -93,89 +107,113 @@ async function save(enabled: boolean, observation?: AiObservationConfig) {
93
107
  </script>
94
108
 
95
109
  <template>
96
- <el-form-item label="识别方式">
97
- <template #label>
98
- <span class="recognition-label">识别方式
99
- <el-tooltip placement="top" :show-after="200">
100
- <template #content><div class="recognition-help-content">单帧识别:截取当前画面并分析。持续观察:按采样间隔连续截图,判断目标是否在观察期间出现过。建议紧接启动 App 或触发广告的操作放置本节点。</div></template>
101
- <el-button class="recognition-help" text :icon="QuestionFilled" aria-label="识别方式说明" @click.prevent />
102
- </el-tooltip>
103
- </span>
104
- </template>
105
- <el-radio-group :model-value="Boolean(step.aiObservation)" :disabled="disabled || busy" @update:model-value="emit('update', { aiObservation: $event ? { ...DEFAULT_AI_OBSERVATION } : undefined }); error = ''">
106
- <el-radio-button :value="false">单帧识别</el-radio-button>
107
- <el-radio-button :value="true">持续观察</el-radio-button>
108
- </el-radio-group>
109
- </el-form-item>
110
- <template v-if="step.aiObservation">
111
- <el-form-item label="观察模式">
112
- <template #label>
113
- <span class="recognition-label">观察模式
114
- <el-tooltip placement="top" :show-after="200">
115
- <template #content>
116
- <div class="recognition-help-content">
117
- <p>观察结束后统一分析:完成采样后,将保留的截图一次提交给模型。</p>
118
- <p>检测命中后提前结束:采样期间逐次识别,确认命中后停止观察并执行下一节点;启用分支时走“是”分支。达到最长观察时间后停止采样,等待剩余关键帧判断,未命中则继续下一节点或走“否”分支。</p>
119
- <p>最多采样 30 帧,实际速度取决于设备,截图按去重配置保留。观察时长与模型请求超时分别计时;提前结束模式可能多次调用模型,实际结束时间包含模型等待,识别错误不会视为未命中。</p>
120
- </div>
110
+ <div class="ai-recognition-settings">
111
+ <el-collapse v-model="activeSections" class="ai-recognition-settings__groups">
112
+ <el-collapse-item name="prompt">
113
+ <template #title>
114
+ <span class="ai-recognition-settings__group-title"><strong>识别内容</strong><small>{{ prompt.trim() ? '已填写' : '未填写' }}</small></span>
115
+ </template>
116
+ <el-form-item :label="untilMatch ? '命中条件' : '识别内容'">
117
+ <template #label>
118
+ <span class="recognition-label">{{ untilMatch ? '命中条件' : '识别内容' }}
119
+ <el-tooltip v-if="untilMatch" placement="top" :show-after="200">
120
+ <template #content><div class="recognition-help-content">填写能用“是 / 否”判断的具体条件,例如“当前画面是否出现广告弹窗?”。模型判断为“是”即命中并提前结束观察;修改条件后需验证并保存。“广告内容是什么”等开放式问题请使用统一分析模式。</div></template>
121
+ <el-button class="recognition-help" text :icon="QuestionFilled" aria-label="命中条件说明" @click.prevent />
122
+ </el-tooltip>
123
+ </span>
124
+ </template>
125
+ <AiRecognitionPromptInput v-model="prompt" :presets="promptPresets" :placeholder="untilMatch ? '例如:当前画面是否出现广告弹窗?' : ''" :disabled="disabled || busy || optimizingPrompt" @change="error = ''; !branch && !untilMatch && save(false)" />
126
+ <div class="recognition-prompt-actions">
127
+ <el-button :loading="optimizingPrompt" :disabled="disabled || busy || !prompt.trim()" @click="optimizePrompt">优化提示词</el-button>
128
+ <el-button v-if="(branch || untilMatch) && prompt !== step.value" :disabled="disabled || busy || optimizingPrompt" @click="save(branch)">验证并保存问题</el-button>
129
+ </div>
130
+ </el-form-item>
131
+ </el-collapse-item>
132
+
133
+ <el-collapse-item name="observation">
134
+ <template #title>
135
+ <span class="ai-recognition-settings__group-title"><strong>观察设置</strong><small>{{ observationSummary }}</small></span>
136
+ </template>
137
+ <el-form-item label="识别方式">
138
+ <template #label>
139
+ <span class="recognition-label">识别方式
140
+ <el-tooltip placement="top" :show-after="200">
141
+ <template #content><div class="recognition-help-content">单帧识别:截取当前画面并分析。持续观察:按采样间隔连续截图,判断目标是否在观察期间出现过。建议紧接启动 App 或触发广告的操作放置本节点。</div></template>
142
+ <el-button class="recognition-help" text :icon="QuestionFilled" aria-label="识别方式说明" @click.prevent />
143
+ </el-tooltip>
144
+ </span>
145
+ </template>
146
+ <el-radio-group :model-value="Boolean(step.aiObservation)" :disabled="disabled || busy" @update:model-value="emit('update', { aiObservation: $event ? { ...DEFAULT_AI_OBSERVATION } : undefined }); error = ''">
147
+ <el-radio-button :value="false">单帧识别</el-radio-button>
148
+ <el-radio-button :value="true">持续观察</el-radio-button>
149
+ </el-radio-group>
150
+ </el-form-item>
151
+ <template v-if="step.aiObservation">
152
+ <el-form-item label="观察模式">
153
+ <template #label>
154
+ <span class="recognition-label">观察模式
155
+ <el-tooltip placement="top" :show-after="200">
156
+ <template #content>
157
+ <div class="recognition-help-content">
158
+ <p>观察结束后统一分析:完成采样后,将保留的截图一次提交给模型。</p>
159
+ <p>检测命中后提前结束:采样期间逐次识别,确认命中后停止观察并执行下一节点;启用分支时走“是”分支。达到最长观察时间后停止采样,等待剩余关键帧判断,未命中则继续下一节点或走“否”分支。</p>
160
+ <p>最多采样 30 帧,实际速度取决于设备,截图按去重配置保留。观察时长与模型请求超时分别计时;提前结束模式可能多次调用模型,实际结束时间包含模型等待,识别错误不会视为未命中。</p>
161
+ </div>
162
+ </template>
163
+ <el-button class="recognition-help" text :icon="QuestionFilled" aria-label="观察模式说明" @click.prevent />
164
+ </el-tooltip>
165
+ </span>
166
+ </template>
167
+ <el-radio-group :model-value="step.aiObservation.mode ?? 'batch'" :disabled="disabled || busy" @update:model-value="$event === 'untilMatch' ? save(branch, { ...step.aiObservation!, mode: 'untilMatch' }) : updateObservation({ mode: 'batch' })">
168
+ <el-radio-button value="batch">观察结束后统一分析</el-radio-button>
169
+ <el-radio-button value="untilMatch">检测命中后提前结束</el-radio-button>
170
+ </el-radio-group>
171
+ </el-form-item>
172
+ <div class="ai-recognition-settings__grid">
173
+ <el-form-item :label="untilMatch ? '最长观察时间 ms' : '观察时长 ms'">
174
+ <el-input-number :model-value="step.aiObservation.durationMs" :min="1000" :max="60000" :step="1000" :disabled="disabled || busy" controls-position="right" @change="updateObservation({ durationMs: $event })" />
175
+ </el-form-item>
176
+ <el-form-item label="采样间隔 ms">
177
+ <el-input-number :model-value="step.aiObservation.intervalMs" :min="500" :max="10000" :step="500" :disabled="disabled || busy" controls-position="right" @change="updateObservation({ intervalMs: $event })" />
178
+ </el-form-item>
179
+ </div>
180
+ </template>
181
+ </el-collapse-item>
182
+
183
+ <el-collapse-item name="branch">
184
+ <template #title>
185
+ <span class="ai-recognition-settings__group-title"><strong>分支设置</strong><small>{{ branchSummary }}</small></span>
186
+ </template>
187
+ <el-form-item class="ai-recognition-settings__toggles">
188
+ <div class="ai-recognition-settings__toggle-row">
189
+ <el-checkbox :model-value="branchChoice" :disabled="disabled || busy" @update:model-value="toggleBranch($event === true)">启用分支</el-checkbox>
190
+ <template v-if="branch">
191
+ <el-checkbox :model-value="fallbackEnabled" :disabled="disabled || busy" @update:model-value="toggleFallback($event === true)">启用兜底</el-checkbox>
192
+ <el-tooltip placement="top" :show-after="200">
193
+ <template #content><div class="recognition-help-content">仅在模型返回空内容、无效格式、无法判断或没有返回 true/false 时生效。正常返回布尔结果时仍按识别结果进入分支;请求失败和超时不使用此兜底。</div></template>
194
+ <el-button class="recognition-help" text :icon="QuestionFilled" aria-label="AI 识别兜底说明" @click.prevent />
195
+ </el-tooltip>
121
196
  </template>
122
- <el-button class="recognition-help" text :icon="QuestionFilled" aria-label="观察模式说明" @click.prevent />
123
- </el-tooltip>
124
- </span>
125
- </template>
126
- <el-radio-group :model-value="step.aiObservation.mode ?? 'batch'" :disabled="disabled || busy" @update:model-value="$event === 'untilMatch' ? save(branch, { ...step.aiObservation!, mode: 'untilMatch' }) : updateObservation({ mode: 'batch' })">
127
- <el-radio-button value="batch">观察结束后统一分析</el-radio-button>
128
- <el-radio-button value="untilMatch">检测命中后提前结束</el-radio-button>
129
- </el-radio-group>
130
- </el-form-item>
131
- <el-form-item :label="untilMatch ? '最长观察时间 ms' : '观察时长 ms'">
132
- <el-input-number :model-value="step.aiObservation.durationMs" :min="1000" :max="60000" :step="1000" :disabled="disabled || busy" controls-position="right" @change="updateObservation({ durationMs: $event })" />
133
- </el-form-item>
134
- <el-form-item label="采样间隔 ms">
135
- <el-input-number :model-value="step.aiObservation.intervalMs" :min="500" :max="10000" :step="500" :disabled="disabled || busy" controls-position="right" @change="updateObservation({ intervalMs: $event })" />
136
- </el-form-item>
137
- </template>
138
- <el-form-item :label="untilMatch ? '命中条件' : '识别内容'">
139
- <template #label>
140
- <span class="recognition-label">{{ untilMatch ? '命中条件' : '识别内容' }}
141
- <el-tooltip v-if="untilMatch" placement="top" :show-after="200">
142
- <template #content><div class="recognition-help-content">填写能用“是 / 否”判断的具体条件,例如“当前画面是否出现广告弹窗?”。模型判断为“是”即命中并提前结束观察;修改条件后需验证并保存。“广告内容是什么”等开放式问题请使用统一分析模式。</div></template>
143
- <el-button class="recognition-help" text :icon="QuestionFilled" aria-label="命中条件说明" @click.prevent />
144
- </el-tooltip>
145
- </span>
146
- </template>
147
- <AiRecognitionPromptInput v-model="prompt" :presets="promptPresets" :placeholder="untilMatch ? '例如:当前画面是否出现广告弹窗?' : ''" :disabled="disabled || busy || optimizingPrompt" @change="error = ''; !branch && !untilMatch && save(false)" />
148
- <div class="recognition-prompt-actions">
149
- <el-button :loading="optimizingPrompt" :disabled="disabled || busy || !prompt.trim()" @click="optimizePrompt">优化提示词</el-button>
150
- <el-button v-if="(branch || untilMatch) && prompt !== step.value" :disabled="disabled || busy || optimizingPrompt" @click="save(branch)">验证并保存问题</el-button>
151
- </div>
152
- </el-form-item>
153
- <el-form-item>
154
- <el-checkbox :model-value="branchChoice" :disabled="disabled || busy" @update:model-value="toggleBranch($event === true)">启用分支</el-checkbox>
155
- <span v-if="busy" class="validation-status" role="status">
156
- <el-icon class="is-loading" aria-hidden="true"><Loading /></el-icon>
157
- 正在验证…
158
- </span>
159
- </el-form-item>
160
- <el-form-item v-if="branch">
161
- <el-checkbox :model-value="fallbackEnabled" :disabled="disabled || busy" @update:model-value="toggleFallback($event === true)">启用兜底</el-checkbox>
162
- <el-tooltip placement="top" :show-after="200">
163
- <template #content><div class="recognition-help-content">仅在模型返回空内容、无效格式、无法判断或没有返回 true/false 时生效。正常返回布尔结果时仍按识别结果进入分支;请求失败和超时不使用此兜底。</div></template>
164
- <el-button class="recognition-help" text :icon="QuestionFilled" aria-label="AI 识别兜底说明" @click.prevent />
165
- </el-tooltip>
166
- </el-form-item>
167
- <el-form-item v-if="branch && fallbackEnabled" label="兜底分支">
168
- <el-select
169
- :model-value="step.aiInvalidResultBranch || ''"
170
- :disabled="disabled || busy"
171
- placeholder="请选择左右分支"
172
- @update:model-value="emit('update', { aiInvalidResultBranch: $event })"
173
- >
174
- <el-option :label="`进入左侧分支(${flowBranchLabel(step, 'yes')})`" value="yes" />
175
- <el-option :label="`进入右侧分支(${flowBranchLabel(step, 'no')})`" value="no" />
176
- </el-select>
177
- </el-form-item>
178
- <el-alert v-if="error" :title="error" type="warning" :closable="false" show-icon />
197
+ </div>
198
+ <span v-if="busy" class="validation-status" role="status">
199
+ <el-icon class="is-loading" aria-hidden="true"><Loading /></el-icon>
200
+ 正在验证…
201
+ </span>
202
+ </el-form-item>
203
+ <el-form-item v-if="branch && fallbackEnabled" label="兜底分支">
204
+ <el-select :model-value="step.aiInvalidResultBranch || ''" :disabled="disabled || busy" placeholder="请选择左右分支" @update:model-value="emit('update', { aiInvalidResultBranch: $event })">
205
+ <el-option :label="`进入左侧分支(${flowBranchLabel(step, 'yes')})`" value="yes" />
206
+ <el-option :label="`进入右侧分支(${flowBranchLabel(step, 'no')})`" value="no" />
207
+ </el-select>
208
+ </el-form-item>
209
+ </el-collapse-item>
210
+
211
+ <el-collapse-item title="节点信息与超时设置" name="other">
212
+ <slot name="other" />
213
+ </el-collapse-item>
214
+ </el-collapse>
215
+ <el-alert v-if="error" :title="error" type="warning" :closable="false" show-icon />
216
+ </div>
179
217
  </template>
180
218
 
181
219
  <style scoped>
@@ -184,7 +222,26 @@ async function save(enabled: boolean, observation?: AiObservationConfig) {
184
222
  .recognition-help-content { max-width: min(360px, calc(100vw - 40px)); line-height: 1.6; overflow-wrap: anywhere; }
185
223
  .recognition-help-content p { margin: 0 0 8px; }
186
224
  .recognition-help-content p:last-child { margin-bottom: 0; }
187
- .recognition-prompt-actions { display: flex; justify-content: flex-end; width: 100%; margin-top: 10px; }
225
+ .recognition-prompt-actions { display: flex; justify-content: flex-end; gap: 6px; width: 100%; margin-top: 6px; }
226
+ .recognition-prompt-actions .el-button + .el-button { margin-left: 0; }
227
+ .ai-recognition-settings { min-width: 0; }
228
+ .ai-recognition-settings :deep(.el-form-item) { margin-bottom: 10px; }
229
+ .ai-recognition-settings__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
230
+ .ai-recognition-settings__grid :deep(.el-form-item) { min-width: 0; }
231
+ .ai-recognition-settings__grid :deep(.el-input-number) { width: 100%; }
232
+ .ai-recognition-settings__toggle-row { display: flex; align-items: center; flex-wrap: wrap; gap: 0 12px; }
233
+ .ai-recognition-settings__toggle-row :deep(.el-checkbox) { margin-right: 0; }
234
+ .ai-recognition-settings__toggles :deep(.el-form-item__content) { align-items: center; }
235
+ .ai-recognition-settings__groups { overflow: hidden; border: 1px solid var(--el-border-color-lighter); border-radius: 10px; background: #fff; }
236
+ .ai-recognition-settings__groups :deep(.el-collapse-item__header) { height: 42px; padding: 0 10px; border-bottom-color: var(--el-border-color-lighter); font-size: 12px; }
237
+ .ai-recognition-settings__groups :deep(.el-collapse-item__wrap) { border-bottom-color: var(--el-border-color-lighter); }
238
+ .ai-recognition-settings__groups :deep(.el-collapse-item:last-child .el-collapse-item__header),
239
+ .ai-recognition-settings__groups :deep(.el-collapse-item:last-child .el-collapse-item__wrap) { border-bottom: 0; }
240
+ .ai-recognition-settings__groups :deep(.el-collapse-item__content) { padding: 8px 10px 2px; }
241
+ .ai-recognition-settings__group-title { display: flex; align-items: center; justify-content: space-between; min-width: 0; width: 100%; padding-right: 8px; gap: 8px; }
242
+ .ai-recognition-settings__group-title strong { color: var(--ui-text); font-size: 12px; }
243
+ .ai-recognition-settings__group-title small { min-width: 0; overflow: hidden; color: var(--ui-text-muted); font-size: 11px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
244
+ .el-alert :deep(.el-alert__title) { white-space: pre-line; line-height: 1.6; }
188
245
  .validation-status {
189
246
  display: inline-flex;
190
247
  align-items: center;
@@ -65,6 +65,8 @@ let internalsFrame = 0;
65
65
  let resetViewFrame = 0;
66
66
  let pendingResetView = false;
67
67
  let searchFrame = 0;
68
+ let focusFrame = 0;
69
+ let focusedNodeId = '';
68
70
  watch(() => [props.searchFocusToken, props.searchTargetId, props.searchActive, paneReady.value], async () => {
69
71
  if (searchFrame) cancelAnimationFrame(searchFrame);
70
72
  if (!props.searchActive || !props.searchTargetId || !paneReady.value) return;
@@ -107,9 +109,37 @@ function handleNodeResize(payload: { id: string; height: number }) {
107
109
  [payload.id]: height,
108
110
  };
109
111
  void nextTick(scheduleNodeInternalsUpdate);
112
+ if (payload.id === focusedNodeId) void nextTick(() => scheduleNodeFocus(payload.id));
110
113
  if (props.readonly) void nextTick(() => scheduleResetView());
111
114
  }
112
115
 
116
+ function scheduleNodeFocus(nodeId: string) {
117
+ if (!paneReady.value || !nodeId) return;
118
+ if (focusFrame) window.cancelAnimationFrame(focusFrame);
119
+ focusFrame = window.requestAnimationFrame(() => {
120
+ updateNodeInternals([nodeId]);
121
+ focusFrame = window.requestAnimationFrame(() => {
122
+ focusFrame = 0;
123
+ if (focusedNodeId !== nodeId) return;
124
+ const node = findNode(nodeId);
125
+ if (!node) return;
126
+ const zoom = Math.min(1.8, Math.max(1.2, viewport.value.zoom));
127
+ void setCenter(
128
+ node.position.x + node.dimensions.width / 2,
129
+ node.position.y + node.dimensions.height / 2,
130
+ { zoom, duration: 260 },
131
+ );
132
+ });
133
+ });
134
+ }
135
+
136
+ function handleNodeClick(index: number) {
137
+ const step = props.steps[index];
138
+ if (step) focusedNodeId = `step:${step.id}`;
139
+ emit('nodeClick', index);
140
+ if (focusedNodeId) void nextTick(() => scheduleNodeFocus(focusedNodeId));
141
+ }
142
+
113
143
  function scheduleNodeInternalsUpdate() {
114
144
  if (internalsFrame) window.cancelAnimationFrame(internalsFrame);
115
145
  internalsFrame = window.requestAnimationFrame(() => {
@@ -165,12 +195,20 @@ watch(graph, () => {
165
195
  void nextTick(scheduleNodeInternalsUpdate);
166
196
  });
167
197
 
198
+ watch(() => props.expandedStepIndex, () => {
199
+ if (focusedNodeId) void nextTick(() => scheduleNodeFocus(focusedNodeId));
200
+ });
201
+
168
202
  watch(() => props.resetViewToken, () => {
203
+ focusedNodeId = '';
204
+ if (focusFrame) window.cancelAnimationFrame(focusFrame);
205
+ focusFrame = 0;
169
206
  void nextTick(scheduleResetView);
170
207
  });
171
208
 
172
209
  onBeforeUnmount(() => {
173
210
  if (searchFrame) cancelAnimationFrame(searchFrame);
211
+ if (focusFrame) cancelAnimationFrame(focusFrame);
174
212
  if (internalsFrame) window.cancelAnimationFrame(internalsFrame);
175
213
  if (resetViewFrame) window.cancelAnimationFrame(resetViewFrame);
176
214
  pendingResetView = false;
@@ -225,7 +263,7 @@ function handleInsert(payload: {
225
263
  :data="data"
226
264
  :readonly="props.readonly"
227
265
  :search-highlighted="nodeId === `step:${searchTargetId}`"
228
- @node-click="emit('nodeClick', $event)"
266
+ @node-click="handleNodeClick"
229
267
  @copy="emit('copy', [$event])"
230
268
  @remove="emit('remove', $event)"
231
269
  @edit-input="emit('editInput', $event)"
@@ -181,7 +181,10 @@ watch(() => props.data, () => {
181
181
  </el-icon>
182
182
  </el-tooltip>
183
183
  <strong :title="`${data.index + 1}. ${data.title}`"><span class="appium-flow-node-number">{{ data.index + 1 }}.</span> {{ data.title }}</strong>
184
- <small :title="data.meta">{{ data.meta }}</small>
184
+ <small
185
+ :class="{ 'appium-flow-step-card__meta--clamped': data.step.type === 'aiRecognition' }"
186
+ :title="data.meta"
187
+ >{{ data.meta }}</small>
185
188
  <em v-if="data.note" :title="data.note">{{ data.note }}</em>
186
189
  </span>
187
190
  </button>
@@ -274,4 +277,11 @@ watch(() => props.data, () => {
274
277
  .appium-flow-step-shell--delete-selected .appium-flow-step-card__content small { color: #fee2e2; }
275
278
  .appium-node-action-tooltip { display: inline-flex; }
276
279
  .appium-ai-model-warning { float: left; margin: 2px 6px 0 0; font-size: 16px; }
280
+ .appium-flow-step-card__meta--clamped {
281
+ display: -webkit-box;
282
+ overflow: hidden;
283
+ text-overflow: ellipsis;
284
+ -webkit-box-orient: vertical;
285
+ -webkit-line-clamp: 3;
286
+ }
277
287
  </style>
@@ -1,9 +1,11 @@
1
1
  <script setup lang="ts">
2
- import { computed } from 'vue';
3
- import { BaseEdge, type EdgeProps } from '@vue-flow/core';
2
+ import { computed, inject } from 'vue';
3
+ import { BaseEdge, getBezierPath, type EdgeProps } from '@vue-flow/core';
4
+ import { flowLineStyleKey, normalizeFlowLineStyle } from '../flow-appearance';
4
5
  import type { FlowGraphNodeData } from '../flow-graph';
5
6
 
6
7
  const props = defineProps<EdgeProps>();
8
+ const lineStyle = inject(flowLineStyleKey, computed(() => normalizeFlowLineStyle(undefined)));
7
9
 
8
10
  const targetData = computed(() => props.targetNode.data as FlowGraphNodeData | undefined);
9
11
 
@@ -22,6 +24,22 @@ function linePath(points: Point[]) {
22
24
  }
23
25
 
24
26
  const path = computed(() => {
27
+ if (lineStyle.value === 'curved') {
28
+ if (props.data?.merge && props.targetY > props.sourceY) {
29
+ // 先沿分支向下,仅在汇合点上方的留白内弯曲,避免斜穿相邻节点。
30
+ const bendY = Math.max(props.sourceY, props.targetY - 112);
31
+ const controlY = (bendY + props.targetY) / 2;
32
+ return [
33
+ `M ${props.sourceX} ${props.sourceY}`,
34
+ `L ${props.sourceX} ${bendY}`,
35
+ `C ${props.sourceX} ${controlY} ${props.targetX} ${controlY} ${props.targetX} ${props.targetY}`,
36
+ ].join(' ');
37
+ }
38
+ return getBezierPath({
39
+ sourceX: props.sourceX, sourceY: props.sourceY, sourcePosition: props.sourcePosition,
40
+ targetX: props.targetX, targetY: props.targetY, targetPosition: props.targetPosition,
41
+ })[0];
42
+ }
25
43
  const source = { x: props.sourceX, y: props.sourceY };
26
44
  const target = { x: props.targetX, y: props.targetY };
27
45
  const deltaX = target.x - source.x;