Commit 8084055
fix(agent): resolve nested tokio runtime panic in ui_loop
Fix critical panic that prevented terraphim-agent from starting in TTY mode.
Changes:
- Replace Runtime::new() with Handle::try_current() in ui_loop()
- Use existing tokio runtime instead of creating nested runtime
- Update all rt.block_on calls to handle.block_on (6 locations)
- Apply code formatting fixes
Root Cause:
The ui_loop() function was creating a new tokio runtime while already
executing inside a runtime created at main:322, violating tokio's
constraint against nested runtime creation.
Call Stack Before Fix:
main → Runtime::new() [update] → Runtime::new() [TUI] → ui_loop → Runtime::new() [PANIC]
Fix:
Use Handle::try_current() to access existing runtime context instead
of creating a new one. This is the idiomatic tokio pattern for this
scenario.
Testing:
- Build: ✅ Successful (35s)
- Format: ✅ Passes cargo fmt
- Functional: ✅ No panic, clean exit in TTY mode
- Consistency: ✅ 3/3 startup tests pass
- Integration: 1 parent d18c3ea commit 8084055
9 files changed
Lines changed: 218 additions & 103 deletions
File tree
- crates
- terraphim_agent/src
- terraphim_service/src
- llm
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1304 | 1304 | | |
1305 | 1305 | | |
1306 | 1306 | | |
1307 | | - | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
1308 | 1312 | | |
1309 | 1313 | | |
1310 | | - | |
| 1314 | + | |
1311 | 1315 | | |
1312 | | - | |
| 1316 | + | |
| 1317 | + | |
1313 | 1318 | | |
1314 | 1319 | | |
1315 | 1320 | | |
| |||
1407 | 1412 | | |
1408 | 1413 | | |
1409 | 1414 | | |
1410 | | - | |
| 1415 | + | |
1411 | 1416 | | |
1412 | 1417 | | |
1413 | 1418 | | |
| |||
1455 | 1460 | | |
1456 | 1461 | | |
1457 | 1462 | | |
1458 | | - | |
| 1463 | + | |
1459 | 1464 | | |
1460 | 1465 | | |
1461 | 1466 | | |
| |||
1470 | 1475 | | |
1471 | 1476 | | |
1472 | 1477 | | |
1473 | | - | |
| 1478 | + | |
1474 | 1479 | | |
1475 | 1480 | | |
1476 | 1481 | | |
| |||
1480 | 1485 | | |
1481 | 1486 | | |
1482 | 1487 | | |
1483 | | - | |
| 1488 | + | |
1484 | 1489 | | |
1485 | 1490 | | |
1486 | 1491 | | |
| |||
1496 | 1501 | | |
1497 | 1502 | | |
1498 | 1503 | | |
1499 | | - | |
| 1504 | + | |
1500 | 1505 | | |
1501 | 1506 | | |
1502 | 1507 | | |
| |||
1531 | 1536 | | |
1532 | 1537 | | |
1533 | 1538 | | |
1534 | | - | |
| 1539 | + | |
1535 | 1540 | | |
1536 | 1541 | | |
1537 | 1542 | | |
| |||
0 commit comments