mirror of
https://github.com/l0ng-ai/tty7.git
synced 2026-09-22 00:02:23 +00:00
refactor(client): drop the file-wide dead_code allow and the nine it hid
src/terminal/remote.rs opened with a blanket `#![allow(dead_code)]` — every other suppression in the tree is per-item or cfg_attr'd. It was hiding nine unused associated functions, and four of them are the sort worth catching: `spawn`, `attach`, `list_panes` and `kill_pane`, the local-only wrappers left behind when panes became route-addressed. Each hardcodes `PaneRoute::Local`, so reaching for one instead of its `_on` sibling silently talks to the local daemon whatever machine owns the pane — the exact mistake the route argument exists to prevent. Better they not be there to reach for. The rest: `on_workspace_forwards`, a swallowing copy of what `ForwardRoute::forwards` now returns as Option, and the four known-host and loopback-forward wrappers no UI ever called. Also restore, on the daemon side, the rationale that #268 stripped from the two loopback stubs. Without it they read as an unfinished feature — they are not, and the comment saying so is what stops the next reader (this one included) from "finishing" them. Windows CI is the check that cannot run here: the two platform-gated regions in this file are self-contained, so nothing ungated is left stranded, but only a Windows build proves no new dead_code warning.
This commit is contained in:
@@ -138,10 +138,20 @@ impl SshManager {
|
||||
))
|
||||
}
|
||||
|
||||
/// Always empty: loopback forwards are not a registry of their own. A
|
||||
/// forward `ensure_loopback` sets up is an ordinary [`ForwardEntry`] under
|
||||
/// the owning pane or workspace, so the managed list is where it shows up
|
||||
/// and where it is closed from.
|
||||
///
|
||||
/// Kept because the wire protocol still carries `ListLoopbackForwards` and
|
||||
/// `CloseLoopbackForward`; nothing in this workspace sends either.
|
||||
pub fn list_loopback_forwards(&self) -> Vec<LoopbackForwardInfo> {
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
/// Always false, for the reason on [`Self::list_loopback_forwards`]: there
|
||||
/// is no separate registry to close from. Auto forwards go away with their
|
||||
/// owner, or through the managed list.
|
||||
pub fn close_loopback_forward(&self, _id: &LoopbackForwardId) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
+1
-105
@@ -1,5 +1,3 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::io::Read as _;
|
||||
use std::path::PathBuf;
|
||||
@@ -20,8 +18,7 @@ use crate::core::cli_agent::{AgentSessionState, CLIAgent};
|
||||
use crate::core::config::CursorStyle as ConfigCursorStyle;
|
||||
use crate::core::osc::OscTokenizer;
|
||||
use crate::daemon::protocol::{
|
||||
AuthPromptKind, AuthResponse, ClientMsg, DaemonMsg, KnownHostEntry, KnownHostId,
|
||||
LoopbackForward, LoopbackForwardId, LoopbackForwardInfo, LoopbackForwardRequest,
|
||||
AuthPromptKind, AuthResponse, ClientMsg, DaemonMsg, LoopbackForward, LoopbackForwardRequest,
|
||||
ManagedForward, NativeSshSpec, PaneProcs, RemoteContext, RestoreFrom, SftpEntry,
|
||||
SftpJobProgress, SftpOp, SftpOpResult, SftpTransferSpec, ShellSpec, SshForwardRule, SshPhase,
|
||||
SshTestReport, WinSize, WorkspaceOp, WorkspaceRequest,
|
||||
@@ -233,25 +230,6 @@ fn spawn_workspace(owner: Option<&str>, route: &PaneRoute) -> Option<String> {
|
||||
}
|
||||
|
||||
impl RemoteTerminal {
|
||||
pub fn spawn(
|
||||
size: TermSize,
|
||||
cell_w: u16,
|
||||
cell_h: u16,
|
||||
cwd: Option<PathBuf>,
|
||||
shell: Option<ShellSpec>,
|
||||
) -> anyhow::Result<(Self, u64)> {
|
||||
Self::spawn_on(
|
||||
&PaneRoute::Local,
|
||||
size,
|
||||
cell_w,
|
||||
cell_h,
|
||||
cwd,
|
||||
shell,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn spawn_on(
|
||||
route: &PaneRoute,
|
||||
size: TermSize,
|
||||
@@ -389,10 +367,6 @@ impl RemoteTerminal {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn attach(size: TermSize, cell_w: u16, cell_h: u16, pane_id: u64) -> anyhow::Result<Self> {
|
||||
Self::attach_on(&PaneRoute::Local, size, cell_w, cell_h, pane_id)
|
||||
}
|
||||
|
||||
pub fn attach_on(
|
||||
route: &PaneRoute,
|
||||
size: TermSize,
|
||||
@@ -1224,10 +1198,6 @@ impl RemoteTerminal {
|
||||
self.size
|
||||
}
|
||||
|
||||
pub fn list_panes() -> Vec<crate::daemon::protocol::PaneInfo> {
|
||||
Self::list_panes_on(&PaneRoute::Local)
|
||||
}
|
||||
|
||||
pub fn list_panes_on(route: &PaneRoute) -> Vec<crate::daemon::protocol::PaneInfo> {
|
||||
Self::try_list_panes_on(route).unwrap_or_default()
|
||||
}
|
||||
@@ -1243,10 +1213,6 @@ impl RemoteTerminal {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn kill_pane(pane_id: u64) {
|
||||
Self::kill_pane_on(&PaneRoute::Local, pane_id)
|
||||
}
|
||||
|
||||
pub fn kill_pane_on(route: &PaneRoute, pane_id: u64) {
|
||||
if let Ok(mut stream) = connect_routed(route) {
|
||||
let _ = ClientMsg::Kill { pane_id }.encode(&mut stream);
|
||||
@@ -1275,34 +1241,6 @@ impl RemoteTerminal {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn list_loopback_forwards() -> Vec<LoopbackForwardInfo> {
|
||||
fn query() -> anyhow::Result<Vec<LoopbackForwardInfo>> {
|
||||
let mut stream = connect()?;
|
||||
ClientMsg::ListLoopbackForwards.encode(&mut stream)?;
|
||||
match DaemonMsg::read(&mut stream)? {
|
||||
DaemonMsg::LoopbackForwardList(list) => Ok(list),
|
||||
other => Err(anyhow::anyhow!(
|
||||
"unexpected reply to ListLoopbackForwards: {other:?}"
|
||||
)),
|
||||
}
|
||||
}
|
||||
query().unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn close_loopback_forward(id: LoopbackForwardId) -> Vec<LoopbackForwardInfo> {
|
||||
fn query(id: LoopbackForwardId) -> anyhow::Result<Vec<LoopbackForwardInfo>> {
|
||||
let mut stream = connect()?;
|
||||
ClientMsg::CloseLoopbackForward(id).encode(&mut stream)?;
|
||||
match DaemonMsg::read(&mut stream)? {
|
||||
DaemonMsg::LoopbackForwardList(list) => Ok(list),
|
||||
other => Err(anyhow::anyhow!(
|
||||
"unexpected reply to CloseLoopbackForward: {other:?}"
|
||||
)),
|
||||
}
|
||||
}
|
||||
query(id).unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn spawn_native_ssh(
|
||||
size: TermSize,
|
||||
cell_w: u16,
|
||||
@@ -1415,20 +1353,6 @@ impl RemoteTerminal {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn list_known_hosts() -> Vec<KnownHostEntry> {
|
||||
fn query() -> anyhow::Result<Vec<KnownHostEntry>> {
|
||||
let mut stream = connect()?;
|
||||
ClientMsg::ListKnownHosts.encode(&mut stream)?;
|
||||
match DaemonMsg::read(&mut stream)? {
|
||||
DaemonMsg::KnownHostsList(list) => Ok(list),
|
||||
other => Err(anyhow::anyhow!(
|
||||
"unexpected reply to ListKnownHosts: {other:?}"
|
||||
)),
|
||||
}
|
||||
}
|
||||
query().unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Ask the daemon to dial this spec and say what happened. Blocking, and
|
||||
/// bounded by the spec's own connect timeout on the far side — call it off
|
||||
/// the UI thread.
|
||||
@@ -1446,20 +1370,6 @@ impl RemoteTerminal {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn delete_known_host(id: KnownHostId) -> Vec<KnownHostEntry> {
|
||||
fn query(id: KnownHostId) -> anyhow::Result<Vec<KnownHostEntry>> {
|
||||
let mut stream = connect()?;
|
||||
ClientMsg::DeleteKnownHost(id).encode(&mut stream)?;
|
||||
match DaemonMsg::read(&mut stream)? {
|
||||
DaemonMsg::KnownHostsList(list) => Ok(list),
|
||||
other => Err(anyhow::anyhow!(
|
||||
"unexpected reply to DeleteKnownHost: {other:?}"
|
||||
)),
|
||||
}
|
||||
}
|
||||
query(id).unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn sftp_list(pane_id: u64, path: &str) -> Result<Vec<SftpEntry>, String> {
|
||||
fn query(pane_id: u64, path: String) -> anyhow::Result<Result<Vec<SftpEntry>, String>> {
|
||||
let mut stream = connect()?;
|
||||
@@ -1594,20 +1504,6 @@ impl RemoteTerminal {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn on_workspace_forwards(req: WorkspaceRequest) -> Vec<ManagedForward> {
|
||||
match Self::on_workspace(req) {
|
||||
Ok(DaemonMsg::ForwardList(list)) => list,
|
||||
Ok(other) => {
|
||||
log::warn!("unexpected reply to a workspace forward request: {other:?}");
|
||||
Vec::new()
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!("workspace forward request failed: {e}");
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn workspace_request(
|
||||
ws: &PaneWorkspace,
|
||||
view_pane: u64,
|
||||
|
||||
Reference in New Issue
Block a user