Skip to content

[codex] Keep followed files current while inactive - #112

Merged
hybridmachine merged 2 commits into
macos-portfrom
codex/keep-follow-file-active
May 24, 2026
Merged

[codex] Keep followed files current while inactive#112
hybridmachine merged 2 commits into
macos-portfrom
codex/keep-follow-file-active

Conversation

@hybridmachine

Copy link
Copy Markdown
Owner

Summary

  • Add macOS follow-file mode plumbing, including the age bar view, tab/menu integration, settings, and per-file FSEvents watches.
  • Make followed documents update their DocumentData content, file size, and line age state even while their tab is inactive.
  • Mirror follow append/reload operations into Scintilla only for the currently visible followed tab, with follow-age tracking suppressed during programmatic mirrors.

Root Cause

Follow-mode file monitor callbacks previously treated Scintilla as the canonical buffer. When the followed tab was inactive, callbacks skipped the update path, so the stored DocumentData stayed stale until a later catch-up path ran.

Impact

A followed file now keeps advancing in the background without stealing focus or mutating an inactive Scintilla view. Switching back to the tab restores already-current content and reattaches the editor to the bottom.

Validation

  • cmake --build macos/build --target PaperWasp

Copilot AI review requested due to automatic review settings May 24, 2026 04:25

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

Adds a new “Follow Mode” for the macOS port so external file changes continue to update the underlying document state while the tab is inactive, and introduces an “age heatmap” UI strip plus menu/tab integrations to control and visualize follow state.

Changes:

  • Add follow-mode core logic (per-file FSEvents watches, background DocumentData updates, and controlled mirroring into the visible Scintilla view).
  • Add UI plumbing: View-menu and tab context menu actions, a tab “eye” indicator, and a right-edge age bar with configurable colors/thresholds.
  • Persist follow-mode settings in app settings/preferences and wire them into app startup.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
macos/platform/wndproc.mm Adds View-menu command handler for toggling follow mode.
macos/platform/tab_context_menu.mm Adds tab context-menu item to toggle follow mode per tab.
macos/platform/tab_bar_view.mm Renders a “followed” indicator (eye icon) in tabs.
macos/platform/tab_bar_view.h Exposes followed-state setters/getters for tab items.
macos/platform/split_view.mm Uses editor container that can host the age bar; hooks scrolling/modified notifications for follow/age-bar refresh.
macos/platform/settings_manager.mm Loads/saves follow-mode colors and age thresholds to JSON.
macos/platform/settings_manager.h Adds follow-mode settings fields and defaults.
macos/platform/preferences_dialog.mm Adds preferences UI for follow-mode colors/thresholds and triggers age-bar refresh on apply.
macos/platform/npp_constants.h Defines new command IDs for follow mode and tab context follow action.
macos/platform/menu_builder.mm Adds View-menu item and shortcut for follow mode.
macos/platform/follow_mode.mm Implements follow-mode behavior (watching, background updates, Scintilla mirroring, line-age tracking).
macos/platform/follow_mode.h Declares follow-mode toggle/update hooks for UI/Scintilla notifications.
macos/platform/file_monitor_mac.mm Extends file monitor with per-file FSEvents streams and callbacks.
macos/platform/file_monitor_mac.h Declares per-file watch APIs.
macos/platform/document_manager.mm Integrates follow-mode UI refresh on tab activation and stops follow plumbing on close.
macos/platform/document_data.h Adds follow-mode state to per-document data (flags, birth times, file size).
macos/platform/app_state.h Adds global follow-mode settings and suppression flag for programmatic Scintilla restores.
macos/platform/app_delegate.mm Installs editor container capable of hosting the age bar and wires follow/age-bar invalidation into notifications.
macos/platform/age_bar_view.mm Implements the age heatmap view and editor container layout logic.
macos/platform/age_bar_view.h Declares the age bar view, editor container, and invalidation helpers.
macos/CMakeLists.txt Adds new follow-mode/age-bar sources to the macOS build.

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

Comment thread macos/platform/wndproc.mm
Comment on lines +677 to +689
case IDM_VIEW_FOLLOW:
{
toggleFollowModeForActiveTab(ctx().activeView);
HMENU hMenu = GetMenu(hWnd);
if (hMenu)
{
int tab = (ctx().activeView == 0) ? ctx().activeTab : ctx().activeTab2;
auto& docs = (ctx().activeView == 0) ? ctx().documents : ctx().documents2;
bool on = (tab >= 0 && tab < (int)docs.size() && docs[tab].followMode);
CheckMenuItem(hMenu, IDM_VIEW_FOLLOW,
MF_BYCOMMAND | (on ? MF_CHECKED : MF_UNCHECKED));
}
return 0;
Comment thread macos/platform/age_bar_view.mm Outdated
Comment on lines +28 to +35
static NSMutableArray<NppAgeBarView*>* sLiveBars = nil;
static NSTimer* sTickTimer = nil;

static void ensureBarRegistry()
{
if (!sLiveBars)
sLiveBars = [NSMutableArray array];
}
Comment thread macos/platform/file_monitor_mac.mm Outdated
std::wstring widePath = UTF8ToWide([nsPath UTF8String]);

if (fwc && fwc->callback)
fwc->callback(action, widePath);
Comment on lines +215 to +223
// If already watching, replace the callback in-place.
for (size_t i = 0; i < m_impl->watchedFiles.size(); ++i)
{
if (m_impl->watchedFiles[i] == path)
{
m_impl->fileCallbacks[i] = std::move(callback);
return true;
}
}
@hybridmachine
hybridmachine merged commit 4ca46e2 into macos-port May 24, 2026
15 of 30 checks passed
@hybridmachine
hybridmachine deleted the codex/keep-follow-file-active branch May 24, 2026 04:59
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