-
Notifications
You must be signed in to change notification settings - Fork 500
Fix/terminal background color detection #2461
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ function CodeEditPreview({ model }: SpecializedViewProps) { | |
| const fileContent = useAtomValue(model.fileContent); | ||
| const setNewFileContent = useSetAtom(model.newFileContent); | ||
| const fileInfo = useAtomValue(model.statFile); | ||
| const fileName = fileInfo?.path || fileInfo?.name; | ||
|
|
||
| function codeEditKeyDownHandler(e: WaveKeyboardEvent): boolean { | ||
| if (checkKeyPressed(e, "Cmd:e")) { | ||
|
|
@@ -65,6 +66,7 @@ function CodeEditPreview({ model }: SpecializedViewProps) { | |
| <CodeEditor | ||
| blockId={model.blockId} | ||
| text={fileContent} | ||
| fileName={fileName} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify fileName prop integration with CodeEditor. The Confirm that the CodeEditor component properly handles the case when 🏁 Script executed: #!/bin/bash
# Verify CodeEditor's handling of fileName prop and editorPath stability
# Check how editorPath is used and whether it updates when fileName changes
ast-grep --pattern $'const editorPath = $$$'
# Search for Monaco Editor path prop usage
rg -nP --type=tsx --type=ts -C3 '\bpath\s*=\s*\{?\s*editorPath'Length of output: 147 I found that 🏁 Script executed: #!/bin/bash
# Examine the CodeEditor component to understand fileName prop and editorPath handling
# View the CodeEditor component around the editorPath definition
echo "=== CodeEditor component (lines 110-150) ==="
sed -n '110,150p' frontend/app/view/codeeditor/codeeditor.tsx
# Search for all uses of editorPath within CodeEditor to see if it updates reactively
echo -e "\n=== All editorPath usages in CodeEditor ==="
grep -n "editorPath" frontend/app/view/codeeditor/codeeditor.tsx
# Check if fileName appears in dependency arrays
echo -e "\n=== useEffect/useCallback dependency arrays with fileName or editorPath ==="
grep -n -B2 -A2 "fileName\|editorPath" frontend/app/view/codeeditor/codeeditor.tsx | grep -A2 -B2 "\[.*\]"
# View the preview-edit.tsx file around line 69 to see how fileName is passed
echo -e "\n=== preview-edit.tsx context (lines 60-80) ==="
sed -n '60,80p' frontend/app/view/preview/preview-edit.tsxLength of output: 2286 I found a critical issue. Let me verify how 🏁 Script executed: #!/bin/bash
# Check if fileName changes dynamically in preview-edit.tsx
echo "=== Full preview-edit.tsx to understand fileName lifecycle ==="
cat frontend/app/view/preview/preview-edit.tsx | grep -n "fileName" -B2 -A2
echo -e "\n=== Check for fileName state updates ==="
grep -n "setFileName\|fileName.*=" frontend/app/view/preview/preview-edit.tsxLength of output: 667 I've identified a potential bug. Let me check if 🏁 Script executed: #!/bin/bash
# Search for updates to model.statFile atom to determine if fileInfo can change
echo "=== Check atom updates and fileInfo reactivity ==="
rg -n "statFile" frontend/app/view/preview/preview-edit.tsx
echo -e "\n=== Search broader codebase for statFile mutations ==="
rg -n "statFile.*=" --type ts --type tsx -C2 | head -40
echo -e "\n=== Verify if editorPath should be reactive ==="
# Check if Monaco editor's path prop expects to update dynamically
grep -n "path=" frontend/app/view/codeeditor/codeeditor.tsx -B3 -A3Length of output: 522 Fix editorPath reactivity: editorPath should update when fileName changes. The current implementation freezes Issue location: The fix should ensure const editorPath = useRef(fileName ?? crypto.randomUUID()).current;With a pattern that maintains the UUID fallback while allowing updates: const editorPathRef = useRef(fileName ?? crypto.randomUUID());
const editorPath = editorPathRef.current;Or if the path should update with fileName changes: const editorPath = fileName ?? useRef(crypto.randomUUID()).current;🤖 Prompt for AI Agents |
||
| readonly={fileInfo.readonly} | ||
| onChange={(text) => setNewFileContent(text)} | ||
| onMount={onMount} | ||
|
|
||
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.
Fix:
editorPathdoesn't update whenfileNameprop changes.The current implementation uses
useRefwhich only evaluates its initial value on the first render. If thefileNameprop changes on subsequent renders,editorPathwill retain its original value, causing Monaco Editor to use the wrong model identity.Scenario demonstrating the bug:
fileName="file-a.txt"→editorPath="file-a.txt"fileName="file-b.txt"→editorPathstill"file-a.txt"❌This results in Monaco using the model for file A when editing file B.
Apply this diff to make
editorPathreactive tofileNamechanges while maintaining a stable UUID fallback:This ensures:
fileNameis provided,editorPathupdates immediatelyfileNameisundefined, a stable random UUID is used across renders📝 Committable suggestion
🤖 Prompt for AI Agents