Repository navigation
fix: Stop naming sessions /clear and refresh stale harvested titles #1761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -477,12 +477,20 @@ func promptCandidate(text string) (string, bool) { | |
| candidate = stripWrapperTag(text) | ||
| } | ||
| candidate = cutTrailingHarness(candidate) | ||
| if isSyntheticPrompt(candidate) { | ||
| if isSyntheticPrompt(candidate) || isClear(candidate) { | ||
| return "", false | ||
| } | ||
| return candidate, true | ||
| } | ||
|
|
||
| // isClear reports whether s is the /clear command. /clear resets the session, so it names nothing: | ||
| // Claude Code writes it as the first user turn of the NEW transcript, before the user asks anything, | ||
| // and a session left idle after it was titled "/clear". | ||
| func isClear(s string) bool { | ||
| f := strings.Fields(s) | ||
| return len(f) > 0 && f[0] == "/clear" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: |
||
| } | ||
|
|
||
| // isSyntheticPrompt reports whether s READS AS markup Claude Code inserted rather than as something | ||
| // the user typed. | ||
| // | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This stays
truefor good when the harvester cannot refresh the entry. The case is a live row whoseLogFilesits under a config dir other than the oneclaude.Harvestscans, e.g. the entry was written with a differentCLAUDE_CONFIG_DIRand is carried forward by the merge.ReadSessionsnever sees that file, soLogModTimenever advances, and every settled pause in that session starts a harvest. The backoff bounds it at one walk peruntitledBackoffCap, the same steady state the served-title rows already accept, so this is not blocking. Two possible fixes: a sentence in the doc comment, or skipping whenmeta.AgentConfigDirdiffers from the dir the harvester reads. Separately, "One Stat per named live row per tick" overstates the cost. The gate evaluatesuntitledSettledonly afternow.Sub(m.lastHarvest) >= wait, so it is one Stat per row per backoff window.