Repository navigation
refactor(dashboard): replace Monaco editor with stream-diffs surfaces #11352
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
Draft
Simon-He95
wants to merge
3
commits into
AstrBotDevs:master
Choose a base branch
from
Simon-He95:feat/dashboard-replace-monaco-with-stream-diffs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+392
−302
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🟠 High · Select-all edits retain old text
When a user selects all editor contents and types several characters consecutively, the edit callback accepts the surface's contents without correcting the known select-all replacement defect, so typing several characters after selecting all leaves trailing tokens from the previous document in the editor; users can save corrupted text.
Upgrade or patch the underlying edit surface so select-all followed by consecutive typing fully replaces the selection before enabling this editor in the dashboard.
Also at
dashboard/src/components/shared/StreamDiffsEditor.vue:96-98.Prompt for AI agents
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.
Not fixed here on purpose — this is an upstream
@pierre/diffs1.7.1 defect, not something this wrapper introduced, and it is already documented in the PR description under "Known limitation".Repro on a bare
createDiffSurfacewith no Vue wrapper and no app code: select-all, then per-key typing leaves the trailing characters of the previous document; a single key press over the same selection replaces correctly, and paste/IME (insertText) replaces correctly. AsetEdges/selection workaround was tried and made it worse (text inserted at the start of the document), so I dropped it rather than ship a hack.The auto-format path is not exposed to this:
replaceAll()applies one explicit full-range edit, andapplyEditsis exact. So the blast radius is "user selects all and types several characters by hand" in the 8 editable surfaces.Agreed this needs a fix, but the fix belongs in
stream-diffs. Happy to keep this PR open until that lands if you would rather gate the merge on it — just say which you prefer.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.
Thanks for confirming it reproduces on the bare surface. Please keep the PR gated until
stream-diffsfixes this or there’s a reliable workaround: the bug affects the editable surfaces and can leave stale text in content users may save, so documenting it alone isn’t enough. Once addressed upstream, please add a regression check for select-all followed by consecutive typing.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.
Updating this thread with new evidence — my first reply undersold the bug, and the PR description has been rewritten accordingly.
It reproduces in the real dashboard, on the File surface, at every document size. Driven end-to-end on this branch (
/data/conversations/legacy→ view → Edit Conversation), real Chromium, mocked/api/**, seeded withJSON.stringify(history, null, 2), select-all then typing{"b":2}character by character:{"b":2}"}{"b":2}"}{"b":2}+ the whole original document{"b":2}+ the whole original document{"b":2}+ the whole original documentrows rendered == document linesin every row, so my earlier assumption that this needed a virtualized surface was wrong. This is not a rendering artifact either — the editor model is corrupted: pressing Save Changes shows "Invalid JSON format" and sends no request, while the control case (same select-all, content delivered as oneinsertText) formats and saves normally viaPUT /api/v1/conversations/{cid}/messages.It is upstream, and not reachable from either wrapper.
stream-diffshas no select-all code at all (grep -rn selectAll src/ dist/→ nothing);src/edit.tsisexport * from '@pierre/diffs/edit', andDiffSurfaceController.startEditing()only constructs the upstreamEditorand callseditor.edit(instance).cmd/ctrl+Ais an upstream keybinding command (dist/editor/command.jsmaps it toselectAll; the editor's ownkeydownlistener runs the private#runCommand('selectAll')). The race is inside@pierre/diffs:selectAllsets the whole-document selection, thenfocus()collapses the native selection, then it widens the native selection only to the rendered range with#suppressNativeSelectionSync = true— and thekeydownhandler clears that flag as its first statement, so a queuedselectionchangedispatched after the first keystroke is read back over#selections.#selections,#suppressNativeSelectionSyncand#runCommandare all#private, so neitherstream-diffsnorStreamDiffsEditor.vuecan fix or shim it; a programmaticsetEditorSelectionssubstitute was tried and made it worse (text inserted at the start of the document), which is why I did not ship one.On your gating request: agreed, and I am not asking to merge around it. An upstream issue is being filed with this repro and the proposed fix (stop clearing the suppression flag on
keydown, clear it once the edit completes, and stopselectAllfrom being collapsed by its ownfocus()), plus a regression check that types several characters over a select-all selection at 7 / 27 / 202 lines as you asked. The PR description now carries the evidence table, the mechanism, the blast radius (JSON surfaces block the save; the T2I template and skills editors have no JSON gate and are unverified — flagged as a risk), and an explicit "merge only if you accept this, or wait for the upstream fix" note.I would rather this PR stayed blocked until the upstream fix lands. If a reviewer prefers to take it earlier, the honest framing is that it moves nine dashboard editors onto a known data-integrity bug.
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.
Root cause found and mitigated in
77c94f5— and one correction to my previous reply.The root cause is auto-surround, not a selection race.
@pierre/diffsauto-surrounds any non-collapsed selection, including one spanning the whole document: typing{aftercmd/ctrl+Aproduces{<whole document>}instead of replacing it, and the caret then sits just after the inserted opener, so every following character lands near the start of the buffer while the original content stays.A/B on the same harness (history editor, real Chromium, mocked
/api/**, select-all then typing{"b":2}one key at a time), three consecutive runs with identical results:autoSurroundautoSurround: 'never'Invalid JSON format, 0 requests){"b":2}→ formatted → savedTyping
{alone over the select-all: default wraps the whole document (length +1),'never'replaces it (length 1).The fix in this PR:
StreamDiffsEditor.vuenow passesautoSurround: 'never'tostartEditing(). It removes the symptom entirely and matches Monaco's behaviour (Monaco never wrapped a selection), so it is not a behaviour change users would notice. It is a mitigation — the surprising default is still upstream, tracked in pierrecomputer/pierre#1338 with this evidence and a suggested fix.Correction: my previous reply described a second defect — a
selectionchangeread-back race in#runCommand('selectAll'). That came from a hacked local build where I had forced the auto-surround helper to return early, not from the public option. WithautoSurround: 'never'the select-all path behaved correctly at every size. I have corrected the PR description too: those code paths are worth upstream attention, but this PR makes no claim that they misbehave on their own. Mode B was my instrumentation, not your product.Residual risk, stated plainly: the A/B was measured on the conversation history editor; the other eight surfaces share the same wrapper and therefore the same option but were not re-measured. The T2I template editor and skills editor have no JSON gate, so a corrupted document there would still save silently — not re-driven after this change.
Gates on the pushed commit:
pnpm run i18n:checkPASS,pnpm run build(includesvue-tsc --noEmit) exit 0.Given the symptom is now gone and the mechanism is understood, I would treat the gating request as satisfiable by this commit plus the upstream issue — but say the word if you would rather keep it blocked until #1338 ships.
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 current wrapper sets
autoSurround: 'never'for every edit session, addressing the select-all replacement failure. This resolves my gating concern for this PR; thanks for the reproduction and follow-up evidence.