Skip to content

Add in-app log console; stop launching a separate terminal window#4

Merged
stytim merged 2 commits into
mainfrom
feature/in-app-log-console
Jun 13, 2026
Merged

Add in-app log console; stop launching a separate terminal window#4
stytim merged 2 commits into
mainfrom
feature/in-app-log-console

Conversation

@stytim

@stytim stytim commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Launching the app from a GUI no longer opens a separate console window (CMD on Windows, Terminal on macOS). All logging now appears in a docked "Log" console along the bottom of the app window, and still prints to the terminal when the app is launched from one.

Logging

  • New LogConsole (include/Log.h, src/Log.cpp): tees std::cout/std::cerr so every line goes to both the original stream (terminal) and a bounded, thread-safe ring buffer rendered as the bottom panel. No changes needed at the ~54 existing log call sites. The render path snapshots under the lock and draws unlocked, so a worker thread logging never blocks the GUI and there is no re-entrancy path back into the lock.

No separate console on launch

  • Windows: built as a GUI-subsystem executable (WIN32_EXECUTABLE + /ENTRY:mainCRTStartup to keep int main). AttachConsole(ATTACH_PARENT_PROCESS) reattaches stdio when started from a terminal so logs still print there.
  • macOS: CMake now builds an ir-tracking-app.app bundle (Info.plist.in + icon), so double-clicking in Finder does not spawn Terminal. release.yml's macOS packaging consumes the CMake bundle (dylibbundler + PlistBuddy version stamp) instead of hand-assembling it.

macOS data directory

  • A Finder-launched .app has working directory "/", which broke the relative "Tools" folder and CSV paths. On macOS these now live under ~/Library/Application Support/IR Tracking App/ regardless of launch method; Windows and Linux keep their current working-directory behavior. The data directory is logged at startup.

Layout

  • Default window grown to 1060x900; IR/Depth monitors lifted above the log console and clamped so they never render off the top on a short window.

Tracker fixes (from code review)

  • UdpThreadFunction: GetToolTransform() returns 8 floats, so copying begin()+3..end() wrote 5 floats into data.quaternion[4] (out-of-bounds). Copy exactly the 4 quaternion components.
  • MIN_SPHERES 4 -> 3 to match the tracker, which supports 3-sphere tools in both AddTool and CalibrateTool. The old value rejected valid 3-sphere manual/ROM definitions and 3-sphere calibration results.

Launching the app from a GUI no longer opens a separate console window
(CMD on Windows, Terminal on macOS). All logging now appears in a docked
"Log" console along the bottom of the app window, and still prints to the
terminal when the app is launched from one.

Logging
- New LogConsole (include/Log.h, src/Log.cpp): tees std::cout/std::cerr so
  every line goes to both the original stream (terminal) and a bounded,
  thread-safe ring buffer rendered as the bottom panel. No changes needed
  at the ~54 existing log call sites. The render path snapshots under the
  lock and draws unlocked, so a worker thread logging never blocks the GUI
  and there is no re-entrancy path back into the lock.

No separate console on launch
- Windows: built as a GUI-subsystem executable (WIN32_EXECUTABLE +
  /ENTRY:mainCRTStartup to keep int main). AttachConsole(ATTACH_PARENT_PROCESS)
  reattaches stdio when started from a terminal so logs still print there.
- macOS: CMake now builds an ir-tracking-app.app bundle (Info.plist.in +
  icon), so double-clicking in Finder does not spawn Terminal. release.yml's
  macOS packaging consumes the CMake bundle (dylibbundler + PlistBuddy
  version stamp) instead of hand-assembling it.

macOS data directory
- A Finder-launched .app has working directory "/", which broke the relative
  "Tools" folder and CSV paths. On macOS these now live under
  ~/Library/Application Support/IR Tracking App/ regardless of launch method;
  Windows and Linux keep their current working-directory behavior. The data
  directory is logged at startup.

Layout
- Default window grown to 1060x900; IR/Depth monitors lifted above the log
  console and clamped so they never render off the top on a short window.

Tracker fixes (from code review)
- UdpThreadFunction: GetToolTransform() returns 8 floats, so copying
  begin()+3..end() wrote 5 floats into data.quaternion[4] (out-of-bounds).
  Copy exactly the 4 quaternion components.
- MIN_SPHERES 4 -> 3 to match the tracker, which supports 3-sphere tools in
  both AddTool and CalibrateTool. The old value rejected valid 3-sphere
  manual/ROM definitions and 3-sphere calibration results.

Copilot AI 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.

Pull request overview

This PR changes the application’s launch/logging behavior so GUI launches no longer spawn an external terminal window, while still preserving terminal logging when launched from a shell. It also adds an in-app, docked ImGui log console and adjusts macOS path handling so tool/CSV data is stored in a stable per-user location when running as a .app bundle.

Changes:

  • Add LogConsole to tee std::cout/std::cerr into a bounded in-app log view while still forwarding output to the original streams.
  • Update Windows/macOS packaging to avoid spawning a separate console (Windows GUI-subsystem executable; macOS builds a .app bundle + workflow packaging updates).
  • Fix tracker data handling (quaternion copy bounds) and adjust UI layout (larger default window, monitors lifted above log panel), plus macOS data directory routing.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/ViewerWindow.cpp Adds macOS data directory resolution, fixes quaternion copy bounds, adjusts default window/layout, and renders the docked Log console.
src/viewer_main.cpp Attaches to parent console on Windows when available and installs/restores the log tee early in main().
src/Log.cpp Implements the in-app log console (tee streambuf + ring buffer + ImGui rendering).
include/Log.h Declares LogConsole public API used by the app.
include/ViewerWindow.h Lowers MIN_SPHERES to 3 to match tracker support.
resources/Info.plist.in Adds CMake-templated Info.plist for the macOS .app bundle.
CMakeLists.txt Builds Windows as GUI-subsystem and macOS as a bundle; wires icon/plist and adds new Log sources.
.github/workflows/release.yml Updates macOS DMG packaging to consume the CMake-generated .app and version-stamp Info.plist.
README.md Documents the new in-app Log console, Windows GUI launch behavior, and macOS .app usage/data directory.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ViewerWindow.cpp
Comment on lines +51 to +58
fs::path dir = fs::path(home) / "Library" / "Application Support" / "IR Tracking App";
std::error_code ec;
fs::create_directories(dir, ec);
if (!ec)
{
return dir;
}
}
Comment thread src/ViewerWindow.cpp Outdated
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize |
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings |
ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoFocusOnAppearing;
ImGui::SetNextWindowPos(ImVec2(0.0f, logWinHeight - kLogConsoleHeight));
@stytim stytim merged commit be55964 into main Jun 13, 2026
3 checks passed
@stytim stytim deleted the feature/in-app-log-console branch June 13, 2026 20:56
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