-
Notifications
You must be signed in to change notification settings - Fork 765
Ability to drag changes to start a commit #12176
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 | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,7 +1,10 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import { FileChangeDropData, FolderChangeDropData, HunkDropDataV3 } from '$lib/dragging/draggables'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import { updateStackPrs } from '$lib/forge/shared/prFooter'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import type { DropzoneHandler } from '$lib/dragging/handler'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import type { ForgePrService } from '$lib/forge/interface/forgePrService'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import type { UncommittedService } from '$lib/selection/uncommittedService.svelte'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import type { StackService } from '$lib/stacks/stackService.svelte'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import type { UiState } from '$lib/state/uiState.svelte'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| export class BranchDropData { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| constructor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -62,3 +65,66 @@ export class MoveBranchDzHandler implements DropzoneHandler { | |||||||||||||||||||||||||||||||||||||||||||||||||
| await updateStackPrs(this.prService, branchDetails, this.baseBranchName); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| export class StartCommitDzHandler implements DropzoneHandler { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| constructor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| private readonly uiState: UiState, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| private readonly uncommittedService: UncommittedService, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| private readonly projectId: string, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| private readonly stackId: string | undefined, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| private readonly branchName: string | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) {} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| print(): string { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return `StartCommitDzHandler(${this.projectId}, ${this.stackId}, ${this.branchName})`; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| accepts(data: unknown): boolean { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (data instanceof FileChangeDropData || data instanceof FolderChangeDropData) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // Only accept uncomitted files/folders | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (data.isCommitted) return false; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // Only accept unassinged files/folders or those assigned to the same stack | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| // Only accept unassinged files/folders or those assigned to the same stack | |
| // Only accept unassigned files/folders or those assigned to the same stack |
Copilot
AI
Feb 3, 2026
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.
There are two spelling errors in the comments: "uncomitted" should be "uncommitted" and "unassinged" should be "unassigned".
| // Only accept uncomitted files/folders | |
| if (data.isCommitted) return false; | |
| // Only accept unassinged files/folders or those assigned to the same stack | |
| // Only accept uncommitted files/folders | |
| if (data.isCommitted) return false; | |
| // Only accept unassigned files/folders or those assigned to the same stack |
Copilot
AI
Feb 3, 2026
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.
The return type Promise<true> is overly specific. Since this method always returns true and doesn't seem to need a return value, consider changing the return type to Promise<void> and removing the return true statements. This would make the intent clearer that this method is called for its side effects rather than its return value.
| ): Promise<true> { | |
| if (data instanceof FileChangeDropData || data instanceof FolderChangeDropData) { | |
| const changes = await data.treeChanges(); | |
| const paths = changes.map((c) => c.path); | |
| if (paths.length === 0) return true; | |
| this.uncommittedService.checkFiles(data.stackId ?? null, paths); | |
| return true; | |
| } | |
| // Handle hunk data | |
| this.uncommittedService.checkHunk(data.stackId ?? null, data.change.path, data.hunk); | |
| return true; | |
| ): Promise<void> { | |
| if (data instanceof FileChangeDropData || data instanceof FolderChangeDropData) { | |
| const changes = await data.treeChanges(); | |
| const paths = changes.map((c) => c.path); | |
| if (paths.length === 0) return; | |
| this.uncommittedService.checkFiles(data.stackId ?? null, paths); | |
| return; | |
| } | |
| // Handle hunk data | |
| this.uncommittedService.checkHunk(data.stackId ?? null, data.change.path, data.hunk); | |
| return; |
Copilot
AI
Feb 3, 2026
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.
The order of operations may cause a race condition. The method calls startCommitting() to set the UI state to commit mode, then immediately calls checkDropData() to stage the changes. However, if the UI responds to the state change before the changes are checked/staged, users might see an empty commit form briefly. Consider awaiting checkDropData() before calling startCommitting() to ensure the changes are staged before the commit UI appears.
| this.startCommitting(); | |
| await this.checkDropData(data); | |
| await this.checkDropData(data); | |
| this.startCommitting(); |
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.
Spelling error: "uncomitted" should be "uncommitted"