Repository navigation
Conversation
… base are not displayed
| :class="{ 'cursor-pointer': !isWorkspaceSharedResource(), selectable: batchMode, active: batchMode && selectedParagraphIds.includes(paragraph.id), disabled: !paragraph.is_active }" | ||
| @click="handleClickParagraphCard(paragraph)" | ||
| > | ||
| <div |
There was a problem hiding this comment.
Here's my review of the changes:
Summary
The diff adds a "shared workspace resource" guard that disables paragraph interaction (opening detail, pointer cursor) when the workspace is a shared read-only resource. This is generally reasonable but has a few issues.
Issues & Suggestions
-
Inconsistent gating — click handler not guarded
- You remove
cursor-pointerand blockhandleOpenParagraphDetail, but@click="handleClickParagraphCard(paragraph)"still fires. IfhandleClickParagraphCardinternally callshandleOpenParagraphDetail, that's fine; but if it triggers other side effects (selection, navigation), those will still run in shared mode. - Suggestion: Verify
handleClickParagraphCardrespectsisWorkspaceSharedResource(), or guard at that level for a single source of truth.
- You remove
-
Batch mode / selection may still be allowed
- The
selectableandactiveclasses are untouched. In shared mode withbatchMode, users can still select paragraphs (checkbox, highlight). Confirm whether batch operations should be disabled in shared mode too — if so, add a guard wherebatchModeis entered/enabled.
- The
-
Repeated
isWorkspaceSharedResource()calls- It's called inline in template (
:class) on every render, potentially per card. If it's a cheap computed getter this is fine; if it does any meaningful work (e.g., reading route/store traversal), consider exposing a computed likeisReadOnlyorcanEditParagraphsonce and reuse it in both template and methods. - Suggestion:
then use
const isReadOnly = computed(() => isWorkspaceSharedResource())
isReadOnly.value/isReadOnlyconsistently.
- It's called inline in template (
-
Naming / semantics
isWorkspaceSharedResource()returning "should not edit" is an indirect signal. A dedicated predicate likeisReadOnlyView()orcanInteractWithParagraph()would make intent clearer at call sites.
-
UX feedback
- Silently ignoring the click may confuse users. Consider showing a tooltip ("Shared workspace – read only") on hover when shared, rather than just removing the pointer cursor.
-
Template class binding readability
- The ternary-in-object-key form works but is less readable. Also mixing
cursor-pointerinto an object key while other entries are static is fine but slightly inconsistent with prior style. Optional::class="[ { 'cursor-pointer': !isReadOnly }, { selectable: batchMode, active: batchMode && selectedParagraphIds.includes(paragraph.id), disabled: !paragraph.is_active } ]"
- The ternary-in-object-key form works but is less readable. Also mixing
-
disabledclass vs shared-mode visual state- When
!paragraph.is_active, a.disabledstyle is applied. In shared mode, cards are also effectively non-interactive but get no visual cue besides missing pointer cursor. Consider adding a subtle shared/read-only visual state for consistency.
- When
-
Guard placement in
handleOpenParagraphDetail- Early-return happens before
editDialogMounted.value = trueandnextTick()— good, avoids mounting the dialog unnecessarily. ✅ No issue here.
- Early-return happens before
Minor Nit
- The
if (loading.value || isWorkspaceSharedResource()) returnline now silently blocks opening the detail dialog even indetailmode (not justedit). If viewing details was intended to remain available in shared mode (read-only viewing), this is a behavior change worth confirming. If detail viewing should still be allowed, separate the guard:if (loading.value) return if (initialMode === 'edit' && isWorkspaceSharedResource()) return
Overall: Functionally OK, but the main risk is partially gated interactions (click handler, batch selection) and a possible unintended block on read-only viewing. Clarify the intended UX and centralize the read-only check.
| :row-class-name="imageRowClassName" | ||
| resizable | ||
| > | ||
| <el-table-column type="selection" width="40" reserve-selection v-if="!isWorkspaceSharedResource()" /> |
There was a problem hiding this comment.
Code Review
1. Bug: isWorkspaceSharedResource guard is inverted in handleOpenParagraph
if (isWorkspaceSharedResource() || loading.value || ...) returnThis means when the resource is a workspace-shared resource, clicking a row does nothing. Combined with the template change (imageRowClassName returns 'cursor-pointer' only when not shared), this appears to be the intention — but verify it against the original behavior.
Issue: In the original code, row-class-name="cursor-pointer" was applied unconditionally, and handleOpenParagraph did not check isWorkspaceSharedResource(). So previously, clicking a row on a shared resource apparently did open the paragraph dialog. This patch silently disables that feature for shared resources.
- If disabling is intended → fine, but confirm the product requirement.
- If not → remove the
isWorkspaceSharedResource()check fromhandleOpenParagraph.
2. Column config inconsistency (likely bug)
The el-table-column type="selection" is conditionally rendered with v-if="!isWorkspaceSharedResource()", but the row-click guard also checks column?.type === 'selection'. Since selection columns are hidden for shared resources, the column?.type === 'selection' branch is dead code in that path. Not harmful, but redundant given the new early return.
3. Naming
imageRowClassName is misleading — there's no logic about images here, just pointer-cursor styling. Prefer:
const rowClassName = computed(() =>
isWorkspaceSharedResource() ? '' : 'cursor-pointer',
)or clickableRowClassName.
4. Reactive dependency concern
isWorkspaceSharedResource() is called inside a computed. If it reads reactive refs/state, this works; if it reads non-reactive values (e.g., a module-level flag or route params cached once), the computed will never invalidate and the class may become stale. Verify isWorkspaceSharedResource actually touches reactive sources, otherwise consider using a plain function in the binding instead of computed.
5. Minor: empty string vs null
Returning '' for the class name is fine in Element Plus. Returning null would also work, but '' is safer across render paths.
6. Guard order / performance
In handleOpenParagraph, the cheap synchronous checks are first — good. However, operationLoading.value = true is set after early returns but before the async call; ensure the .finally() (or .catch) resets it. If the promise rejects without resetting, subsequent clicks lock the UI. Confirm the reset exists (not shown in the diff).
Summary
| Severity | Item |
|---|---|
| Behavior change for shared resources — confirm intent (item 1) | |
| 🟡 Low | Rename imageRowClassName (item 3) |
| 🟡 Low | Verify isWorkspaceSharedResource reactivity inside computed (item 4) |
| ℹ️ Info | Dead column?.type === 'selection' branch for shared resources (item 2) |
| ℹ️ Info | Verify operationLoading reset on error (item 6) |
fix: details for document segments and images in the shared knowledge base are not displayed