Skip to content

fix(app): open the file editor as an ordinary window - #273

Merged
TooonyChen merged 5 commits into
mainfrom
bugfix/file-editor-ordinary-window
Nov 29, 2026
Merged

TooonyChen merged 5 commits into
mainfrom
bugfix/file-editor-ordinary-window

Conversation

@TooonyChen

Copy link
Copy Markdown
Owner

Summary

The file editor window was owned by the main window and could not be minimized, only because it opened through the same code as the dialogs. On Windows that kept it above the terminal whichever window had the focus. It is now an ordinary window beside the main one: no owner, not modal, minimize enabled, and whichever window is clicked comes to the front. There is no setting for it.

This continues #256 by @loooinfo, whose commits are kept, reworked as decided in the review there:

  • No setting. The "Keep the file editor in front of the main window" checkbox, the independentFileEditor key (and its place in localSettings and the sync tests), its strings in both locales and its docs are removed. Options › General is unchanged from main, so the scrolling feat(app): make file editor window placement optional #256 added to agent_test.go is gone too.
  • One mechanism. main got WindowSpec.TopLevel with feat(app): maximize the bottom panel in place and open it in a window #266 (the panels' windows) while feat(app): make file editor window placement optional #256 added Independent for the same thing. Independent is removed and the editor sets TopLevel. feat(app): make file editor window placement optional #256's secondaryWindowOptions helper stays, as it makes the options testable: a top-level window gets no Parent, no Modal and no DisableMinimize; every other secondary window is as before. The panels' windows are top-level as they are on main.
  • Kept from feat(app): make file editor window placement optional #256: FocusWindow restores a minimized window before focusing it (now a small bringToFront with a test), and the comment that CloseAll is what closes windows the main window does not own.
  • The editor's own dialogs (unsaved changes for a tab or the window, the conflict on save) are ui.AlertDialogs drawn in the editor's own view, and save errors show in its status bar, so nothing of the editor's can open behind it. The editor opens no native file chooser and never calls Confirm. No change was needed there.
  • Docs: features.md (the editor's Window section) and development.md (Child windows) in both languages.

Closes #255

Testing

  • go build ./..., go vet ./..., GOOS=windows go vet ., GOOS=darwin go vet ., go tool mygo vet, go tool mygo generate (catalog equal to main's).
  • GOOS=windows GOARCH=amd64 go build . and GOOS=darwin GOARCH=arm64 go build . both build.
  • go test -race -count=1 -timeout 30m ./...: every package ok.
  • Tests:
    • TestFileEditorOrdinaryWindow (internal/app, replaces feat(app): make file editor window placement optional #256's TestFileEditorWindowPlacement): the editor's spec is top-level and not modal while Options is owned; opening the file again keeps the window and tab and calls FocusWindow for the editor; the close button asks, with the question in the editor's view and not the main window's, and Cancel keeps the changes; hiding to the tray closes Options, keeps an editor with changes and closes one without; CloseAll closes it without asking. It fails without TopLevel on the editor's spec.
    • TestSecondaryWindowOptions (root package, from feat(app): make file editor window placement optional #256, now on TopLevel): owned, top-level and modal options, same position.
    • TestBringToFront (root package): a minimized window is restored, then focused.
  • Options › General rendered in English and Simplified Chinese on main and on this branch: the images are identical byte for byte.

Not tested: anything on a real desktop. The z-order, minimizing, and the taskbar and Dock behavior cannot be rendered headless, and nothing here ran on Windows or macOS. What is expected comes from reading MyGo v0.10.0's backends: on Windows a window without Parent has no owner (so it is not kept above the main window, has its own taskbar button, and does not minimize with it); on macOS it is an NSWindow that MyGo neither orders above the main window nor hides with it; Focus restores a minimized window on Windows, and Restore is called first on every platform.

Please click through this on Windows and on macOS before merging:

  1. Open a file from the file panel. The editor opens over the main window. Click the main window: it comes in front of the editor. Click the editor (or its taskbar button, or the Window menu on macOS): it comes back in front.
  2. The editor's title bar has a working minimize button. Minimize it: on Windows it has its own taskbar button, on macOS it goes into the Dock. Restore it from there.
  3. With the editor minimized, and again with it behind the main window, double-click a file in the file panel (the same one and another one): the editor is restored and comes to the front with that file's tab.
  4. Minimize the main window: the editor stays where it is. Restore the main window.
  5. Edit a file without saving and click the editor's close button: the question appears inside the editor window. Cancel keeps it open; "Don't save" closes it.
  6. Edit a file without saving and close the main window (tray option off), then again with Cmd+Q on macOS: the app asks about the unsaved file; check that the question is visible and not behind the editor. Answering yes quits and leaves no editor window; Cancel leaves both windows.
  7. With no unsaved changes and the editor open, close the main window: the app quits and the editor window goes with it.
  8. Turn on "Minimize to tray when closed". With a saved file open, close the main window: the editor closes too. With unsaved changes: the editor stays open while the main window is in the tray. Close it by hand, then bring the main window back from the tray (and on macOS from the Dock icon while the editor is still open).
  9. Options, the connection manager and the connection editor still stay above the main window and have no minimize button. A panel's window (feat(app): maximize the bottom panel in place and open it in a window #266) behaves as before.
  10. macOS: full screen the main window, then open a file; and Cmd+W in the editor closes a tab, not the window.

Generated by Claude Code

loooinfo and others added 4 commits November 26, 2026 15:35
…dinary-window

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015nMqJEvqPnRmPgi6dnraZM
The editor was owned by the main window and could not be minimized only
because it opened through the same code as the dialogs. Drop the setting
that made this optional: the editor is always a top-level window, using
the TopLevel window kind the panel windows already have. Dialogs and
Options stay owned.

Remove the checkbox, the independentFileEditor key, its strings and its
docs, and restore the agent test that had to scroll the longer page.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015nMqJEvqPnRmPgi6dnraZM
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-29T08:23:35.582368Z 91ab6ab PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 91ab6ab3a0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Kind: WindowFileEditor, Title: a.fileEditorTitle,
Width: 1000, Height: 700, MinWidth: 560, MinHeight: 360,
OwnKeys: true, CloseRequested: a.closeFileEditorRequested, Closed: a.fileEditorClosed,
OwnKeys: true, TopLevel: true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore the tray-hidden main window when the editor is visible

On macOS, hiding the main window to the tray while the editor has unsaved changes now leaves a visible top-level editor window. The Dock activation handler in main.go only calls plat.showMain() when hasVisibleWindows is false, so clicking the Dock icon in this state no longer brings back the terminal window. Update that handler to also restore the main window when it is hidden in the tray, regardless of whether the editor is visible.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed and fixed in 2aceca5: OnActivate now calls plat.showMain() whatever windows are visible. showMain returns at once when the main window is not in the tray, so nothing changes outside that case. Not tried on a real Mac; it is step 8 of the click-through in the description.


Generated by Claude Code

With the main window hidden in the tray, an editor with unsaved changes
stays open, and as an ordinary window it is no longer hidden along. The
Dock icon then found a visible window and did not bring the main window
back. It now shows the main window whenever it is in the tray.

Refs #255

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015nMqJEvqPnRmPgi6dnraZM

Copy link
Copy Markdown
Owner Author

CI on 2aceca5 failed in TestSSHRestoreHistory ("transport did not resize: [0 0]"). That is not from this PR: the test reads a size the terminal sends from a goroutine, and fails the same way on unmodified main (#274, fixed in #275). The job is re-running once.


Generated by Claude Code

@TooonyChen
TooonyChen merged commit 2ee02c5 into main Nov 29, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(app): make file editor window placement optional

3 participants