Repository navigation
fix(local): resolve a duplicated session id to its most recently modified copy - #87
Open
malihashar wants to merge 1 commit into
Open
malihashar wants to merge 1 commit into
malihashar wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #88
What is wrong
Sometimes the same session id exists in more than one folder, for example when a session is resumed from another directory. When you run
view,export,continueorcropwith that id, txcript has to pick one copy.The code comments say it picks the newest copy. It does not. The list of sessions is sorted by start time only, and copies of the same session have the same start time. So the winner is decided by the order the folders are read from disk, which is arbitrary. You can silently get an older, shorter copy, with no message.
How to see it
txcript query "<text from the later messages>". It finds the text.txcript view <id>,export <id>orcontinue <id>. The later messages are missing, because the older copy was loaded.What this PR changes
Among copies with the same start time, the one that was changed most recently now comes first. This is a second sort key in
src/local.rs, using the file modification time that txcript already records. Because every command picks the first match from that list, all of them get the fix at once. If the modification time is missing or equal, the order stays the same as before.Nothing else changes: no new option, no new dependency, and different ids that share a prefix are still reported as ambiguous. I also added one sentence to
docs/usage.mdand an entry inCHANGELOG.md.How it was tested
src/local.rs.cli/tests/duplicate_ids.rs. They run the real binary on synthetic sessions with four copies, where the modification times are set on purpose so they do not match the folder order. They coverview,export, prefix lookup, still-ambiguous different ids, and equal modification times.view,exportand prefix tests fail. After the fix, everything passes. I ran them five times each with the same result.cargo fmtandcargo clippyare clean.What I could not test
read_sessiontool and the interactive picker. They use the same lookup, but I did not run them directly.Questions for the maintainer
listshow each copy as a separate row (as now), or collapse them into one?cli/tests/an acceptable place for tests that run the binary? I added a short note about it intests/README.md.