Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,7 @@ fn initialize_app(
} else {
log::info!("Home directory not found; skipping HomeDirectoryWatcher registration");
}
ctx.add_singleton_model(crate::terminal::shell_history_watcher::ShellHistoryWatcher::new);
}

#[cfg(feature = "local_fs")]
Expand Down Expand Up @@ -1494,6 +1495,15 @@ fn initialize_app(

ctx.add_singleton_model(move |_| History::new(command_history));

// GH-3422: subscribe History to ShellHistoryWatcher so live updates from
// other terminals (when the user has opted in via
// `terminal.live_sync_os_shell_history`) flow into Warp's autocomplete.
// Idempotent — safe to call once at app startup.
#[cfg(not(target_family = "wasm"))]
crate::terminal::history::History::handle(ctx).update(ctx, |history, ctx| {
history.set_up_external_history_sync(ctx);
});

ctx.add_singleton_model(CustomSecretRegexUpdater::new);

// Register the `TelemetryCollection` singleton model.
Expand Down
6 changes: 6 additions & 0 deletions app/src/search/command_search/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,12 @@ impl CommandSearchView {
ctx.notify();
}
}
HistoryEvent::ExternalHistoryUpdated { .. } => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ [IMPORTANT] The history data source is a snapshot created when the mixer is reset; this callback is only installed in the !is_queryable branch and ctx.notify() does not rebuild the source or rerun the current query, so command search stays stale for already-queryable sessions after live history updates.

// Live OS-shell-history sync (GH-3422). The mixer's
// history source re-queries on its own debounce, so
// we just trigger a notify to refresh visible state.
ctx.notify();
}
}
});
}
Expand Down
5 changes: 3 additions & 2 deletions app/src/settings/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ use super::{
AliasExpansionSettings, AppEditorSettings, BlockVisibilitySettings, ChangelogSettings,
CodeSettings, DebugSettings, EmacsBindingsSettings, FontSettings, FontSettingsChangedEvent,
GPUSettings, InputBoxType, InputModeSettings, InputSettings, PaneSettings,
SameLinePromptBlockSettings, ScrollSettings, SelectionSettings, SshSettings, ThemeSettings,
VimBannerSettings, WarpDrivePrivacySettings,
SameLinePromptBlockSettings, ScrollSettings, SelectionSettings, ShellHistorySyncSettings,
SshSettings, ThemeSettings, VimBannerSettings, WarpDrivePrivacySettings,
};

pub struct UserDefaultsOnStartup {
Expand Down Expand Up @@ -91,6 +91,7 @@ pub fn register_all_settings(ctx: &mut AppContext) {
AltScreenReporting::register(ctx);
UndoCloseSettings::register(ctx);
SshSettings::register(ctx);
ShellHistorySyncSettings::register(ctx);
VimBannerSettings::register(ctx);
SharedSessionSettings::register(ctx);
WarpDriveSettings::register(ctx);
Expand Down
2 changes: 2 additions & 0 deletions app/src/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ mod privacy;
mod same_line_prompt_block;
mod scroll;
mod select;
mod shell_history_sync;
mod ssh;
mod theme;
mod vim_banner;
Expand Down Expand Up @@ -61,6 +62,7 @@ pub use privacy::*;
pub use same_line_prompt_block::*;
pub use scroll::*;
pub use select::*;
pub use shell_history_sync::*;
pub use ssh::*;
pub use theme::*;
pub use vim_banner::*;
Expand Down
18 changes: 18 additions & 0 deletions app/src/settings/shell_history_sync.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use settings::{
macros::define_settings_group, RespectUserSyncSetting, SupportedPlatforms, SyncToCloud,
};

define_settings_group!(ShellHistorySyncSettings, settings: [
live_sync_os_shell_history: LiveSyncOsShellHistoryEnabled {
type: bool,
default: false,
supported_platforms: SupportedPlatforms::ALL,
sync_to_cloud: SyncToCloud::Globally(RespectUserSyncSetting::Yes),
private: false,
toml_path: "terminal.live_sync_os_shell_history",
description: "When enabled, Warp watches the active shell's history file (~/.zsh_history, \
~/.bash_history, fish, PSReadLine) for changes made by other terminals and \
merges new commands into Warp's autocomplete in real time. Off by default. \
Tracks GH-3422.",
},
]);
Loading