Unverified 提交 0e2f0025 authored 作者: wwwillchen-bot's avatar wwwillchen-bot 提交者: GitHub

fix: provide stable Monaco model path in file editor (#2781)

## Summary - Compute a stable Monaco `path` value from `appId` and `filePath` in `FileEditor` - Pass that `path` into the editor so file models are keyed consistently across renders/apps ## Test plan - npm run fmt - npm run lint:fix - npm run ts - npm test 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/dyad-sh/dyad/pull/2781" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end --> --------- Co-authored-by: 's avatarWill Chen <willchen90@gmail.com>
上级 26c65ed3
...@@ -6,6 +6,16 @@ When pushing changes and creating PRs: ...@@ -6,6 +6,16 @@ When pushing changes and creating PRs:
2. If the branch hasn't been pushed before, default to pushing to `origin` (the fork `wwwillchen/dyad`), then create a PR from the fork to the upstream repo (`dyad-sh/dyad`). 2. If the branch hasn't been pushed before, default to pushing to `origin` (the fork `wwwillchen/dyad`), then create a PR from the fork to the upstream repo (`dyad-sh/dyad`).
3. If you cannot push to the fork due to permissions, push directly to `upstream` (`dyad-sh/dyad`) as a last resort. 3. If you cannot push to the fork due to permissions, push directly to `upstream` (`dyad-sh/dyad`) as a last resort.
## `gh pr create` branch detection
If `gh pr create` says `you must first push the current branch to a remote` even though `git push -u` succeeded, create the PR with an explicit head ref:
```bash
gh pr create --head <owner>:<branch> ...
```
This can happen when remotes are configured in a non-fork layout and `gh` fails to infer the branch mapping.
## Skipping automated review ## Skipping automated review
Add `#skip-bugbot` to the PR description for trivial PRs that won't affect end-users, such as: Add `#skip-bugbot` to the PR description for trivial PRs that won't affect end-users, such as:
......
...@@ -139,6 +139,10 @@ export const FileEditor = ({ ...@@ -139,6 +139,10 @@ export const FileEditor = ({
(theme === "system" && (theme === "system" &&
window.matchMedia("(prefers-color-scheme: dark)").matches); window.matchMedia("(prefers-color-scheme: dark)").matches);
const editorTheme = isDarkMode ? "dyad-dark" : "dyad-light"; const editorTheme = isDarkMode ? "dyad-dark" : "dyad-light";
const modelPath = React.useMemo(() => {
const normalizedPath = filePath.replace(/^\/+/, "");
return `file:///app-${appId ?? "unknown"}/${encodeURI(normalizedPath)}`;
}, [appId, filePath]);
// Navigate to a specific line in the editor // Navigate to a specific line in the editor
const navigateToLine = React.useCallback((line: number | null) => { const navigateToLine = React.useCallback((line: number | null) => {
...@@ -260,6 +264,7 @@ export const FileEditor = ({ ...@@ -260,6 +264,7 @@ export const FileEditor = ({
<div className="flex-1 overflow-hidden"> <div className="flex-1 overflow-hidden">
<Editor <Editor
height="100%" height="100%"
path={modelPath}
defaultLanguage={getLanguage(filePath)} defaultLanguage={getLanguage(filePath)}
value={value} value={value}
theme={editorTheme} theme={editorTheme}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论