fix(gateway): keep main sessions visible in active session lists#43984
fix(gateway): keep main sessions visible in active session lists#43984stim64045-spec wants to merge 2 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR fixes a regression where the default agent's main session ( Key changes:
Issue identified:
Confidence Score: 3/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/gateway/session-utils.ts
Line: 730
Comment:
**Stale sessions permanently pinned when custom `mainKey` is configured**
The condition `parsed.rest === normalizedMainKey || parsed.rest === "main"` has an unintended side-effect when a user configures a non-default `mainKey` (e.g. `cfg.session.mainKey = "primary"`):
- `normalizedMainKey` becomes `"primary"`
- `parsed.rest === normalizedMainKey` correctly pins `agent:X:primary` sessions
- **But** `|| parsed.rest === "main"` additionally pins any `agent:X:main` session from the old default key
This means that after a user migrates from the default `"main"` key to a custom one, their old stale `agent:X:main` sessions will be permanently exempt from `activeMinutes` filtering and will never disappear from the session list.
The fallback should only apply when no custom key has been configured:
```suggestion
return parsed.rest === normalizedMainKey || (normalizedMainKey !== "main" ? false : parsed.rest === "main");
```
Or more simply — since `normalizeMainKey` already returns `"main"` when `cfg.session?.mainKey` is unset — the extra `|| parsed.rest === "main"` clause is entirely redundant for the default case and harmful for the custom-key case:
```suggestion
return parsed.rest === normalizedMainKey;
```
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: 97e02ee |
src/gateway/session-utils.ts
Outdated
| return false; | ||
| } | ||
| const normalizedMainKey = normalizeMainKey(cfg.session?.mainKey); | ||
| return parsed.rest === normalizedMainKey || parsed.rest === "main"; |
There was a problem hiding this comment.
Stale sessions permanently pinned when custom mainKey is configured
The condition parsed.rest === normalizedMainKey || parsed.rest === "main" has an unintended side-effect when a user configures a non-default mainKey (e.g. cfg.session.mainKey = "primary"):
normalizedMainKeybecomes"primary"parsed.rest === normalizedMainKeycorrectly pinsagent:X:primarysessions- But
|| parsed.rest === "main"additionally pins anyagent:X:mainsession from the old default key
This means that after a user migrates from the default "main" key to a custom one, their old stale agent:X:main sessions will be permanently exempt from activeMinutes filtering and will never disappear from the session list.
The fallback should only apply when no custom key has been configured:
| return parsed.rest === normalizedMainKey || parsed.rest === "main"; | |
| return parsed.rest === normalizedMainKey || (normalizedMainKey !== "main" ? false : parsed.rest === "main"); |
Or more simply — since normalizeMainKey already returns "main" when cfg.session?.mainKey is unset — the extra || parsed.rest === "main" clause is entirely redundant for the default case and harmful for the custom-key case:
| return parsed.rest === normalizedMainKey || parsed.rest === "main"; | |
| return parsed.rest === normalizedMainKey; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/gateway/session-utils.ts
Line: 730
Comment:
**Stale sessions permanently pinned when custom `mainKey` is configured**
The condition `parsed.rest === normalizedMainKey || parsed.rest === "main"` has an unintended side-effect when a user configures a non-default `mainKey` (e.g. `cfg.session.mainKey = "primary"`):
- `normalizedMainKey` becomes `"primary"`
- `parsed.rest === normalizedMainKey` correctly pins `agent:X:primary` sessions
- **But** `|| parsed.rest === "main"` additionally pins any `agent:X:main` session from the old default key
This means that after a user migrates from the default `"main"` key to a custom one, their old stale `agent:X:main` sessions will be permanently exempt from `activeMinutes` filtering and will never disappear from the session list.
The fallback should only apply when no custom key has been configured:
```suggestion
return parsed.rest === normalizedMainKey || (normalizedMainKey !== "main" ? false : parsed.rest === "main");
```
Or more simply — since `normalizeMainKey` already returns `"main"` when `cfg.session?.mainKey` is unset — the extra `|| parsed.rest === "main"` clause is entirely redundant for the default case and harmful for the custom-key case:
```suggestion
return parsed.rest === normalizedMainKey;
```
How can I resolve this? If you propose a fix, please make it concise.
This comment was marked as spam.
This comment was marked as spam.
|
Addressed the custom Updated Focused |
Summary
sessions.listeven whenactiveMinuteshides stale conversationsmainsession alongside an activeheartbeatsessionFixes #43737.