Skip to content

Replace compact mode with F11 detach mode (Log Only View) - #749

Open
mfkeeq199458 wants to merge 4 commits into
LogExperts:Developmentfrom
mfkeeq199458:feature/f11-compact-mode
Open

mfkeeq199458 wants to merge 4 commits into
LogExperts:Developmentfrom
mfkeeq199458:feature/f11-compact-mode

Conversation

@mfkeeq199458

Copy link
Copy Markdown
Contributor

F11 now detaches the active log window into its own top-level window and hides the main window; F11 or ESC returns to the normal mode. The float window gets min/max buttons, a resizable border, a taskbar button, its own stable icon and a maximizable double-click-title behaviour; dark title bars are re-applied after the style-driven handle recreation.

TabController gains GetPlacedWindows/GetNextWindow/GetPreviousWindow and a guarded CloseAllExcept; the View menu offers the toggle as "Log Only View" (en/de/zh-CN) with F11 as a display-only shortcut hint. DetachMode service, message filter and a NativeWindow caption hook live in DetachModeService; 17 controller tests plus 6 filter tests cover it.

F11 now detaches the active log window into its own top-level window and
hides the main window; F11 or ESC returns to the normal mode. The float
window gets min/max buttons, a resizable border, a taskbar button, its
own stable icon and a maximizable double-click-title behaviour; dark
title bars are re-applied after the style-driven handle recreation.

TabController gains GetPlacedWindows/GetNextWindow/GetPreviousWindow and
a guarded CloseAllExcept; the View menu offers the toggle as "Log Only
View" (en/de/zh-CN) with F11 as a display-only shortcut hint. DetachMode
service, message filter and a NativeWindow caption hook live in
DetachModeService; 17 controller tests plus 6 filter tests cover it.

@Hirogen Hirogen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @mfkeeq199458 — a focus mode for a single log is a nice idea, and it's good that F11 doesn't clash with anything and that closing the app while detached leaves the saved main-window layout intact. Before this can go in, there are a few behavioural issues, plus some housekeeping.

ESC handling (blocking)
The filter catches ESC for the whole app, and the text-input guard doesn't work as intended:

  • Form.ActiveForm?.ActiveControl is TextBoxBase (DetachMessageFilter.cs:31) stops at the nearest nested container, so it sees the LogWindow, not the filter/search box or the in-grid edit control. ESC in those inputs therefore leaves detach mode instead of doing its normal job. A check like GetFocus() → Control.FromHandle(...) is TextBoxBase (or walking the ContainerControl chain) would find the real focused control.
  • ESC on the grid normally cancels a search and clears highlighting (LogWindow.cs:6989). The filter's own comment says that should keep working, but while detached it exits the mode instead.
  • If a modal dialog is open (e.g. from the float window), ESC is swallowed: the dialog stays open and the main window reappears behind it. Please only react when the active form is the detached float window.

The ESC tests stub _isTextInputFocused, so they can't catch this. It needs a manual check, or a test that exercises the real focus lookup.

Restoring state on exit

  • Exit docks the window again with Show(_dockPanel, DockState.Document) (DetachModeController.cs:107), so the original tab position and any split pane are lost. Please restore the original pane and index.
  • If the window was already floating before F11, Exit leaves the patched chrome on it (no owner, taskbar button, sizable border). ReleaseFloatWindow only removes the hook.
  • _detachModeController is never disposed in LogTabWindow.Dispose, and the message filter is only removed when Exit() runs. Please make the controller IDisposable and dispose it next to _tabController.

Scope

  • "Close other tabs" now goes through CloseAllExcept and asks for confirmation, where before it closed directly. That's a user-visible change detach mode doesn't need. Please split it into its own PR (or drop it).
  • Ctrl+Tab cycling, "opening a file replaces the detached window" and "X on the float detaches the next hidden window" are reasonable, but they aren't in the description. Please document them. I'd also argue the X button should simply return to the main window; that's what most users will expect.

Housekeeping

  • The PR adds 10 new analyzer warnings (CA1060, CA5392, CA1051, CA1303, CA1001, CA1031). Please get the build back to the base warning count.
  • LogExpert.UI already uses Vanara: please use Vanara.PInvoke.User32 for GetWindowLongPtr / CallWindowProc, and put DwmSetWindowAttribute in NativeMethods (or use Vanara.DwmApi) instead of new DllImports.
  • WM_KEYDOWN and the autorepeat bit are defined in both the filter and LogTabWindow. The restore-dock-state block is repeated three times in the controller. Please extract both.
  • ToggleDetachMode() only calls Enter(). Please rename it, or make it actually toggle.
  • Comments: we keep them minimal in this repo. DetachModeController is about 20% comments, many of them multi-paragraph. Please trim them to the non-obvious "why" lines.
  • Naming: the code says "detach mode", the UI says "Log Only View". Please pick one concept name and use it throughout.
  • Test seams: prefer constructor injection over mutable internal fields.
  • The new blocks in LogTabWindow.designer.cs look hand-edited (// without the trailing space). Please let the designer generate them.

Description

  • The title says "Replace compact mode", but there's no compact mode on Development. Please retitle to something like "Add F11 Log Only View".
  • The test count is off: the code has 9 controller + 8 filter + 6 TabController tests.

Thanks — the core idea is solid. ESC handling and restoring the original state on exit are the two I need fixed; the rest is cleanup.

mfkeeq199458 and others added 2 commits October 24, 2026 09:55
Adds F11 detach mode: F11 hides the main window and keeps the active log
window floating as a stand-alone viewer. F11 brings the main window back and
restores the window to its original pane and tab index.

Behaviour:
- F11 enters and leaves the mode. ESC is not part of detach mode and keeps its
  normal behaviour (cancelling a search on the grid, editing in text boxes,
  dismissing dialogs).
- Ctrl+Tab / Ctrl+Shift+Tab cycle through log windows while detached.
- Opening a file while detached replaces the detached window.
- Closing the detached float (X) ends the mode and returns to the main window.
- A window that was already floating keeps its original chrome on exit; a
  docked window is restored to its original pane and tab position.
- The keyboard filter only reacts while the detached float is the active form,
  so modal dialogs keep F11 and Ctrl+Tab for themselves.

Review follow-up:
- Removed the ESC exit path and the old text-input guard; the mode is left
  with F11 only.
- Restore the original dock pane and content index instead of docking to
  DockState.Document.
- Restore the patched chrome for windows that were already floating on entry.
- Make DetachModeController IDisposable and dispose it next to TabController;
  the message filter is removed in Dispose as well.
- Revert the "Close other tabs" change: it was not part of this feature and is
  now identical to Development.
- Clear the new analyzer warnings: remove the unused GetFocus/SetFocus
  P/Invokes, add DefaultDllImportSearchPaths for the DWM call, and suppress
  CA1303, CA1031 and CA1001 with justifications.
- Share the WM_KEYDOWN and autorepeat constants through NativeMethods and keep
  a single restore-dock-state block.
- Rename ToggleDetachMode to EnterDetachMode, trim comments to the non-obvious
  "why", and use the concept name "Detach Mode" in code, designer text and all
  three resource files.
- Use constructor injection for the keyboard filter test seams.

Tests: 9 controller, 8 filter and 3 TabController tests. Full
LogExpert.UI.Tests suite: 391 passed, 0 failed.

Note: the previous description said "Replace compact mode", but Development has
no compact mode; this change adds F11 Detach Mode. The earlier test count and
the Ctrl+Tab, file-replacement and X-button behaviour were missing from the
description and are documented above.

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com>
@mfkeeq199458
mfkeeq199458 requested a review from Hirogen October 24, 2026 06:23
Two detach mode regressions:

- Closing the detached float through its X left an empty, unclosable tab in the main
  window. OnWindowDisposed fired while LogWindow.IsDisposed was still false, so Exit()
  re-showed the closing window into its original pane. The close path no longer calls
  Exit(): it releases the hook without touching the float chrome, clears the captured
  placement and shows the main window on the message loop after the suite finished
  closing, which keeps the document panel empty.
- In dark mode a detached float kept a light title bar until it was moved or resized.
  DWM only repaints the caption on a real move/resize, so the immersive dark flag is
  applied after the float is shown and a one pixel height nudge forces the repaint. A
  maximized float only gets the flag because the nudge would overwrite its restore
  bounds.

ApplyDarkTitleBar replaces SetImmersiveDarkTitleBar, Exit keeps restoring chrome for the
F11 path, and ClearOriginalPlacement is shared by both exit paths.

Tests: 18 DetachModeController tests pass, including a regression test that closing the
float leaves no document in the panel; LogExpert.UI and LogExpert build without errors.
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.

2 participants