Skip to content

Commit 195b60c

Browse files
authored
Merge pull request #295 from takahirom/tm/add-run-only-this-scenario-button/2025-06-04
Add Run only this scenario button
2 parents bc1ec29 + 6f22d0a commit 195b60c

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

arbigent-ui/src/main/kotlin/io/github/takahirom/arbigent/ui/App.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ private fun MainScreen(
164164
onExecute = {
165165
appStateHolder.run(it)
166166
},
167+
onDebugExecute = {
168+
appStateHolder.runDebug(it)
169+
},
167170
onCancel = {
168171
appStateHolder.cancel()
169172
scenarioStateHolderAndDepth.first.cancel()

arbigent-ui/src/main/kotlin/io/github/takahirom/arbigent/ui/ArbigentAppStateHolder.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,24 @@ class ArbigentAppStateHolder(
141141
}
142142
}
143143

144+
fun runDebug(scenarioStateHolder: ArbigentScenarioStateHolder) {
145+
job?.cancel()
146+
allScenarioStateHoldersStateFlow.value.forEach { it.cancel() }
147+
recreateProject()
148+
job = coroutineScope.launch {
149+
// Create a regular scenario and then modify it to only include the current task
150+
val scenario = scenarioStateHolder.createScenario(allScenarioStateHoldersStateFlow.value)
151+
// Modify the scenario to only include the last task (the current scenario's task)
152+
val lastTask = scenario.agentTasks.last()
153+
val debugScenario = scenario.copy(
154+
agentTasks = listOf(lastTask)
155+
)
156+
executeScenario(debugScenario)
157+
selectedScenarioIndex.value =
158+
sortedScenariosAndDepths().indexOfFirst { it.first.id == scenarioStateHolder.id }
159+
}
160+
}
161+
144162

145163
private fun recreateProject() {
146164
projectStateFlow.value?.cancel()

arbigent-ui/src/main/kotlin/io/github/takahirom/arbigent/ui/Scenario.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ fun Scenario(
6868
scenarioCountById: (String) -> Int,
6969
onStepFeedback: (StepFeedbackEvent) -> Unit,
7070
onExecute: (ArbigentScenarioStateHolder) -> Unit,
71+
onDebugExecute: (ArbigentScenarioStateHolder) -> Unit,
7172
onCancel: (ArbigentScenarioStateHolder) -> Unit,
7273
onRemove: (ArbigentScenarioStateHolder) -> Unit,
7374
) {
@@ -97,7 +98,19 @@ fun Scenario(
9798
hint = Size(28)
9899
) {
99100
Text(
100-
text = "Run",
101+
text = "Run with the dependent scenarios",
102+
)
103+
}
104+
IconActionButton(
105+
key = AllIconsKeys.Actions.StartDebugger,
106+
onClick = {
107+
onDebugExecute(scenarioStateHolder)
108+
},
109+
contentDescription = "Debug Run",
110+
hint = Size(28)
111+
) {
112+
Text(
113+
text = "Run only this scenario",
101114
)
102115
}
103116
IconActionButton(

0 commit comments

Comments
 (0)