Repository navigation
feat(web): show checkout details when hovering a sidebar thread #35281
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
Closed
+325
−35
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import { assert, it } from "@effect/vitest"; | ||
| import * as Effect from "effect/Effect"; | ||
| import * as FileSystem from "effect/FileSystem"; | ||
| import * as Layer from "effect/Layer"; | ||
| import * as NodeCrypto from "@effect/platform-node/NodeCrypto"; | ||
| import * as NodeServices from "@effect/platform-node/NodeServices"; | ||
| import * as GitVcsDriver from "../vcs/GitVcsDriver.ts"; | ||
| import * as ServerConfig from "../config.ts"; | ||
| import { readCheckoutDetails } from "./checkoutDetails.ts"; | ||
|
|
||
| it.live("reports the checked out revision, HEAD update time and exact origin/main divergence", () => | ||
| Effect.gen(function* () { | ||
| const fs = yield* FileSystem.FileSystem; | ||
| const cwd = yield* fs.makeTempDirectoryScoped(); | ||
| const git = yield* GitVcsDriver.GitVcsDriver; | ||
| const run = (args: readonly string[]) => | ||
| git.execute({ cwd, operation: "checkout-details-test", args }); | ||
| yield* run(["init", "--initial-branch=main"]); | ||
| yield* run(["config", "user.name", "Test"]); | ||
| yield* run(["config", "user.email", "test@example.com"]); | ||
| yield* run(["commit", "--allow-empty", "-m", "first"]); | ||
| const first = (yield* run(["rev-parse", "HEAD"])).stdout.trim(); | ||
| assert.isNull((yield* readCheckoutDetails(cwd))?.behindOriginMain); | ||
| yield* run(["commit", "--allow-empty", "-m", "second"]); | ||
| yield* run(["update-ref", "refs/remotes/origin/main", "HEAD"]); | ||
| yield* run(["checkout", "--detach", first]); | ||
| const details = yield* readCheckoutDetails(cwd); | ||
| assert.strictEqual(details?.commit, first); | ||
| assert.strictEqual(details?.behindOriginMain, 1); | ||
| assert.isTrue(Number.isFinite(Date.parse(details?.committedAt ?? ""))); | ||
| assert.isTrue(Number.isFinite(Date.parse(details?.headUpdatedAt ?? ""))); | ||
| yield* run(["checkout", "main"]); | ||
| assert.strictEqual((yield* readCheckoutDetails(cwd))?.behindOriginMain, 0); | ||
| }).pipe( | ||
| Effect.scoped, | ||
| Effect.provide( | ||
| GitVcsDriver.layer.pipe( | ||
| Layer.provideMerge( | ||
| ServerConfig.layerTest(process.cwd(), { prefix: "checkout-details-test-" }), | ||
| ), | ||
| Layer.provideMerge(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer)), | ||
| ), | ||
| ), | ||
| ), | ||
| ); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import * as Effect from "effect/Effect"; | ||
| import * as GitVcsDriver from "../vcs/GitVcsDriver.ts"; | ||
|
|
||
| export const readCheckoutDetails = Effect.fn("GitManager.readCheckoutDetails")(function* ( | ||
| cwd: string, | ||
| ) { | ||
| const git = yield* GitVcsDriver.GitVcsDriver; | ||
| const read = (args: readonly string[]) => | ||
| git.execute({ operation: "GitManager.readCheckoutDetails", cwd, args, allowNonZeroExit: true }); | ||
| const head = yield* read(["log", "-1", "--format=%H%n%cI", "HEAD", "--"]); | ||
| const [commit = "", committedAt = ""] = head.stdout.trim().split("\n"); | ||
| if (head.exitCode !== 0 || !commit) return undefined; | ||
| const reflog = yield* read(["reflog", "-1", "--format=%gD", "--date=iso-strict", "HEAD"]); | ||
| const origin = yield* read(["rev-parse", "--verify", "--quiet", "refs/remotes/origin/main"]); | ||
| const originMainCommit = origin.exitCode === 0 ? origin.stdout.trim() : null; | ||
| const behind = originMainCommit | ||
| ? yield* read(["rev-list", "--count", `HEAD..${originMainCommit}`, "--"]) | ||
| : null; | ||
| const count = behind?.exitCode === 0 ? Number(behind.stdout.trim()) : NaN; | ||
| return { | ||
| commit, | ||
| committedAt, | ||
| headUpdatedAt: /\{([^}]+)\}/.exec(reflog.stdout)?.[1] ?? null, | ||
| originMainCommit, | ||
| behindOriginMain: Number.isSafeInteger(count) && count >= 0 ? count : null, | ||
| }; | ||
| }); |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
🟡 Medium
vcs/VcsStatusBroadcaster.ts:954A detailed stream can emit a snapshot with checkout details and then deliver an older queued
localUpdatedevent without those details, removing the hover card’s version, dates, and comparison until another refresh. The in-flight refresh may have sampledcheckoutDetailDemandRefbefore this subscriber retained demand, and subscribing before reading the snapshot queues its event; serialize the detailed initial read withlocalRefreshLocksand ensure queued pre-snapshot updates cannot replace the detailed state.🤖 Copy this AI Prompt to have your agent fix this: