feat: inline chunk editor and table batch ops with undo/redo#3504
Conversation
Replace modal-based chunk editing/creation with inline editor following the files tab pattern (state-based view toggle with ResourceHeader). Add batch update API endpoint, undo/redo support, and Popover-based context menus for tables. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Refactors Knowledge Base documents list and Document chunk list/editor onto the shared Replaces Written by Cursor Bugbot for commit bb73f62. Configure here. |
Icons were incorrectly carried over from the DropdownMenu migration. PopoverItems in this codebase use text-only labels. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The table-level context menu was incorrectly migrated to Popover during conflict resolution. Only the row-level context menu uses Popover; the table context menu should remain DropdownMenu with icons, matching the base branch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@greptile |
|
@cursor review |
apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/document.tsx
Show resolved
Hide resolved
apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/document.tsx
Outdated
Show resolved
Hide resolved
Prevent indefinite polling if page data never loads during chunk navigation across page boundaries. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Greptile SummaryThis PR delivers three major features: an inline chunk editor replacing the Key points:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant U as User
participant Doc as Document.tsx
participant CE as ChunkEditor
participant API as POST /api/.../chunks
participant Store as QueryCache
U->>Doc: Click "New chunk"
Doc->>Doc: setIsCreatingNewChunk(true)
Doc-->>CE: render ChunkEditor (mode=create)
U->>CE: type content, Cmd+S
CE->>API: createChunk(content)
API-->>CE: { id: newChunkId }
CE->>Store: invalidateQueries (async)
CE->>Doc: onCreated(newChunkId)
Doc->>Doc: handleChunkCreated runs\n(totalPages = stale value)
Doc->>Doc: goToPage(staleTotalPages)
Note over Doc: If new chunk is on page N+1\nbut code navigates to page N,\nselectedChunk = null → stuck spinner
U->>Doc: (Table view) right-click row
Doc->>Doc: handleChunkContextMenu(e, rowId)
Doc-->>Doc: setContextMenuChunk(chunk)
U->>Doc: click "Edit"
Doc->>Doc: setSelectedChunkId(chunk.id)
Doc-->>CE: render ChunkEditor (mode=edit)
U->>CE: edit content, Cmd+S
CE->>API: updateChunk(chunkId, content)
API-->>CE: success
CE->>Store: invalidateQueries (async)
Doc->>Doc: setSaveStatus("saved")
Last reviewed commit: bb73f62 |
apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/document.tsx
Show resolved
Hide resolved
apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/document.tsx
Show resolved
Hide resolved
apps/sim/app/workspace/[workspaceId]/components/resource/resource.tsx
Outdated
Show resolved
Hide resolved
After creating a chunk, navigate to the last page (where new chunks append) before selecting it. This prevents the editor from showing "Loading chunk..." when the new chunk is not on the current page. The loading state breadcrumb remains as an escape hatch for edge cases. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a .refine() check to reject duplicate rowIds in batch update requests, consistent with the positions uniqueness check on batch insert. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix disableEdit logic: use || instead of && so connector doc chunks cannot be edited from context menu (row click still opens viewer) - Add uniqueness validation for rowIds in BatchUpdateByIdsSchema - Fix inconsistent bg token: bg-background → bg-[var(--bg)] in Pagination Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@greptile |
|
@cursor review |
The refine was applied both on the inner updates array and the outer object. Keep only the inner array refine which is cleaner. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix stale rowId after create-row redo: patch undo stack with new row ID using patchUndoRowId so subsequent undo targets the correct row - Fix text color tokens in Pagination: use CSS variable references (text-[var(--text-body)], text-[var(--text-secondary)]) instead of Tailwind semantic tokens for consistency with the rest of the file Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove unused `onAddData` prop and `isEmptyCell` variable from row context menu (introduced in PR but never wired to JSX). Fix type errors in optimistic update spreads by removing unnecessary `as Record<string, unknown>` casts that lost the RowData type. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Addressed the dead |
|
@greptile |
|
@cursor review |
apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/document.tsx
Show resolved
Hide resolved
...workspace/[workspaceId]/knowledge/[id]/[documentId]/components/chunk-editor/chunk-editor.tsx
Outdated
Show resolved
Hide resolved
…d-forget goToPage calls ChunkEditor.handleSave now throws on empty/oversized content instead of silently returning, so the parent's catch block correctly sets saveStatus to 'error'. Also added explicit `void` to unawaited goToPage(1) calls in filter handlers to signal intentional fire-and-forget. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/document.tsx
Show resolved
Hide resolved
apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/document.tsx
Show resolved
Hide resolved
…case When creating a chunk that spills onto a new page, totalPages in the closure is stale. Now polls displayChunksRef for the new chunk, and if not found, checks totalPagesRef for an updated page count and navigates to the new last page before continuing to poll. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
EditChunkModalandCreateChunkModalwith an inline editor that renders within the Resource layout, matching the Files tab pattern (state-based view toggle withResourceHeader+ChunkEditor)useTableUndohook and Zustand store, and batch insert with position supportTest plan