fix(daemon): recover stash target oid when last stash is popped - #59
Draft
posthog[bot] wants to merge 1 commit into
Draft
posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
Popping or dropping the last stash deletes both `refs/stash` and its reflog. Both trace-payload stash resolvers read those files from disk, so each returned an error and logged at error level, which the telemetry bridge reported as an exception — two per occurrence, on an ordinary action. Wire the daemon's existing rewrite-history fallback (`inferred_top_stash_sha_from_rewrite_history`, already used by the event builder) into both payload resolvers via a shared `recover_top_stash_target_oid_from_history` helper. For a top-of-stack target, an on-disk miss now recovers the sha from history, or returns a benign `None` that the event builder still fills, instead of erroring. Non-top-of-stack targets still surface as errors. Attribution was already correct because the event builder had the fallback; this removes the error-level telemetry noise and populates the intermediate stash target oid on the affected traces. Generated-By: PostHog Desktop Task-Id: 398311fd-9505-4892-8aea-aa1f97fddd24
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.
Problem
.git/refs/stashand.git/logs/refs/stashwhen the last stash leaves the stack. Both trace-payload resolvers read those files from disk, so both fail on the same command and each logs at error level; the telemetry bridge turns each into an$exception. That is why the two issues always arrive as a pair, ~1s apart, for the same worktree.Changes
recover_top_stash_target_oid_from_historyhelper that reuses the daemon's existing rewrite-history fallback (inferred_top_stash_sha_from_rewrite_history) — the same recovery the event builder already relied on.resolve_stash_target_oid_for_commandand the pop/drop/branch arm ofresolve_stash_target_oid_for_terminal_payload: on an on-disk miss for a top-of-stack target, recover the sha from history, or return a benignNone(which the event builder still fills) instead of erroring.stash@{2}) still return an error — those genuinely cannot be recovered from history.StashOperation::Applyfallback at the new helper too, so there is one copy of the recovery expression.Impact
autter_stash_target_oidon the affected traces.Tests
refs/stashand its reflog are absent; one asserts a non-top-of-stack reference still errors.cargo check --locked --all-targets(the CI job) and the existing stash integration suite pass.Agent context
recover_*helper plus an inline gate reads cleaner than a combinator.Created with PostHog Desktop from this inbox report.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.