Fix: Resolve Comment Draft Collisions by Using Full File Path (#370)
* fix(FilesView): use file path for drafts labeling Use file path for draft labels instead of file name for precise grouping Filter and associate drafts by file path to ensure correct per-file draft retrieval Improve handling of files with identical names across directories * fix(PierreDiffViewer): use fileName as label for drafts Use fileName as the draft label when editing or adding diffs Fallback to 'unknown' if fileName is missing for draft labels Align draft filtering to the provided fileName rather than basename * refactor(ui): remove unused fileLabel computation
This commit is contained in:
@@ -750,7 +750,7 @@ export const FilesView: React.FC = () => {
|
|||||||
addDraft({
|
addDraft({
|
||||||
sessionKey,
|
sessionKey,
|
||||||
source: 'file',
|
source: 'file',
|
||||||
fileLabel: selectedFile.name,
|
fileLabel: selectedFile.path,
|
||||||
startLine: finalRange.start,
|
startLine: finalRange.start,
|
||||||
endLine: finalRange.end,
|
endLine: finalRange.end,
|
||||||
code,
|
code,
|
||||||
@@ -1765,7 +1765,7 @@ export const FilesView: React.FC = () => {
|
|||||||
const sessionDrafts = allDrafts[sessionKey] ?? [];
|
const sessionDrafts = allDrafts[sessionKey] ?? [];
|
||||||
// Filter drafts for current file
|
// Filter drafts for current file
|
||||||
const fileDrafts = sessionDrafts.filter(
|
const fileDrafts = sessionDrafts.filter(
|
||||||
(d) => d.source === 'file' && d.fileLabel === selectedFile.name
|
(d) => d.source === 'file' && d.fileLabel === selectedFile.path
|
||||||
);
|
);
|
||||||
|
|
||||||
const widgets: BlockWidgetDef[] = [];
|
const widgets: BlockWidgetDef[] = [];
|
||||||
|
|||||||
@@ -264,7 +264,6 @@ export const PierreDiffViewer: React.FC<PierreDiffViewerProps> = ({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fileLabel = fileName ? fileName.split('/').pop() || 'unknown' : 'unknown';
|
|
||||||
// Pierre selection range: { start, end, side }
|
// Pierre selection range: { start, end, side }
|
||||||
// Store needs { startLine, endLine, side: 'original'|'modified' }
|
// Store needs { startLine, endLine, side: 'original'|'modified' }
|
||||||
// Pierre side: 'additions' (right) | 'deletions' (left)
|
// Pierre side: 'additions' (right) | 'deletions' (left)
|
||||||
@@ -275,7 +274,7 @@ export const PierreDiffViewer: React.FC<PierreDiffViewerProps> = ({
|
|||||||
|
|
||||||
if (editingDraftId) {
|
if (editingDraftId) {
|
||||||
updateDraft(sessionKey, editingDraftId, {
|
updateDraft(sessionKey, editingDraftId, {
|
||||||
fileLabel,
|
fileLabel: fileName || 'unknown',
|
||||||
startLine: targetRange.start,
|
startLine: targetRange.start,
|
||||||
endLine: targetRange.end,
|
endLine: targetRange.end,
|
||||||
side: storeSide,
|
side: storeSide,
|
||||||
@@ -287,7 +286,7 @@ export const PierreDiffViewer: React.FC<PierreDiffViewerProps> = ({
|
|||||||
addDraft({
|
addDraft({
|
||||||
sessionKey,
|
sessionKey,
|
||||||
source: 'diff',
|
source: 'diff',
|
||||||
fileLabel,
|
fileLabel: fileName || 'unknown',
|
||||||
startLine: targetRange.start,
|
startLine: targetRange.start,
|
||||||
endLine: targetRange.end,
|
endLine: targetRange.end,
|
||||||
side: storeSide,
|
side: storeSide,
|
||||||
@@ -436,7 +435,7 @@ export const PierreDiffViewer: React.FC<PierreDiffViewerProps> = ({
|
|||||||
|
|
||||||
const sessionDrafts = allDrafts[sessionKey] ?? [];
|
const sessionDrafts = allDrafts[sessionKey] ?? [];
|
||||||
// Match file label logic - use basename
|
// Match file label logic - use basename
|
||||||
const fileLabel = fileName ? fileName.split('/').pop() || 'unknown' : 'unknown';
|
const fileLabel = fileName || 'unknown';
|
||||||
const fileDrafts = sessionDrafts.filter((d) => d.source === 'diff' && d.fileLabel === fileLabel);
|
const fileDrafts = sessionDrafts.filter((d) => d.source === 'diff' && d.fileLabel === fileLabel);
|
||||||
|
|
||||||
const anns: DiffLineAnnotation<AnnotationData>[] = [];
|
const anns: DiffLineAnnotation<AnnotationData>[] = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user