Commit 2d85c73
authored
Openclaw local plugin 20260408 (#1454)
## Description
This PR introduces UX enhancements for model configurations, improves
the server shutdown lifecycle, and fixes a critical issue where multiple
Viewer instances were being spawned concurrently due to OpenClaw
lifecycle mismatch.
**Key Changes:**
1. **Multiple Viewer Instances Fix (Fixes #1422, #1425, #1430)**:
- **The Problem**: Previously, the plugin's Viewer could self-start
multiple times during OpenClaw's initialization or hot-reloads. This led
to duplicate instances, port drifting (e.g., 18799 → 18800+), resource
waste, and occasionally caused the Memory service to be reported as
unavailable despite a fixed port configuration.
- **The Solution**: Introduced a global singleton state
(`globalRef.__memosLocalPluginActiveService`) to ensure the service
startup is idempotent across repeated register/init cycles. The
self-start fallback logic was also refactored to conditionally trigger
based on `process.argv` arguments (ensuring it only auto-starts for
`gateway`, `start`, or `restart` commands), completely preventing orphan
instances and port accumulation.
2. **Model Configuration Warnings**: Added visual warning banners in the
Viewer UI (Settings and Main view) to alert users when critical models
(Embedding, Summarizer, Skill Evolution) are missing or using the
built-in mini model. This helps prevent degraded memory retrieval and
processing experiences.
3. **Graceful Shutdown**: Refactored `ViewerServer.stop()` to be
asynchronous, utilizing `server.closeAllConnections()` to ensure all
active connections are properly closed and releasing the singleton lock
before shutting down the process.
Related Issue (Required): Fixes #1430, Fixes #1425, Fixes #1422
## Type of change
- [x] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] Refactor (does not change functionality, e.g. code style
improvements, linting)
- [ ] Documentation update
## How Has This Been Tested?
- [x] Unit Test
- [x] Test Script Or Test Steps (please provide)
- **Multiple Instances Fix**: Started OpenClaw gateway and verified that
the Viewer only starts once on the configured port. Triggered OpenClaw
hot-reloads and confirmed the singleton lock prevents duplicate Viewer
instances and port drift.
- **Shutdown Lifecycle**: Started the viewer using `start-viewer.ts` and
triggered `SIGINT` to verify the asynchronous graceful shutdown works as
expected without leaving hanging processes.
- **UI Warnings**: Verified the UI fallback warning banners correctly
render and disappear across both English and Chinese locales when model
configurations are absent.
- Ran integration and unit tests (`pnpm test`) to ensure everything
works correctly.
- [ ] Pipeline Automated API Test (please provide)
## Checklist
- [x] I have performed a self-review of my own code | 我已自行检查了自己的代码
- [x] I have commented my code in hard-to-understand areas |
我已在难以理解的地方对代码进行了注释
- [x] I have added tests that prove my fix is effective or that my
feature works | 我已添加测试以证明我的修复有效或功能正常
- [ ] I have created related documentation issue/PR in
`https://github.com/MemTensor/MemOS-Docs` (if applicable) | 我已在
`https://github.com/MemTensor/MemOS-Docs` 中创建了相关的文档 issue/PR(如果适用)
- [x] I have linked the issue to this PR (if applicable) | 我已将 issue
链接到此 PR(如果适用)
- [ ] I have mentioned the person who will review this PR | 我已提及将审查此 PR
的人
## Reviewer Checklist
- [x] closes #1430
- [x] closes #1425
- [x] closes #1422
- [ ] Made sure Checks passed
- [ ] Tests have been provided4 files changed
Lines changed: 129 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
389 | 389 | | |
390 | 390 | | |
391 | 391 | | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
392 | 401 | | |
393 | 402 | | |
394 | 403 | | |
| |||
2383 | 2392 | | |
2384 | 2393 | | |
2385 | 2394 | | |
| 2395 | + | |
| 2396 | + | |
| 2397 | + | |
| 2398 | + | |
2386 | 2399 | | |
| 2400 | + | |
| 2401 | + | |
| 2402 | + | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
2387 | 2408 | | |
2388 | 2409 | | |
2389 | 2410 | | |
| |||
2425 | 2446 | | |
2426 | 2447 | | |
2427 | 2448 | | |
2428 | | - | |
| 2449 | + | |
2429 | 2450 | | |
2430 | 2451 | | |
2431 | 2452 | | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
2432 | 2457 | | |
2433 | 2458 | | |
2434 | 2459 | | |
2435 | | - | |
2436 | 2460 | | |
2437 | 2461 | | |
2438 | 2462 | | |
2439 | | - | |
| 2463 | + | |
| 2464 | + | |
| 2465 | + | |
| 2466 | + | |
2440 | 2467 | | |
2441 | 2468 | | |
2442 | 2469 | | |
2443 | | - | |
2444 | | - | |
2445 | | - | |
2446 | | - | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
2447 | 2473 | | |
2448 | | - | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
2449 | 2486 | | |
2450 | 2487 | | |
2451 | 2488 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
75 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| |||
1500 | 1500 | | |
1501 | 1501 | | |
1502 | 1502 | | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
1503 | 1513 | | |
1504 | 1514 | | |
1505 | 1515 | | |
| |||
2126 | 2136 | | |
2127 | 2137 | | |
2128 | 2138 | | |
| 2139 | + | |
2129 | 2140 | | |
2130 | 2141 | | |
2131 | 2142 | | |
| |||
2273 | 2284 | | |
2274 | 2285 | | |
2275 | 2286 | | |
2276 | | - | |
| 2287 | + | |
| 2288 | + | |
| 2289 | + | |
| 2290 | + | |
2277 | 2291 | | |
2278 | 2292 | | |
2279 | 2293 | | |
| |||
2899 | 2913 | | |
2900 | 2914 | | |
2901 | 2915 | | |
| 2916 | + | |
2902 | 2917 | | |
2903 | 2918 | | |
2904 | 2919 | | |
| |||
3046 | 3061 | | |
3047 | 3062 | | |
3048 | 3063 | | |
3049 | | - | |
| 3064 | + | |
| 3065 | + | |
| 3066 | + | |
| 3067 | + | |
3050 | 3068 | | |
3051 | 3069 | | |
3052 | 3070 | | |
| |||
3647 | 3665 | | |
3648 | 3666 | | |
3649 | 3667 | | |
3650 | | - | |
| 3668 | + | |
| 3669 | + | |
| 3670 | + | |
| 3671 | + | |
| 3672 | + | |
| 3673 | + | |
| 3674 | + | |
| 3675 | + | |
| 3676 | + | |
3651 | 3677 | | |
3652 | 3678 | | |
3653 | 3679 | | |
| |||
8263 | 8289 | | |
8264 | 8290 | | |
8265 | 8291 | | |
| 8292 | + | |
8266 | 8293 | | |
8267 | 8294 | | |
8268 | 8295 | | |
| |||
8312 | 8339 | | |
8313 | 8340 | | |
8314 | 8341 | | |
| 8342 | + | |
| 8343 | + | |
| 8344 | + | |
| 8345 | + | |
| 8346 | + | |
| 8347 | + | |
| 8348 | + | |
| 8349 | + | |
| 8350 | + | |
| 8351 | + | |
| 8352 | + | |
| 8353 | + | |
| 8354 | + | |
8315 | 8355 | | |
8316 | 8356 | | |
8317 | 8357 | | |
| |||
9623 | 9663 | | |
9624 | 9664 | | |
9625 | 9665 | | |
9626 | | - | |
| 9666 | + | |
| 9667 | + | |
| 9668 | + | |
| 9669 | + | |
| 9670 | + | |
| 9671 | + | |
| 9672 | + | |
| 9673 | + | |
| 9674 | + | |
| 9675 | + | |
| 9676 | + | |
| 9677 | + | |
| 9678 | + | |
| 9679 | + | |
| 9680 | + | |
| 9681 | + | |
9627 | 9682 | | |
9628 | 9683 | | |
9629 | 9684 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
221 | 232 | | |
222 | 233 | | |
223 | 234 | | |
| |||
904 | 915 | | |
905 | 916 | | |
906 | 917 | | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
907 | 921 | | |
908 | 922 | | |
909 | 923 | | |
| |||
0 commit comments