aboutsummaryrefslogtreecommitdiffstats
path: root/ui/backend/src/run
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@atuin.sh>2024-07-30 16:54:10 +0100
committerGitHub <noreply@github.com>2024-07-30 16:54:10 +0100
commit808138de633e410c1d3867d4fb7cb74967647605 (patch)
treef180b7066b91d8d8d8006219a118439be1621d74 /ui/backend/src/run
parentchore(deps): bump debian (#2320) (diff)
downloadatuin-808138de633e410c1d3867d4fb7cb74967647605.zip
chore: remove ui directory (#2329)
This is still in development, but rather than clutter the commit history and issues with an unreleased project I've split the UI into its own repo. Once ready for release, I'll either merge the ui code back in, or just make the repo public.
Diffstat (limited to 'ui/backend/src/run')
-rw-r--r--ui/backend/src/run/migrations.rs13
-rw-r--r--ui/backend/src/run/mod.rs2
-rw-r--r--ui/backend/src/run/pty.rs103
3 files changed, 0 insertions, 118 deletions
diff --git a/ui/backend/src/run/migrations.rs b/ui/backend/src/run/migrations.rs
deleted file mode 100644
index 3516e62a..00000000
--- a/ui/backend/src/run/migrations.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-use lazy_static::lazy_static;
-use tauri_plugin_sql::{Builder, Migration, MigrationKind};
-
-pub fn migrations() -> Vec<Migration> {
- vec![
- Migration {
- version: 1,
- description: "create_initial_tables",
- sql: "CREATE TABLE runbooks(id string PRIMARY KEY, name TEXT, content TEXT, created bigint, updated bigint);",
- kind: MigrationKind::Up,
- }
- ]
-}
diff --git a/ui/backend/src/run/mod.rs b/ui/backend/src/run/mod.rs
deleted file mode 100644
index a7a28497..00000000
--- a/ui/backend/src/run/mod.rs
+++ /dev/null
@@ -1,2 +0,0 @@
-pub mod migrations;
-pub mod pty;
diff --git a/ui/backend/src/run/pty.rs b/ui/backend/src/run/pty.rs
deleted file mode 100644
index 72ca98d2..00000000
--- a/ui/backend/src/run/pty.rs
+++ /dev/null
@@ -1,103 +0,0 @@
-use eyre::{Result, WrapErr};
-use std::io::BufRead;
-use std::path::PathBuf;
-
-use crate::state::AtuinState;
-use tauri::{Emitter, Manager, State};
-
-use atuin_client::{database::Sqlite, record::sqlite_store::SqliteStore, settings::Settings};
-
-#[tauri::command]
-pub async fn pty_open<'a>(
- app: tauri::AppHandle,
- state: State<'a, AtuinState>,
- cwd: Option<String>,
-) -> Result<uuid::Uuid, String> {
- let id = uuid::Uuid::new_v4();
-
- let cwd = cwd.map(|c| shellexpand::tilde(c.as_str()).to_string());
- let pty = crate::pty::Pty::open(24, 80, cwd).await.unwrap();
-
- let reader = pty.reader.clone();
-
- tauri::async_runtime::spawn_blocking(move || loop {
- let mut buf = [0u8; 512];
-
- match reader.lock().unwrap().read(&mut buf) {
- // EOF
- Ok(0) => {
- println!("reader loop hit eof");
- break;
- }
-
- Ok(n) => {
- println!("read {n} bytes");
-
- // TODO: sort inevitable encoding issues
- let out = String::from_utf8_lossy(&buf).to_string();
- let out = out.trim_matches(char::from(0));
- let channel = format!("pty-{id}");
-
- app.emit(channel.as_str(), out).unwrap();
- }
-
- Err(e) => {
- println!("failed to read: {e}");
- break;
- }
- }
- });
-
- state.pty_sessions.write().await.insert(id, pty);
-
- Ok(id)
-}
-
-#[tauri::command]
-pub(crate) async fn pty_write(
- pid: uuid::Uuid,
- data: String,
- state: tauri::State<'_, AtuinState>,
-) -> Result<(), String> {
- let sessions = state.pty_sessions.read().await;
- let pty = sessions.get(&pid).ok_or("Pty not found")?;
-
- let bytes = data.as_bytes().to_vec();
- pty.send_bytes(bytes.into())
- .await
- .map_err(|e| e.to_string())?;
- Ok(())
-}
-
-#[tauri::command]
-pub(crate) async fn pty_resize(
- pid: uuid::Uuid,
- rows: u16,
- cols: u16,
- state: tauri::State<'_, AtuinState>,
-) -> Result<(), String> {
- let sessions = state.pty_sessions.read().await;
- let pty = sessions.get(&pid).ok_or("Pty not found")?;
-
- pty.resize(rows, cols).await.map_err(|e| e.to_string())?;
-
- Ok(())
-}
-
-#[tauri::command]
-pub(crate) async fn pty_kill(
- pid: uuid::Uuid,
- state: tauri::State<'_, AtuinState>,
-) -> Result<(), String> {
- let pty = state.pty_sessions.write().await.remove(&pid);
-
- match pty {
- Some(pty) => {
- pty.kill_child().await.map_err(|e| e.to_string())?;
- println!("RIP {pid:?}");
- }
- None => {}
- }
-
- Ok(())
-}