Skip to content

feat: agent mode toggle and sandbox config isolation for OpenClaw#7612

Open
Vanalite wants to merge 4 commits intomainfrom
feat/integration_improvement
Open

feat: agent mode toggle and sandbox config isolation for OpenClaw#7612
Vanalite wants to merge 4 commits intomainfrom
feat/integration_improvement

Conversation

@Vanalite
Copy link
Contributor

@Vanalite Vanalite commented Mar 4, 2026

Summary

  • Add Agent Mode toggle in chat input that routes messages through OpenClaw's HTTP chat completions API
  • Isolate config directories between Docker sandbox (~/.openclaw/sandbox/docker/) and direct process (~/.openclaw/) — configs, sessions, agents, and credentials never cross-contaminate
  • Fix gateway bind mode — default to lan so channels (Telegram, WhatsApp) work without "Gateway is only bound to loopback" errors
  • Fix macOS launchd caching — gateway restart now does stop → install → start so config changes take effect

Frontend (web-app)

  • useAgentMode Zustand store (persisted) tracking per-thread agent mode
  • Agent mode toggle (robot icon) in ChatInput — only visible when OpenClaw is running
  • DropdownModelProvider shows "OpenClaw Agent" when agent mode is active
  • CustomChatTransport routes to OpenClaw gateway HTTP API with auth token and session key headers
  • ModelFactory registers openclaw as OpenAI-compatible provider
  • New Tauri commands: openclaw_get_auth_token, openclaw_ensure_http_api
  • Agent mode cleanup on thread delete, clear-all, and OpenClaw stop

Backend (src-tauri)

  • Config isolation: DOCKER_MODE_ACTIVE atomic flag in mod.rs makes get_openclaw_config_dir() return the correct path per sandbox mode, called in 5 entry points before any config access
  • Config patching in lifecycle.rs: on gateway start, fixes cross-mode agent paths (/home/node/.openclaw/ ↔ host path), Jan API baseUrl (localhosthost.docker.internal), and agent models.json files
  • Gateway restart in commands.rs: direct process uses stop → install → start cycle instead of plain gateway restart to handle macOS launchd caching
  • Removed 3 fragile patch functions (~120 lines): clear_mismatched_session_paths, patch_agent_models_base_url, patch_openclaw_config_base_url — replaced by config directory isolation
  • Removed unused Discord commands from Tauri command registration
  • Consolidated DOCKER_BIND_MODE / DEFAULT_BIND_MODE → single GATEWAY_BIND_MODE = "lan"

Test plan

  • Switch between direct process and docker sandbox runtime
  • Connect with telegram on both mode
  • Use Jan to chat with agent
  • Use different threads on Jan for different sessions in Agent

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Barecheck - Code coverage report

Total: 22.1%

Your code coverage diff: -0.02% ▾

Uncovered files and lines
FileLines
web-app/src/containers/AgentModeToggle.tsx1-3, 8-11, 17-22, 24-26, 28-30, 32, 34-46, 48, 50-59, 61, 63
web-app/src/containers/ChatInput.tsx1-7, 12, 21-22, 36-38, 40-41, 43-45, 51-62, 71-77, 82, 87-91, 107-144, 148-153, 155-157, 159-161, 164-168, 170-171, 173-185, 188-189, 194-203, 206-209, 212-216, 218-221, 224-241, 243-245, 247-250, 252, 254-262, 264-271, 274-276, 279, 281-285, 287-302, 304-307, 310-313, 315-325, 327-328, 331-332, 335-337, 339-350, 352, 355, 357-363, 365-368, 371-373, 376-382, 384-387, 389, 391-395, 397-405, 407, 410, 412-428, 432-434, 436-444, 447, 450-453, 456-459, 461-465, 467-470, 472-477, 479-483, 485-486, 488-492, 495-499, 501-505, 508-512, 515-516, 518-522, 524-525, 527-535, 537, 539-541, 543-563, 565-573, 575-583, 585-590, 592-602, 604, 607, 609, 611-620, 622, 624-633, 636-640, 642-678, 680-692, 694-703, 705-731, 733-762, 765-785, 787-790, 792-802, 804-805, 807-812, 814-815, 817-823, 825-828, 830-834, 836-844, 846-847, 850-855, 857-871, 873-876, 878-889, 891-901, 903-906, 908-909, 912, 914-917, 920-921, 924-927, 929-930, 933-936, 938-957, 959-960, 962-965, 967-968, 970-976, 978-982, 984-987, 989-995, 997-999, 1001, 1003-1019, 1021-1031, 1034-1038, 1040-1045, 1047-1051, 1053-1054, 1056-1062, 1064-1065, 1067-1068, 1071-1074, 1076-1079, 1082-1093, 1095-1097, 1099-1100, 1102-1103, 1106-1109, 1111-1120, 1122-1131, 1133-1139, 1141-1144, 1146-1148, 1150-1156, 1158-1160, 1162-1167, 1169, 1171-1177, 1179-1188, 1190-1200, 1202-1204, 1206-1209, 1211-1213, 1216-1220, 1222-1224, 1226-1229, 1231-1234, 1237-1239, 1242-1245, 1247-1248, 1250-1254, 1256-1258, 1260, 1262-1264, 1267-1270, 1272-1273, 1275-1276, 1278-1283, 1286-1292, 1294-1298, 1301, 1303-1307, 1310-1317, 1319-1322, 1324-1326, 1328-1339, 1341-1347, 1349-1355, 1358-1361, 1363, 1365, 1367-1374, 1376-1385, 1388-1398, 1400-1411, 1413-1419, 1422-1427, 1429-1434, 1436, 1439-1445, 1447-1461, 1464-1467, 1469-1473, 1475, 1477-1479, 1481-1490, 1492-1495, 1497-1500, 1505-1507, 1509-1525, 1527-1534, 1537-1543, 1545-1555, 1557-1559, 1561-1565, 1567-1570, 1572-1577, 1579-1593, 1595-1599, 1601-1616, 1618-1626, 1628, 1630-1631, 1633, 1635-1636, 1638-1639, 1641-1642, 1644-1645, 1654-1665, 1668-1672, 1674-1680, 1682-1693, 1696-1701, 1703-1712, 1715-1717, 1719-1723, 1725-1727, 1730-1732, 1734-1736, 1738-1744, 1746-1753, 1755-1760, 1762-1768, 1770-1777, 1780-1789, 1791-1807, 1810-1823, 1826-1839, 1841-1842, 1844-1863, 1866-1873, 1875-1876, 1878-1884, 1886-1887, 1889-1892, 1894-1901, 1903-1909, 1912-1930, 1933-1938, 1941-1946, 1948, 1950
web-app/src/containers/DropdownModelProvider.tsx47-55, 90-94, 103, 109-111, 113-120, 125-126, 128-135, 137-138, 140-148, 157-160, 162-169, 171-172, 175-185, 187-189, 191-202, 225-226, 232-241, 244-245, 250-253, 255-258, 263-264, 286-287, 330-337, 339-343, 356-357, 359-360, 363-374, 376-377, 380, 392-393, 408-410, 412-419, 422-425, 428-438, 441-455, 458-468, 481, 488-491, 493-494, 496, 522-529, 562-568, 575-577, 582, 584-588, 591-596, 598-608, 610-623, 625-626, 628-629, 634, 662-668, 680
web-app/src/hooks/useAgentMode.ts23-24, 27-33, 36-42, 53-54
web-app/src/hooks/useThreads.ts47-48, 50-54, 69, 73, 78, 124, 126-130, 204-206, 224-225, 228-232, 234-242, 244-245, 248-251, 254-257, 260-268, 270-277, 282-287, 291-293, 308-337, 339, 342, 345, 347-353, 355-376, 378-395, 423-425, 428-431, 434-435, 438, 440-452, 454-456, 458-462, 464, 466-477
web-app/src/lib/custom-chat-transport.ts2, 13-23, 59-83, 85-95, 97-100, 102, 104-106, 108-110, 118-125, 128-129, 137-141, 143, 146-150, 152-155, 157-158, 161-163, 165-167, 169-186, 188-190, 193-196, 198, 200-215, 218-220, 223, 225-239, 241-242, 247-249, 255-257, 259-260, 268, 270, 273-275, 277, 279-283, 285-295, 297-305, 307-314, 317-318, 322-336, 339-341, 345-349, 353-356, 359, 361-368, 370, 372-373, 375-377, 379-383, 386-387, 392-394, 397-398, 401-407, 409-423, 425-427, 431-442, 444-445, 448-454, 459-462, 464, 466, 469, 472-473, 480-483, 488-490, 492-499, 501-514, 516-519
web-app/src/lib/model-factory.ts80-92, 94, 96-117, 129-130, 133, 135-139, 141-142, 162, 165, 186, 189, 200-203, 205-208, 210-219, 222-225, 227-229, 231, 233-246, 248-255, 262-265, 267-270, 272-281, 284-287, 289-291, 293-297, 300-308, 312-318, 320-322, 324-325, 327-336, 338-345, 386-389, 405-409, 412-416, 418-423, 425-426
web-app/src/utils/openclaw.ts12-16, 18-28, 32-33, 36-39, 43-45, 49-54, 60-67, 69-70, 72-77, 79-80, 86-91, 93-99, 101-107, 109, 111-119, 133-139, 141-144, 146-147, 150-164, 167-173

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant