dream-num / dream-num/cli

Orphan chart drawing remains visible and cannot be deleted from CLI package

Open
#32 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

# Orphan chart drawing remains visible and cannot be deleted

## Environment

- Univer CLI: `0.4.0`
- Viewer: local Collab Gateway Viewer at `http://127.0.0.1:9123/`
- Reproduction package: `harbourline-q3-qbr-deep-ocean.univer`
- Target Sheet unit: `Ct1A0c` (`Harbourline Q3 QBR`)
- Worksheet: `Chart Gallery`
- Diagnostic worktree: `wt-mshcgd6y-xpojxs` (`remove-doc-ghost-chart-frame`)

## Summary

The CLI package contains stale `DRAWING_CHART` anchors whose chart resources no longer exist. The Viewer still renders the orphan anchors as selectable chart frames behind an embedded Doc. The chart menu offers **Delete chart**, but deletion has no effect and the frames return after reload.

## Steps to reproduce with the attached file

1. Unzip `harbourline-q3-qbr-orphan-chart-repro.zip`.
2. Open the resulting `.univer` package in Univer CLI 0.4.0 Viewer.
3. Open unit `Ct1A0c` and select the `Chart Gallery` worksheet.
4. Select the empty chart frame behind the embedded Doc near rows 5–20.
5. Open the chart menu and choose **Delete chart**.
6. Reload the Viewer.

## Actual result

- The empty chart frame remains visible and selectable.
- The Viewer identifies it as a chart and continues to offer **Delete chart**.
- `sheet.charts.remove(orphanDrawingId)` returns `false`.
- `sheet.getDrawingLayout()` continues to return the orphan `DRAWING_CHART` entry.
- No public generic drawing-removal API is exposed for deleting the orphan independently of the missing chart resource.

## Diagnostic evidence

- Valid chart resources on `Chart Gallery`: **12**.
- Orphan `DRAWING_CHART` anchors present in the drawing layout: **13**.
- Three orphan anchors overlap the embedded Doc near row 5.
- All 12 valid charts retained their source ranges and resolved without diagnostics.
- Formula errors after recalculation: **0**.
- Key values remained unchanged: `$1,140,562` and `$1,405,552`.
- The embedded Doc remained present at the same bounds.

## Expected result

Choosing **Delete chart** should remove the selected drawing anchor even if the matching chart resource is already missing.

One of the following would resolve the issue:

1. Make **Delete chart** fall back to deleting the orphan drawing anchor.
2. Detect and clean orphan chart drawings when loading a CLI package.
3. Expose a public API that removes a Sheet drawing by ID independently of the chart collection.

## Temporary workaround

Moving each orphan drawing off-canvas and reducing it to `1 x 1` removes the visible artifact:

```ts
sheet.setDrawingPlacement(orphanDrawingId, {
kind: UniverAPI.Enum.SheetDrawingAnchorType.Position,
from: {
row: 0,
column: 0,
rowOffset: -1000,
columnOffset: -1000,
},
width: 1,
height: 1,
});
```

This only hides the orphan. It does not delete the stale drawing record.

## Impact

CLI-generated or edited packages can retain undeletable chart frames that overlap embedded Docs or other floating objects. The UI presents a deletion action that silently cannot complete, leaving the package with persistent orphan drawing records.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by loading harbourline-q3-qbr-orphan-chart-repro.zip in the Univer CLI Viewer and inspect sheet.getDrawingLayout() alongside sheet.charts.remove(orphanDrawingId). Compare the selected orphan anchor with the 12 valid chart resources. Done means Delete chart removes the selected orphan drawing, the change persists after reload, and valid charts and the embedded Doc remain unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.