android-midscene-automation 1.1.5 → 1.1.6

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.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,12 @@
1
1
  # 更新记录
2
+ ## v1.1.6
3
+ - [Appium]优化流程画布交互:点击节点自动放大并居中,流程总览支持还原位置,AI 识别节点提示词最多展示三行。
4
+ - [Appium]统一节点编辑界面:AI 识别、组件定位、节点信息和超时设置使用紧凑分组,优化循环、滑动、缩放等参数布局。
5
+ - [Appium]组件树搜索支持上下切换匹配项,组件详情按优先级展示定位方式和组件属性。
6
+ - [AI识别]分支提示词校验增加开放式输出说明和具体修改建议。
7
+ - [配置/UI]修复 API Key 显示按钮,统一提示弹窗、选项控件及相关配置区域样式。
8
+ - [Artemis]停止输出成功的状态与就绪探测访问日志,保留服务运行和异常日志。
9
+
2
10
  ## v1.1.5
3
11
  - UI优化
4
12
 
package/README.md CHANGED
@@ -1502,6 +1502,14 @@ Linux: ~/.local/share/android-midscene-automation
1502
1502
 
1503
1503
  # 项目更新记录
1504
1504
 
1505
+ ## v1.1.6
1506
+ - [Appium]优化流程画布交互:点击节点自动放大并居中,流程总览支持还原位置,AI 识别节点提示词最多展示三行。
1507
+ - [Appium]统一节点编辑界面:AI 识别、组件定位、节点信息和超时设置使用紧凑分组,优化循环、滑动、缩放等参数布局。
1508
+ - [Appium]组件树搜索支持上下切换匹配项,组件详情按优先级展示定位方式和组件属性。
1509
+ - [AI识别]分支提示词校验增加开放式输出说明和具体修改建议。
1510
+ - [配置/UI]修复 API Key 显示按钮,统一提示弹窗、选项控件及相关配置区域样式。
1511
+ - [Artemis]停止输出成功的状态与就绪探测访问日志,保留服务运行和异常日志。
1512
+
1505
1513
  ## v1.1.5
1506
1514
  - UI优化
1507
1515
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "android-midscene-automation",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/oooooooko/android-midscene-automation.git"
@@ -55,6 +55,7 @@ export async function recognizeDeviceScreen(input: {
55
55
  onObservationFrame?: (frame: ObservationCapture) => Promise<void> | void;
56
56
  signal?: AbortSignal;
57
57
  imageBase64?: string;
58
+ onAnalysisStart?: () => void;
58
59
  onModelOutput?: (content: string) => void;
59
60
  }): Promise<AiRecognitionResult & { imageBase64: string }> {
60
61
  const prompt = validateAiRecognitionPrompt(input.prompt);
@@ -68,6 +69,7 @@ export async function recognizeDeviceScreen(input: {
68
69
  const timeoutMs = Number.isFinite(input.timeoutMs) && input.timeoutMs! > 0
69
70
  ? Math.min(300000, Math.max(1000, input.timeoutMs!)) : DEFAULT_NODE_TIMEOUT_MS;
70
71
  const captureSignal = input.signal || new AbortController().signal;
72
+ let analysisStartNotified = false;
71
73
  captureSignal.throwIfAborted();
72
74
  async function analyze(observation?: AiRecognitionResult['observation'], imageBase64 = '', requestSignal = captureSignal) {
73
75
  // 持续观察的采集窗口与模型请求分别计时,避免 3 秒请求超时截断 15 秒观察。
@@ -90,6 +92,10 @@ export async function recognizeDeviceScreen(input: {
90
92
  { type: 'image_url' as const, image_url: { url: frame.imageDataUrl, detail: 'high' as const } },
91
93
  ])
92
94
  : [{ type: 'image_url', image_url: { url: `data:image/png;base64,${imageBase64}`, detail: 'high' } }];
95
+ if (!analysisStartNotified) {
96
+ analysisStartNotified = true;
97
+ input.onAnalysisStart?.();
98
+ }
93
99
  const response = await client.chat.completions.create({
94
100
  model: model.name,
95
101
  max_completion_tokens: 2048,
@@ -163,6 +169,9 @@ export async function validateAiBranchQuestion(value: unknown, signal?: AbortSig
163
169
  询问指定对象是否存在或指定状态是否成立,包括“有没有”“是否”“是不是”“了吗”“吗”等问法,都可以作为分支条件。广告弹窗、黑屏、按钮可用等视觉概念不要求用户额外定义像素或坐标。
164
170
  必须区分封闭判断与开放问题:“当前画面有没有广告弹窗”是指定对象的存在性判断,应返回 true;“当前画面是否有广告弹窗”“页面是不是黑屏”“登录按钮可用吗”也应返回 true。
165
171
  “当前画面有什么”“描述当前画面”“提取画面中的所有文字”需要列举、描述或提取内容,应返回 false。“有没有广告弹窗,如果有请列出全部广告内容”包含开放任务,也应返回 false。
172
+ 要求输出时长、时间点、数量、名称、文字内容、画面描述、失败原因、判断依据、列表、总结,或指定“XX秒”“HH:MM:SS”“播放失败”等自定义输出格式,也属于开放式输出;即使文本前半部分可以回答是/否,只要同时要求这些额外输出,仍返回 false。
173
+ 返回 false 时,reason 必须包含“开放式内容”和“修改建议”两部分:先逐项短引用用户文本中导致失败的具体要求,再说明应删除或如何改写,并给出一个保留原判断目标、可直接回答是/否的简短问题。不得只写“包含开放式任务”等笼统原因。
174
+ 示例 reason:“开放式内容:‘输出首次变化时长’、‘失败时简要说明依据’;修改建议:删除自定义输出要求,改为‘本次观察期间录像回放是否播放成功?’。”
166
175
  只返回 JSON:{"result":true或false,"reason":"简短中文原因"}。不要输出思考过程。` },
167
176
  { role: 'user', content: prompt },
168
177
  ],
@@ -744,6 +744,7 @@ async function saveScreenshot(deviceId: string) {
744
744
 
745
745
  type RunStepMeta = {
746
746
  onModelOutput?: (content: string) => void;
747
+ onAiAnalysisStart?: () => void;
747
748
  onAiProgress?: (message: string) => void;
748
749
  nodeNumber: number;
749
750
  scriptName: string;
@@ -927,7 +928,9 @@ async function runStep(
927
928
  onProgress: meta.onAiProgress,
928
929
  onObservationFrame: frame => captureReplayFrame(sessionId, step, meta.nodeNumber, meta.scriptName || '', 'observation', `观察第 ${frame.index} 帧 · ${frame.elapsedMs}ms`, frame.imageBase64),
929
930
  timeoutMs: step.timeoutMs, aiTimeoutEnabled: step.aiTimeoutEnabled === true,
930
- signal: replayContext.getStore()?.signal, onModelOutput: meta.onModelOutput,
931
+ signal: replayContext.getStore()?.signal,
932
+ onAnalysisStart: meta.onAiAnalysisStart,
933
+ onModelOutput: meta.onModelOutput,
931
934
  });
932
935
  return `AI 识别回答:${recognition.reason}`;
933
936
  }
@@ -1388,6 +1391,7 @@ async function replayLinearSteps(
1388
1391
  continue;
1389
1392
  }
1390
1393
  await replayContext.getStore()?.selectVideoScript?.(stack.at(-1) || '', options.scriptName || '');
1394
+ const nodeStartedAt = Date.now();
1391
1395
  lines.push(`[节点 ${index + 1}] 开始:${step.label}`);
1392
1396
  await captureReplayFrame(sessionId, step, index + 1, options.scriptName || '', 'before', '执行前');
1393
1397
  try {
@@ -1397,6 +1401,7 @@ async function replayLinearSteps(
1397
1401
  } else {
1398
1402
  const result = await runStep(sessionId, deviceId, step, {
1399
1403
  onAiProgress: message => lines.push(`[节点 ${index + 1}] AI 持续观察:${message}`),
1404
+ onAiAnalysisStart: () => lines.push(`[节点 ${index + 1}] AI 识别内容开始:距进入当前节点 ${Date.now() - nodeStartedAt}ms`),
1400
1405
  onModelOutput: content => lines.push(`[节点 ${index + 1}] AI 识别模型输出:${content}`),
1401
1406
  nodeNumber: index + 1,
1402
1407
  scriptName: options.scriptName || '',
@@ -1450,6 +1455,7 @@ async function replayFlowSteps(
1450
1455
  await replayContext.getStore()?.selectVideoScript?.(stack.at(-1) || '', options.scriptName || '');
1451
1456
  visitedPath.push(step.label);
1452
1457
  const nodeKind = defaultFlowKind(step);
1458
+ const nodeStartedAt = Date.now();
1453
1459
  lines.push(`[节点 ${index + 1}] 开始:${frameStep.label}`);
1454
1460
  await captureReplayFrame(sessionId, frameStep, index + 1, options.scriptName || '', 'before', '执行前');
1455
1461
 
@@ -1478,6 +1484,7 @@ async function replayFlowSteps(
1478
1484
  aiTimeoutEnabled: step.aiTimeoutEnabled === true, aiObservation: step.aiObservation,
1479
1485
  onProgress: message => lines.push(`[节点 ${index + 1}] AI 持续观察:${message}`),
1480
1486
  onObservationFrame: frame => captureReplayFrame(sessionId, frameStep, index + 1, options.scriptName || '', 'observation', `观察第 ${frame.index} 帧 · ${frame.elapsedMs}ms`, frame.imageBase64),
1487
+ onAnalysisStart: () => lines.push(`[节点 ${index + 1}] AI 识别内容开始:距进入当前节点 ${Date.now() - nodeStartedAt}ms`),
1481
1488
  onModelOutput: (content) => lines.push(`[节点 ${index + 1}] AI 识别模型输出:${content}`),
1482
1489
  signal: replayContext.getStore()?.signal,
1483
1490
  imageBase64: beforeFrame?.nodeId === step.id && beforeFrame.phase === 'before' ? beforeFrame.imageBase64 : undefined,
@@ -1576,6 +1583,7 @@ async function replayFlowSteps(
1576
1583
  } else {
1577
1584
  const result = await runStep(sessionId, deviceId, step, {
1578
1585
  onAiProgress: message => lines.push(`[节点 ${index + 1}] AI 持续观察:${message}`),
1586
+ onAiAnalysisStart: () => lines.push(`[节点 ${index + 1}] AI 识别内容开始:距进入当前节点 ${Date.now() - nodeStartedAt}ms`),
1579
1587
  onModelOutput: content => lines.push(`[节点 ${index + 1}] AI 识别模型输出:${content}`),
1580
1588
  nodeNumber: index + 1,
1581
1589
  scriptName: options.scriptName || '',
@@ -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,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { computed } from 'vue';
2
+ import { computed, ref } from 'vue';
3
3
  import CoordinatePointPicker from './CoordinatePointPicker.vue';
4
4
  import type { AppiumRecordedStep, AppiumSelector } from '../types';
5
5
  import { normalizeVisualChangeConfig } from '../visual-change';
@@ -51,6 +51,16 @@ const invalidTapCoordinates = computed(() => (
51
51
  && Number(props.step.fallback?.centerX) === 0
52
52
  && Number(props.step.fallback?.centerY) === 0
53
53
  ));
54
+ const editorSections = ref<string[]>([]);
55
+ const selectorSummary = computed(() => {
56
+ const selector = props.step.selector;
57
+ if (!selector) return '未设置';
58
+ const value = selector.value?.trim() || '未填写';
59
+ return `${selector.strategy} · ${value}${props.step.contextSelector ? ' · 含父级' : ''}`;
60
+ });
61
+ const supportsTimeout = computed(() => ![
62
+ 'delay', 'longPress', 'stopApp', 'log', 'openGallery', 'endFlow', 'loop', 'breakLoop', 'continueLoop', 'aiRecognition',
63
+ ].includes(props.step.type));
54
64
 
55
65
  function defaultKind(): FlowKind {
56
66
  return defaultFlowKind(props.step);
@@ -154,55 +164,27 @@ function patchSelector(patch: Partial<AppiumSelector>) {
154
164
  <template>
155
165
  <div class="appium-flow-editor">
156
166
  <el-form label-position="top" size="small">
157
- <el-form-item label="节点名称">
158
- <el-input
159
- :model-value="step.label"
160
- :disabled="disabled"
161
- @update:model-value="patchStep({ label: String($event) })"
162
- />
163
- </el-form-item>
164
- <el-form-item label="备注">
165
- <el-input
166
- :model-value="step.note || ''"
167
- :disabled="disabled"
168
- maxlength="100"
169
- placeholder="例如:登录按钮、账号输入框"
170
- @update:model-value="patchStep({ note: String($event) || undefined })"
171
- />
172
- </el-form-item>
173
- <div>
174
- <el-form-item v-if="step.type === 'aiRecognition'">
175
- <el-checkbox :model-value="step.aiTimeoutEnabled === true" :disabled="disabled" @update:model-value="patchStep({ aiTimeoutEnabled: $event === true })">启用超时</el-checkbox>
176
- </el-form-item>
177
- <el-form-item v-if="!['longPress', 'stopApp', 'log', 'openGallery', 'endFlow', 'loop', 'breakLoop', 'continueLoop'].includes(step.type) && (step.type !== 'aiRecognition' || step.aiTimeoutEnabled === true)" :label="step.type === 'aiRecognition' && step.aiObservation ? '模型请求超时 ms' : '超时时间 ms'">
178
- <el-input-number
179
- :model-value="step.timeoutMs ?? (step.type === 'delay' ? 1000 : DEFAULT_NODE_TIMEOUT_MS)"
180
- :disabled="disabled"
181
- :min="0"
182
- :max="999999"
183
- :step="1000"
184
- controls-position="right"
185
- @update:model-value="patchTimeout($event)"
186
- />
187
- </el-form-item>
188
- <BranchTimeoutSettings v-if="defaultKind() === 'condition' && (step.type !== 'aiRecognition' || step.aiTimeoutEnabled === true)" :step="step" :disabled="disabled" @update="patchStep({ timeoutBranch: $event })" />
189
- </div>
190
167
  <LongPressSettings v-if="step.type === 'longPress'" :step="step" :disabled="disabled" @update="patchStep" />
191
168
  <el-form-item v-if="['waitActivity', 'launchApp', 'stopApp', 'clearAppData'].includes(step.type)" :label="step.type === 'waitActivity' ? '目标 Activity' : '目标 APP 包名'">
192
169
  <el-input :model-value="step.value || ''" :disabled="disabled" @update:model-value="patchStep({ value: String($event) })" />
193
170
  </el-form-item>
171
+ <el-form-item v-if="step.type === 'delay'" label="延时时长 ms">
172
+ <el-input-number :model-value="step.timeoutMs ?? 1000" :disabled="disabled" :min="0" :max="999999" :step="1000" controls-position="right" @update:model-value="patchTimeout($event)" />
173
+ </el-form-item>
194
174
  <template v-if="step.type === 'pinch'">
195
175
  <el-form-item label="缩放方向">
196
176
  <el-select :model-value="step.pinch?.direction || 'out'" :disabled="disabled" @update:model-value="patchPinch({ direction: $event })">
197
177
  <el-option label="放大" value="out" /><el-option label="缩小" value="in" />
198
178
  </el-select>
199
179
  </el-form-item>
200
- <el-form-item v-for="axis in (['centerX', 'centerY'] as const)" :key="axis" :label="axis === 'centerX' ? '中心 X' : '中心 Y'">
201
- <el-input-number :model-value="step.pinch?.[axis] ?? 0" :disabled="disabled" :min="0" :max="99999" :precision="0" controls-position="right" @update:model-value="patchPinch({ [axis]: $event ?? 0 })" />
202
- </el-form-item>
203
- <el-form-item label="缩放比例">
204
- <el-input-number :model-value="step.pinch?.percent ?? 0.5" :disabled="disabled" :min="0.01" :max="1" :step="0.05" controls-position="right" @update:model-value="patchPinch({ percent: $event ?? 0.5 })" />
205
- </el-form-item>
180
+ <div class="appium-flow-editor__grid">
181
+ <el-form-item v-for="axis in (['centerX', 'centerY'] as const)" :key="axis" :label="axis === 'centerX' ? '中心 X' : '中心 Y'">
182
+ <el-input-number :model-value="step.pinch?.[axis] ?? 0" :disabled="disabled" :min="0" :max="99999" :precision="0" controls-position="right" @update:model-value="patchPinch({ [axis]: $event ?? 0 })" />
183
+ </el-form-item>
184
+ <el-form-item label="缩放比例">
185
+ <el-input-number :model-value="step.pinch?.percent ?? 0.5" :disabled="disabled" :min="0.01" :max="1" :step="0.05" controls-position="right" @update:model-value="patchPinch({ percent: $event ?? 0.5 })" />
186
+ </el-form-item>
187
+ </div>
206
188
  </template>
207
189
  <StageLogSettings v-if="step.type === 'log'" :step="step" :disabled="disabled" @update="patchStep" />
208
190
  <VariableExtractionSettings v-if="step.type === 'extractVariable'" :step="step" :disabled="disabled" @update="patchStep" />
@@ -210,7 +192,25 @@ function patchSelector(patch: Partial<AppiumSelector>) {
210
192
  <LoopSettings v-if="step.type === 'loop'" :step="step" :disabled="disabled" @update="patchStep" />
211
193
  <BreakLoopSettings v-if="step.type === 'breakLoop' || step.type === 'continueLoop'" :step="step" :steps="steps" :disabled="disabled" :mode="step.type === 'continueLoop' ? 'continue' : 'break'" @update="patchStep" />
212
194
  <TextClickSettings v-if="step.type === 'textClick'" :step="step" :disabled="disabled" @update="patchStep" />
213
- <AiRecognitionSettings v-if="step.type === 'aiRecognition'" :step="step" :steps="steps" :disabled="disabled" @update="patchStep" />
195
+ <AiRecognitionSettings v-if="step.type === 'aiRecognition'" :step="step" :steps="steps" :disabled="disabled" @update="patchStep">
196
+ <template #other>
197
+ <el-form-item label="节点名称">
198
+ <el-input :model-value="step.label" :disabled="disabled" @update:model-value="patchStep({ label: String($event) })" />
199
+ </el-form-item>
200
+ <el-form-item label="备注">
201
+ <el-input :model-value="step.note || ''" :disabled="disabled" maxlength="100" placeholder="例如:播放画面检测" @update:model-value="patchStep({ note: String($event) || undefined })" />
202
+ </el-form-item>
203
+ <el-form-item>
204
+ <el-checkbox :model-value="step.aiTimeoutEnabled === true" :disabled="disabled" @update:model-value="patchStep({ aiTimeoutEnabled: $event === true })">启用超时</el-checkbox>
205
+ </el-form-item>
206
+ <template v-if="step.aiTimeoutEnabled === true">
207
+ <el-form-item :label="step.aiObservation ? '模型请求超时 ms' : '超时时间 ms'">
208
+ <el-input-number :model-value="step.timeoutMs ?? DEFAULT_NODE_TIMEOUT_MS" :disabled="disabled" :min="0" :max="999999" :step="1000" controls-position="right" @update:model-value="patchTimeout($event)" />
209
+ </el-form-item>
210
+ <BranchTimeoutSettings v-if="defaultKind() === 'condition'" :step="step" :disabled="disabled" @update="patchStep({ timeoutBranch: $event })" />
211
+ </template>
212
+ </template>
213
+ </AiRecognitionSettings>
214
214
  <el-form-item
215
215
  v-if="step.type === 'input' || step.type === 'inputIfExists' || step.type === 'assertText'"
216
216
  label="文本内容"
@@ -363,50 +363,39 @@ function patchSelector(patch: Partial<AppiumSelector>) {
363
363
  />
364
364
  </el-form-item>
365
365
  </div>
366
- <div v-if="showSelector && step.selector" class="appium-flow-editor__grid">
367
- <el-form-item label="Selector 类型">
368
- <el-select
369
- :model-value="step.selector.strategy"
370
- :disabled="disabled"
371
- @update:model-value="patchSelector({ strategy: $event as AppiumSelector['strategy'] })"
372
- >
373
- <el-option label="accessibility id" value="accessibilityId" />
374
- <el-option label="id" value="id" />
375
- <el-option label="android uiAutomator" value="androidUiAutomator" />
376
- <el-option label="xpath" value="xpath" />
377
- </el-select>
378
- </el-form-item>
379
- <el-form-item label="Selector 值">
380
- <el-input
381
- :model-value="step.selector.value || ''"
382
- :disabled="disabled"
383
- @update:model-value="patchSelector({ value: String($event) })"
384
- />
385
- </el-form-item>
386
- </div>
387
- <div v-if="showSelector" class="appium-flow-editor__grid">
388
- <el-form-item label="父级上下文类型">
389
- <el-select
390
- :model-value="step.contextSelector?.strategy || ''"
391
- :disabled="disabled"
392
- clearable
393
- placeholder="不使用父级"
394
- @update:model-value="patchStep({ contextSelector: $event ? { ...(step.contextSelector || { value: '' }), strategy: $event as AppiumSelector['strategy'] } : undefined })"
395
- >
396
- <el-option label="accessibility id" value="accessibilityId" />
397
- <el-option label="id" value="id" />
398
- <el-option label="android uiAutomator" value="androidUiAutomator" />
399
- <el-option label="xpath" value="xpath" />
400
- </el-select>
401
- </el-form-item>
402
- <el-form-item label="父级上下文值">
403
- <el-input
404
- :model-value="step.contextSelector?.value || ''"
405
- :disabled="disabled || !step.contextSelector"
406
- @update:model-value="patchStep({ contextSelector: { ...(step.contextSelector || { strategy: 'xpath' }), value: String($event) } })"
407
- />
408
- </el-form-item>
409
- </div>
366
+ <el-collapse v-if="showSelector" v-model="editorSections" class="appium-flow-editor__groups">
367
+ <el-collapse-item name="selector">
368
+ <template #title>
369
+ <span class="appium-flow-editor__group-title"><strong>组件定位</strong><small>{{ selectorSummary }}</small></span>
370
+ </template>
371
+ <div v-if="step.selector" class="appium-flow-editor__grid">
372
+ <el-form-item label="Selector 类型">
373
+ <el-select :model-value="step.selector.strategy" :disabled="disabled" @update:model-value="patchSelector({ strategy: $event as AppiumSelector['strategy'] })">
374
+ <el-option label="accessibility id" value="accessibilityId" />
375
+ <el-option label="id" value="id" />
376
+ <el-option label="android uiAutomator" value="androidUiAutomator" />
377
+ <el-option label="xpath" value="xpath" />
378
+ </el-select>
379
+ </el-form-item>
380
+ <el-form-item label="Selector 值">
381
+ <el-input :model-value="step.selector.value || ''" :disabled="disabled" @update:model-value="patchSelector({ value: String($event) })" />
382
+ </el-form-item>
383
+ </div>
384
+ <div class="appium-flow-editor__grid">
385
+ <el-form-item label="父级上下文类型">
386
+ <el-select :model-value="step.contextSelector?.strategy || ''" :disabled="disabled" clearable placeholder="不使用父级" @update:model-value="patchStep({ contextSelector: $event ? { ...(step.contextSelector || { value: '' }), strategy: $event as AppiumSelector['strategy'] } : undefined })">
387
+ <el-option label="accessibility id" value="accessibilityId" />
388
+ <el-option label="id" value="id" />
389
+ <el-option label="android uiAutomator" value="androidUiAutomator" />
390
+ <el-option label="xpath" value="xpath" />
391
+ </el-select>
392
+ </el-form-item>
393
+ <el-form-item label="父级上下文值">
394
+ <el-input :model-value="step.contextSelector?.value || ''" :disabled="disabled || !step.contextSelector" @update:model-value="patchStep({ contextSelector: { ...(step.contextSelector || { strategy: 'xpath' }), value: String($event) } })" />
395
+ </el-form-item>
396
+ </div>
397
+ </el-collapse-item>
398
+ </el-collapse>
410
399
  <div v-if="defaultKind() === 'condition' && step.type !== 'loop' && !isBooleanCondition(step)" class="appium-flow-editor__grid">
411
400
  <el-form-item label="指定文本(可选)">
412
401
  <el-input
@@ -447,6 +436,23 @@ function patchSelector(patch: Partial<AppiumSelector>) {
447
436
  />
448
437
  <CoordinatePointPicker :disabled="disabled" @select="applyTapPoint" />
449
438
  </section>
439
+ <el-collapse v-if="step.type !== 'aiRecognition'" v-model="editorSections" class="appium-flow-editor__groups appium-flow-editor__groups--meta">
440
+ <el-collapse-item name="meta">
441
+ <template #title>
442
+ <span class="appium-flow-editor__group-title"><strong>节点信息与超时</strong><small>{{ step.label }}</small></span>
443
+ </template>
444
+ <el-form-item label="节点名称">
445
+ <el-input :model-value="step.label" :disabled="disabled" @update:model-value="patchStep({ label: String($event) })" />
446
+ </el-form-item>
447
+ <el-form-item label="备注">
448
+ <el-input :model-value="step.note || ''" :disabled="disabled" maxlength="100" placeholder="例如:登录按钮、账号输入框" @update:model-value="patchStep({ note: String($event) || undefined })" />
449
+ </el-form-item>
450
+ <el-form-item v-if="supportsTimeout" label="超时时间 ms">
451
+ <el-input-number :model-value="step.timeoutMs ?? (step.type === 'delay' ? 1000 : DEFAULT_NODE_TIMEOUT_MS)" :disabled="disabled" :min="0" :max="999999" :step="1000" controls-position="right" @update:model-value="patchTimeout($event)" />
452
+ </el-form-item>
453
+ <BranchTimeoutSettings v-if="defaultKind() === 'condition' && supportsTimeout" :step="step" :disabled="disabled" @update="patchStep({ timeoutBranch: $event })" />
454
+ </el-collapse-item>
455
+ </el-collapse>
450
456
  </el-form>
451
457
  </div>
452
458
  </template>
@@ -460,6 +466,8 @@ function patchSelector(patch: Partial<AppiumSelector>) {
460
466
  border-top: 1px solid var(--el-border-color-lighter);
461
467
  }
462
468
 
469
+ .appium-flow-editor :deep(.el-form-item) { margin-bottom: 10px; }
470
+
463
471
  .appium-flow-editor__fallback :deep(.el-form-item) {
464
472
  margin-bottom: 0;
465
473
  }
@@ -472,4 +480,25 @@ function patchSelector(patch: Partial<AppiumSelector>) {
472
480
  font-size: 13px;
473
481
  line-height: 20px;
474
482
  }
483
+
484
+ .appium-flow-editor__groups {
485
+ overflow: hidden;
486
+ margin-top: 8px;
487
+ border: 1px solid var(--el-border-color-lighter);
488
+ border-radius: 10px;
489
+ background: #fff;
490
+ }
491
+
492
+ .appium-flow-editor__groups :deep(.el-collapse-item__header) {
493
+ height: 42px;
494
+ padding: 0 10px;
495
+ border-bottom: 0;
496
+ font-size: 12px;
497
+ }
498
+
499
+ .appium-flow-editor__groups :deep(.el-collapse-item__wrap) { border-bottom: 0; }
500
+ .appium-flow-editor__groups :deep(.el-collapse-item__content) { padding: 8px 10px 2px; }
501
+ .appium-flow-editor__group-title { display: flex; align-items: center; justify-content: space-between; min-width: 0; width: 100%; padding-right: 8px; gap: 8px; }
502
+ .appium-flow-editor__group-title strong { flex: none; color: var(--ui-text); font-size: 12px; }
503
+ .appium-flow-editor__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; }
475
504
  </style>
@@ -13,16 +13,18 @@ function selector(patch: Partial<AppiumSelector>) {
13
13
  </script>
14
14
 
15
15
  <template>
16
- <el-form-item label="循环方式">
17
- <el-select :model-value="step.loop?.exitWhen || 'never'" :disabled="disabled" @update:model-value="patch({ exitWhen: $event })">
18
- <el-option value="never" label="固定次数" />
19
- <el-option value="exists" label="元素出现时退出" />
20
- <el-option value="notExists" label="元素消失时退出" />
21
- </el-select>
22
- </el-form-item>
23
- <el-form-item :label="step.loop?.exitWhen === 'never' ? '执行次数' : '最大执行次数'" required>
24
- <el-input-number :model-value="step.loop?.maxIterations" :disabled="disabled" :min="1" :max="MAX_LOOP_ITERATIONS" :precision="0" controls-position="right" @update:model-value="patch({ maxIterations: Number($event) })" />
25
- </el-form-item>
16
+ <div class="appium-flow-editor__grid">
17
+ <el-form-item label="循环方式">
18
+ <el-select :model-value="step.loop?.exitWhen || 'never'" :disabled="disabled" @update:model-value="patch({ exitWhen: $event })">
19
+ <el-option value="never" label="固定次数" />
20
+ <el-option value="exists" label="元素出现时退出" />
21
+ <el-option value="notExists" label="元素消失时退出" />
22
+ </el-select>
23
+ </el-form-item>
24
+ <el-form-item :label="step.loop?.exitWhen === 'never' ? '执行次数' : '最大执行次数'" required>
25
+ <el-input-number :model-value="step.loop?.maxIterations" :disabled="disabled" :min="1" :max="MAX_LOOP_ITERATIONS" :precision="0" controls-position="right" @update:model-value="patch({ maxIterations: Number($event) })" />
26
+ </el-form-item>
27
+ </div>
26
28
  <template v-if="step.loop?.exitWhen && step.loop.exitWhen !== 'never'">
27
29
  <el-form-item label="退出条件定位方式">
28
30
  <el-select :model-value="step.selector?.strategy || 'id'" :disabled="disabled" @update:model-value="selector({ strategy: $event })">
@@ -298,7 +298,11 @@ function branchSplitPath() {
298
298
  >
299
299
  <span class="appium-flow-node__body">
300
300
  <span class="appium-flow-node__title"><span class="appium-flow-node-number">{{ item.index + 1 }}.</span> {{ item.step.label }}</span>
301
- <span class="appium-flow-node__meta">
301
+ <span
302
+ class="appium-flow-node__meta"
303
+ :class="{ 'appium-flow-node__meta--clamped': item.step.type === 'aiRecognition' }"
304
+ :title="item.step.type === 'aiRecognition' ? stepMeta(item.step) : undefined"
305
+ >
302
306
  {{ kindLabel(defaultKind(item.step)) }} · {{ typeLabel(item.step) }}
303
307
  <template v-if="stepMeta(item.step)"> · {{ stepMeta(item.step) }}</template>
304
308
  </span>
@@ -247,6 +247,10 @@ function resetMainFlowPosition() {
247
247
  mainResetViewToken.value += 1;
248
248
  }
249
249
 
250
+ function resetDialogFlowPosition() {
251
+ dialogResetViewToken.value += 1;
252
+ }
253
+
250
254
  watch(flowDialogVisible, (visible) => {
251
255
  if (!visible) return;
252
256
  void nextTick(() => {
@@ -396,6 +400,14 @@ function updateStep(index: number, step: AppiumRecordedStep) {
396
400
  <el-tooltip v-if="!copyMode" content="批量删除" placement="top" :show-after="200"><span class="flow-toolbar-icon">
397
401
  <el-button aria-label="批量删除" size="small" :icon="Delete" :disabled="!steps.length || mergeDisabled || removeDisabled" @click="startDeleteMode" />
398
402
  </span></el-tooltip>
403
+ <el-tooltip content="还原位置" placement="top" :show-after="200"><span class="flow-toolbar-icon">
404
+ <el-button
405
+ aria-label="还原位置"
406
+ size="small"
407
+ :icon="Aim"
408
+ @click="resetDialogFlowPosition"
409
+ />
410
+ </span></el-tooltip>
399
411
  </div>
400
412
  <FlowCanvas
401
413
  id="appium-flow-dialog"
@@ -5,15 +5,15 @@ const emit = defineEmits<{ update: [patch: Partial<AppiumRecordedStep>] }>();
5
5
  </script>
6
6
 
7
7
  <template>
8
- <el-form-item label="点击文字" required>
9
- <el-input :model-value="step.value || ''" :disabled="disabled" maxlength="1000" aria-label="点击文字"
10
- @update:model-value="emit('update', { value: String($event) })" />
11
- </el-form-item>
12
- <el-form-item label="文本匹配方式">
13
- <el-select :model-value="step.flow?.textMatch || 'contains'" :disabled="disabled"
14
- @update:model-value="emit('update', { flow: { ...props.step.flow, textMatch: $event } })">
15
- <el-option label="精准匹配(完全一致)" value="exact" />
16
- <el-option label="模糊匹配(包含)" value="contains" />
17
- </el-select>
18
- </el-form-item>
8
+ <div class="appium-flow-editor__grid">
9
+ <el-form-item label="点击文字" required>
10
+ <el-input :model-value="step.value || ''" :disabled="disabled" maxlength="1000" aria-label="点击文字" @update:model-value="emit('update', { value: String($event) })" />
11
+ </el-form-item>
12
+ <el-form-item label="文本匹配方式">
13
+ <el-select :model-value="step.flow?.textMatch || 'contains'" :disabled="disabled" @update:model-value="emit('update', { flow: { ...props.step.flow, textMatch: $event } })">
14
+ <el-option label="精准匹配(完全一致)" value="exact" />
15
+ <el-option label="模糊匹配(包含)" value="contains" />
16
+ </el-select>
17
+ </el-form-item>
18
+ </div>
19
19
  </template>
@@ -9,9 +9,11 @@ function update(patch: Partial<VariableExtraction>) {
9
9
  </script>
10
10
 
11
11
  <template>
12
- <el-form-item label="保存到当前脚本变量"><el-input :model-value="step.extractVariable?.name || ''" :disabled="disabled" aria-label="提取变量名" @update:model-value="update({ name: String($event) })" /></el-form-item>
13
- <el-form-item label="组件属性"><el-select :model-value="step.extractVariable?.attribute || 'text'" :disabled="disabled" filterable allow-create default-first-option aria-label="提取组件属性" @update:model-value="update({ attribute: String($event) })">
14
- <el-option v-for="name in ['text', 'content-desc', 'checked', 'selected', 'enabled', 'resource-id', 'class']" :key="name" :label="name" :value="name" />
15
- </el-select></el-form-item>
12
+ <div class="appium-flow-editor__grid">
13
+ <el-form-item label="保存到脚本变量"><el-input :model-value="step.extractVariable?.name || ''" :disabled="disabled" aria-label="提取变量名" @update:model-value="update({ name: String($event) })" /></el-form-item>
14
+ <el-form-item label="组件属性"><el-select :model-value="step.extractVariable?.attribute || 'text'" :disabled="disabled" filterable allow-create default-first-option aria-label="提取组件属性" @update:model-value="update({ attribute: String($event) })">
15
+ <el-option v-for="name in ['text', 'content-desc', 'checked', 'selected', 'enabled', 'resource-id', 'class']" :key="name" :label="name" :value="name" />
16
+ </el-select></el-form-item>
17
+ </div>
16
18
  <el-form-item label="敏感变量"><el-checkbox :model-value="step.extractVariable?.sensitive || sensitiveVariableName(step.extractVariable?.name || '')" :disabled="disabled || sensitiveVariableName(step.extractVariable?.name || '')" @update:model-value="update({ sensitive: Boolean($event) })" /></el-form-item>
17
19
  </template>
@@ -277,9 +277,12 @@ function estimateTextLines(text: string | undefined, charsPerLine: number) {
277
277
  ), 0);
278
278
  }
279
279
 
280
- function estimateStepNodeHeight(label: { title: string; meta: string; note?: string }) {
280
+ function estimateStepNodeHeight(label: { title: string; meta: string; note?: string }, maxMetaLines?: number) {
281
281
  const titleLines = estimateTextLines(label.title, 20);
282
- const metaLines = estimateTextLines(label.meta, 24);
282
+ const estimatedMetaLines = estimateTextLines(label.meta, 24);
283
+ const metaLines = maxMetaLines == null
284
+ ? estimatedMetaLines
285
+ : Math.min(estimatedMetaLines, maxMetaLines);
283
286
  const noteLines = estimateTextLines(label.note, 24);
284
287
  const textHeight = titleLines * 19 + metaLines * 17 + noteLines * 17;
285
288
  return Math.max(FLOW_STEP_NODE_HEIGHT, 34 + textHeight);
@@ -424,7 +427,10 @@ export function buildFlowGraph(
424
427
  const label = options.labelStep(item.step);
425
428
  // 字数估算仅用于首次布局,不强制卡片高度;实际换行由浏览器决定。
426
429
  const cardMinHeight = FLOW_STEP_NODE_HEIGHT;
427
- const estimatedCardHeight = estimateStepNodeHeight(label);
430
+ const estimatedCardHeight = estimateStepNodeHeight(
431
+ label,
432
+ item.step.type === 'aiRecognition' ? 3 : undefined,
433
+ );
428
434
  const estimatedNodeHeight = options.expandedStepIndex === item.index
429
435
  ? estimatedCardHeight + FLOW_EXPANDED_NODE_HEIGHT
430
436
  : estimatedCardHeight;
package/src/style.css CHANGED
@@ -834,6 +834,14 @@ select {
834
834
  overflow-wrap: anywhere;
835
835
  }
836
836
 
837
+ .appium-flow-node__meta--clamped {
838
+ display: -webkit-box;
839
+ overflow: hidden;
840
+ text-overflow: ellipsis;
841
+ -webkit-box-orient: vertical;
842
+ -webkit-line-clamp: 3;
843
+ }
844
+
837
845
  .appium-flow-node__note {
838
846
  min-width: 0;
839
847
  color: var(--ui-text);
@@ -1109,11 +1117,11 @@ select {
1109
1117
  }
1110
1118
 
1111
1119
  .appium-flow-editor__grid--swipe {
1112
- grid-template-columns: repeat(3, minmax(0, 1fr));
1120
+ grid-template-columns: repeat(2, minmax(0, 1fr));
1113
1121
  }
1114
1122
 
1115
1123
  .appium-flow-editor__grid--visual {
1116
- grid-template-columns: repeat(3, minmax(0, 1fr));
1124
+ grid-template-columns: repeat(2, minmax(0, 1fr));
1117
1125
  }
1118
1126
 
1119
1127
  .appium-swipe-message-box {