From 895125c4f7b1be0c4fedfb529592285874cad96d Mon Sep 17 00:00:00 2001 From: Nikita Galaiko Date: Mon, 6 Mar 2023 08:22:26 +0100 Subject: [PATCH 01/24] pnpm format --- src/lib/components/BackForwardButtons.svelte | 28 ++++++++++++++++--- src/lib/components/Breadcrumbs.svelte | 8 +++++- src/lib/components/Login.svelte | 4 ++- src/routes/+layout.svelte | 3 +- src/routes/+page.svelte | 13 ++++----- .../[projectId]/timeline/+page.svelte | 9 +++--- src/routes/users/+page.svelte | 12 ++++++-- 7 files changed, 55 insertions(+), 22 deletions(-) diff --git a/src/lib/components/BackForwardButtons.svelte b/src/lib/components/BackForwardButtons.svelte index 0ca6a4393..25f4eb902 100644 --- a/src/lib/components/BackForwardButtons.svelte +++ b/src/lib/components/BackForwardButtons.svelte @@ -4,9 +4,19 @@
- - @@ -257,8 +259,7 @@
-
+
{format(selection.start, 'hh:mm')} diff --git a/src/routes/users/+page.svelte b/src/routes/users/+page.svelte index 60f581fc5..97d952aa4 100644 --- a/src/routes/users/+page.svelte +++ b/src/routes/users/+page.svelte @@ -98,12 +98,17 @@
{#if saving}
+ class="flex w-32 flex-row w-content items-center gap-1 justify-center px-4 py-2 rounded text-white bg-blue-600" + > Updating...
{:else} - + {/if}
@@ -119,7 +124,8 @@
Timeline + search (test)
diff --git a/src/routes/projects/[projectId]/search/+page.svelte b/src/routes/projects/[projectId]/search/+page.svelte new file mode 100644 index 000000000..c9d6b6419 --- /dev/null +++ b/src/routes/projects/[projectId]/search/+page.svelte @@ -0,0 +1,38 @@ + + +
+
+ +
+ +
    + {#each $results as result} +
  • {JSON.stringify(result)}
  • + {/each} +
+
From cfd151fcb939f2dc88f13a0beca879f86cafe25d Mon Sep 17 00:00:00 2001 From: Nikita Galaiko Date: Mon, 6 Mar 2023 10:42:41 +0100 Subject: [PATCH 15/24] sort results by timestamp --- src-tauri/src/search/deltas.rs | 15 ++++++++++-- src-tauri/src/search/deltas_test.rs | 37 +++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/search/deltas.rs b/src-tauri/src/search/deltas.rs index b1d9a151d..f04629e07 100644 --- a/src-tauri/src/search/deltas.rs +++ b/src-tauri/src/search/deltas.rs @@ -62,7 +62,13 @@ impl Deltas { let mmap_dir = MmapDirectory::open(dir)?; let schema = build_schema(); - let index = tantivy::Index::open_or_create(mmap_dir, schema)?; + let index_settings = tantivy::IndexSettings { + ..Default::default() + }; + let index = tantivy::IndexBuilder::new() + .schema(schema) + .settings(index_settings) + .open_or_create(mmap_dir)?; let reader = index.reader()?; let writer = index.writer(WRITE_BUFFER_SIZE)?; @@ -279,7 +285,12 @@ pub fn search( reader.reload()?; let searcher = reader.searcher(); - let top_docs = searcher.search(query, &collector::TopDocs::with_limit(10))?; + + let top_docs = searcher.search( + query, + &collector::TopDocs::with_limit(10) + .order_by_u64_field(index.schema().get_field("timestamp_ms").unwrap()), + )?; let results = top_docs .iter() diff --git a/src-tauri/src/search/deltas_test.rs b/src-tauri/src/search/deltas_test.rs index 571006eb1..807f98bde 100644 --- a/src-tauri/src/search/deltas_test.rs +++ b/src-tauri/src/search/deltas_test.rs @@ -26,6 +26,43 @@ fn test_project() -> Result<(git2::Repository, projects::Project)> { Ok((repo, project)) } +#[test] +fn test_sorted_by_timestamp() { + let (repo, project) = test_project().unwrap(); + let index_path = tempdir().unwrap().path().to_str().unwrap().to_string(); + + let mut session = sessions::Session::from_head(&repo, &project).unwrap(); + deltas::write( + &repo, + &project, + Path::new("test.txt"), + &vec![ + deltas::Delta { + operations: vec![Operation::Insert((0, "Hello".to_string()))], + timestamp_ms: 0, + }, + deltas::Delta { + operations: vec![Operation::Insert((5, " World".to_string()))], + timestamp_ms: 1, + }, + ], + ) + .unwrap(); + session.flush(&repo, &None, &project).unwrap(); + + let mut searcher = super::Deltas::at(index_path.into()).unwrap(); + + let write_result = searcher.index_session(&repo, &project, &session); + assert!(write_result.is_ok()); + + let search_result = searcher.search(&project.id, "hello world"); + assert!(search_result.is_ok()); + let search_result = search_result.unwrap(); + assert_eq!(search_result.len(), 2); + assert_eq!(search_result[0].index, 1); + assert_eq!(search_result[1].index, 0); +} + #[test] fn test_simple() { let (repo, project) = test_project().unwrap(); From c6c3c3feb58faae7beca393148d91d9aca74f1b7 Mon Sep 17 00:00:00 2001 From: Nikita Galaiko Date: Mon, 6 Mar 2023 10:57:09 +0100 Subject: [PATCH 16/24] add limit & offset to the query --- src-tauri/src/main.rs | 13 +++++++-- src-tauri/src/search/deltas.rs | 20 +++++++++----- src-tauri/src/search/deltas_test.rs | 42 ++++++++++++++++++++++++----- src-tauri/src/search/mod.rs | 2 +- src/lib/search.ts | 18 ++++++++----- 5 files changed, 73 insertions(+), 22 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index b3ae7ea23..28b9db455 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -142,15 +142,24 @@ fn search( handle: tauri::AppHandle, project_id: &str, query: &str, + limit: Option, + offset: Option, ) -> Result, Error> { let app_state = handle.state::(); + let query = search::SearchQuery { + project_id: project_id.to_string(), + q: query.to_string(), + limit: limit.unwrap_or(100), + offset, + }; + let deltas = app_state .deltas_searcher .lock() .unwrap() - .search(project_id, query) - .with_context(|| format!("Failed to search for {}", query))?; + .search(&query) + .with_context(|| format!("Failed to search for {:?}", query))?; Ok(deltas) } diff --git a/src-tauri/src/search/deltas.rs b/src-tauri/src/search/deltas.rs index f04629e07..54e33ae67 100644 --- a/src-tauri/src/search/deltas.rs +++ b/src-tauri/src/search/deltas.rs @@ -81,8 +81,8 @@ impl Deltas { }) } - pub fn search(&self, project_id: &str, query: &str) -> Result> { - search(&self.index, &self.reader, project_id, query) + pub fn search(&self, query: &SearchQuery) -> Result> { + search(&self.index, &self.reader, query) } pub fn reindex_project( @@ -262,11 +262,18 @@ fn index( Ok(()) } +#[derive(Debug, Default)] +pub struct SearchQuery { + pub q: String, + pub project_id: String, + pub limit: usize, + pub offset: Option, +} + pub fn search( index: &tantivy::Index, reader: &tantivy::IndexReader, - project_id: &str, - q: &str, + q: &SearchQuery, ) -> Result> { let query = &tantivy::query::QueryParser::for_index( index, @@ -278,7 +285,7 @@ pub fn search( .parse_query( format!( "version:\"{}\" AND project_id:\"{}\" AND ({})", - CURRENT_VERSION, project_id, q + CURRENT_VERSION, q.project_id, q.q, ) .as_str(), )?; @@ -288,7 +295,8 @@ pub fn search( let top_docs = searcher.search( query, - &collector::TopDocs::with_limit(10) + &collector::TopDocs::with_limit(q.limit) + .and_offset(q.offset.unwrap_or(0)) .order_by_u64_field(index.schema().get_field("timestamp_ms").unwrap()), )?; diff --git a/src-tauri/src/search/deltas_test.rs b/src-tauri/src/search/deltas_test.rs index 807f98bde..aec408d77 100644 --- a/src-tauri/src/search/deltas_test.rs +++ b/src-tauri/src/search/deltas_test.rs @@ -55,7 +55,12 @@ fn test_sorted_by_timestamp() { let write_result = searcher.index_session(&repo, &project, &session); assert!(write_result.is_ok()); - let search_result = searcher.search(&project.id, "hello world"); + let search_result = searcher.search(&super::SearchQuery { + project_id: project.id, + q: "hello world".to_string(), + limit: 10, + ..Default::default() + }); assert!(search_result.is_ok()); let search_result = search_result.unwrap(); assert_eq!(search_result.len(), 2); @@ -92,7 +97,12 @@ fn test_simple() { let write_result = searcher.index_session(&repo, &project, &session); assert!(write_result.is_ok()); - let search_result1 = searcher.search(&project.id, "hello"); + let search_result1 = searcher.search(&super::SearchQuery { + project_id: project.id.clone(), + q: "hello".to_string(), + limit: 10, + ..Default::default() + }); assert!(search_result1.is_ok()); let search_result1 = search_result1.unwrap(); assert_eq!(search_result1.len(), 1); @@ -101,7 +111,12 @@ fn test_simple() { assert_eq!(search_result1[0].file_path, "test.txt"); assert_eq!(search_result1[0].index, 0); - let search_result2 = searcher.search(&project.id, "world"); + let search_result2 = searcher.search(&super::SearchQuery { + project_id: project.id.clone(), + q: "world".to_string(), + limit: 10, + ..Default::default() + }); assert!(search_result2.is_ok()); let search_result2 = search_result2.unwrap(); assert_eq!(search_result2.len(), 1); @@ -110,7 +125,12 @@ fn test_simple() { assert_eq!(search_result2[0].file_path, "test.txt"); assert_eq!(search_result2[0].index, 1); - let search_result3 = searcher.search(&project.id, "hello world"); + let search_result3 = searcher.search(&super::SearchQuery { + project_id: project.id.clone(), + q: "hello world".to_string(), + limit: 10, + ..Default::default() + }); println!("{:?}", search_result3); assert!(search_result3.is_ok()); let search_result3 = search_result3.unwrap(); @@ -122,7 +142,12 @@ fn test_simple() { assert_eq!(search_result3[1].project_id, project.id); assert_eq!(search_result3[1].file_path, "test.txt"); - let search_by_filename_result = searcher.search(&project.id, "test.txt"); + let search_by_filename_result = searcher.search(&super::SearchQuery { + project_id: project.id.clone(), + q: "test.txt".to_string(), + limit: 10, + ..Default::default() + }); assert!(search_by_filename_result.is_ok()); let search_by_filename_result = search_by_filename_result.unwrap(); assert_eq!(search_by_filename_result.len(), 2); @@ -130,7 +155,12 @@ fn test_simple() { assert_eq!(search_by_filename_result[0].project_id, project.id); assert_eq!(search_by_filename_result[0].file_path, "test.txt"); - let not_found_result = searcher.search("404", "hello world"); + let not_found_result = searcher.search(&super::SearchQuery { + project_id: "not found".to_string(), + q: "test.txt".to_string(), + limit: 10, + ..Default::default() + }); assert!(not_found_result.is_ok()); let not_found_result = not_found_result.unwrap(); assert_eq!(not_found_result.len(), 0); diff --git a/src-tauri/src/search/mod.rs b/src-tauri/src/search/mod.rs index e4a81e6c2..060fcf845 100644 --- a/src-tauri/src/search/mod.rs +++ b/src-tauri/src/search/mod.rs @@ -1,6 +1,6 @@ mod deltas; -pub use deltas::{Deltas, SearchResult}; +pub use deltas::{Deltas, SearchResult, SearchQuery}; #[cfg(test)] mod deltas_test; diff --git a/src/lib/search.ts b/src/lib/search.ts index 5204eae24..6b106773c 100644 --- a/src/lib/search.ts +++ b/src/lib/search.ts @@ -1,12 +1,16 @@ import { invoke } from '@tauri-apps/api'; export type SearchResult = { - projectId: string; - sessionId: string; - filePath: string; - // index of the delta in the session. - index: number; + projectId: string; + sessionId: string; + filePath: string; + // index of the delta in the session. + index: number; }; -export const search = (params: { projectId: string; query: string }) => - invoke('search', params); +export const search = (params: { + projectId: string; + query: string; + limit?: number; + offset?: number; +}) => invoke('search', params); From 0aefc8be6143017ef67a3a678cd7eb0f465500f6 Mon Sep 17 00:00:00 2001 From: Nikita Galaiko Date: Mon, 6 Mar 2023 13:44:51 +0100 Subject: [PATCH 17/24] support time ranges --- src-tauri/src/main.rs | 7 +++ src-tauri/src/search/deltas.rs | 14 +++-- src-tauri/src/search/deltas_test.rs | 95 ++++++++++++++++++++++++++--- src-tauri/src/search/mod.rs | 2 +- src/lib/search.ts | 2 + 5 files changed, 104 insertions(+), 16 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 28b9db455..498531b5f 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -15,6 +15,7 @@ use log; use serde::{ser::SerializeMap, Serialize}; use std::{ collections::HashMap, + ops::Range, sync::{mpsc, Mutex}, }; use storage::Storage; @@ -144,6 +145,8 @@ fn search( query: &str, limit: Option, offset: Option, + timestamp_ms_gte: Option, + timestamp_ms_lt: Option, ) -> Result, Error> { let app_state = handle.state::(); @@ -152,6 +155,10 @@ fn search( q: query.to_string(), limit: limit.unwrap_or(100), offset, + range: Range { + start: timestamp_ms_gte.unwrap_or(0), + end: timestamp_ms_lt.unwrap_or(u64::MAX), + }, }; let deltas = app_state diff --git a/src-tauri/src/search/deltas.rs b/src-tauri/src/search/deltas.rs index 54e33ae67..60e431d70 100644 --- a/src-tauri/src/search/deltas.rs +++ b/src-tauri/src/search/deltas.rs @@ -1,6 +1,7 @@ use crate::{deltas, projects, sessions, storage}; use anyhow::{Context, Result}; use serde::Serialize; +use std::ops::Range; use std::{ fs, path::{Path, PathBuf}, @@ -162,7 +163,7 @@ fn build_schema() -> schema::Schema { schema_builder.add_text_field("diff", schema::TEXT); schema_builder.add_bool_field("is_addition", schema::FAST); schema_builder.add_bool_field("is_deletion", schema::FAST); - schema_builder.add_u64_field("timestamp_ms", schema::FAST); + schema_builder.add_u64_field("timestamp_ms", schema::INDEXED | schema::FAST); schema_builder.build() } @@ -262,12 +263,13 @@ fn index( Ok(()) } -#[derive(Debug, Default)] +#[derive(Debug)] pub struct SearchQuery { pub q: String, pub project_id: String, pub limit: usize, pub offset: Option, + pub range: Range, } pub fn search( @@ -275,7 +277,7 @@ pub fn search( reader: &tantivy::IndexReader, q: &SearchQuery, ) -> Result> { - let query = &tantivy::query::QueryParser::for_index( + let query = tantivy::query::QueryParser::for_index( index, vec![ index.schema().get_field("diff").unwrap(), @@ -284,8 +286,8 @@ pub fn search( ) .parse_query( format!( - "version:\"{}\" AND project_id:\"{}\" AND ({})", - CURRENT_VERSION, q.project_id, q.q, + "version:\"{}\" AND project_id:\"{}\" AND timestamp_ms:[{} TO {}}} AND ({})", + CURRENT_VERSION, q.project_id, q.range.start, q.range.end, q.q, ) .as_str(), )?; @@ -294,7 +296,7 @@ pub fn search( let searcher = reader.searcher(); let top_docs = searcher.search( - query, + &query, &collector::TopDocs::with_limit(q.limit) .and_offset(q.offset.unwrap_or(0)) .order_by_u64_field(index.schema().get_field("timestamp_ms").unwrap()), diff --git a/src-tauri/src/search/deltas_test.rs b/src-tauri/src/search/deltas_test.rs index aec408d77..6a77a85a3 100644 --- a/src-tauri/src/search/deltas_test.rs +++ b/src-tauri/src/search/deltas_test.rs @@ -1,10 +1,10 @@ -use std::path::Path; - use crate::{ deltas::{self, Operation}, projects, sessions, }; use anyhow::Result; +use core::ops::Range; +use std::path::Path; use tempfile::tempdir; fn test_project() -> Result<(git2::Repository, projects::Project)> { @@ -26,6 +26,76 @@ fn test_project() -> Result<(git2::Repository, projects::Project)> { Ok((repo, project)) } +#[test] +fn test_filter_by_timestamp() { + let (repo, project) = test_project().unwrap(); + let index_path = tempdir().unwrap().path().to_str().unwrap().to_string(); + + let mut session = sessions::Session::from_head(&repo, &project).unwrap(); + deltas::write( + &repo, + &project, + Path::new("test.txt"), + &vec![ + deltas::Delta { + operations: vec![Operation::Insert((0, "Hello".to_string()))], + timestamp_ms: 0, + }, + deltas::Delta { + operations: vec![Operation::Insert((5, "World".to_string()))], + timestamp_ms: 1, + }, + deltas::Delta { + operations: vec![Operation::Insert((5, " ".to_string()))], + timestamp_ms: 2, + }, + ], + ) + .unwrap(); + session.flush(&repo, &None, &project).unwrap(); + + let mut searcher = super::Deltas::at(index_path.into()).unwrap(); + + let write_result = searcher.index_session(&repo, &project, &session); + assert!(write_result.is_ok()); + + let search_result_from = searcher.search(&super::SearchQuery { + project_id: project.id.clone(), + q: "test.txt".to_string(), + limit: 10, + range: Range { start: 2, end: 10 }, + offset: None, + }); + assert!(search_result_from.is_ok()); + let search_result_from = search_result_from.unwrap(); + assert_eq!(search_result_from.len(), 1); + assert_eq!(search_result_from[0].index, 2); + + let search_result_to = searcher.search(&super::SearchQuery { + project_id: project.id.clone(), + q: "hello world".to_string(), + limit: 10, + range: Range { start: 0, end: 1 }, + offset: None, + }); + assert!(search_result_to.is_ok()); + let search_result_to = search_result_to.unwrap(); + assert_eq!(search_result_to.len(), 1); + assert_eq!(search_result_to[0].index, 0); + + let search_result_from_to = searcher.search(&super::SearchQuery { + project_id: project.id.clone(), + q: "hello world".to_string(), + limit: 10, + range: Range { start: 1, end: 2 }, + offset: None, + }); + assert!(search_result_from_to.is_ok()); + let search_result_from_to = search_result_from_to.unwrap(); + assert_eq!(search_result_from_to.len(), 1); + assert_eq!(search_result_from_to[0].index, 1); +} + #[test] fn test_sorted_by_timestamp() { let (repo, project) = test_project().unwrap(); @@ -59,10 +129,12 @@ fn test_sorted_by_timestamp() { project_id: project.id, q: "hello world".to_string(), limit: 10, - ..Default::default() + range: Range { start: 0, end: 10 }, + offset: None, }); assert!(search_result.is_ok()); let search_result = search_result.unwrap(); + println!("{:?}", search_result); assert_eq!(search_result.len(), 2); assert_eq!(search_result[0].index, 1); assert_eq!(search_result[1].index, 0); @@ -101,8 +173,10 @@ fn test_simple() { project_id: project.id.clone(), q: "hello".to_string(), limit: 10, - ..Default::default() + offset: None, + range: Range { start: 0, end: 10 }, }); + println!("{:?}", search_result1); assert!(search_result1.is_ok()); let search_result1 = search_result1.unwrap(); assert_eq!(search_result1.len(), 1); @@ -115,7 +189,8 @@ fn test_simple() { project_id: project.id.clone(), q: "world".to_string(), limit: 10, - ..Default::default() + offset: None, + range: Range { start: 0, end: 10 }, }); assert!(search_result2.is_ok()); let search_result2 = search_result2.unwrap(); @@ -129,9 +204,9 @@ fn test_simple() { project_id: project.id.clone(), q: "hello world".to_string(), limit: 10, - ..Default::default() + offset: None, + range: Range { start: 0, end: 10 }, }); - println!("{:?}", search_result3); assert!(search_result3.is_ok()); let search_result3 = search_result3.unwrap(); assert_eq!(search_result3.len(), 2); @@ -146,7 +221,8 @@ fn test_simple() { project_id: project.id.clone(), q: "test.txt".to_string(), limit: 10, - ..Default::default() + offset: None, + range: Range { start: 0, end: 10 }, }); assert!(search_by_filename_result.is_ok()); let search_by_filename_result = search_by_filename_result.unwrap(); @@ -159,7 +235,8 @@ fn test_simple() { project_id: "not found".to_string(), q: "test.txt".to_string(), limit: 10, - ..Default::default() + offset: None, + range: Range { start: 0, end: 10 }, }); assert!(not_found_result.is_ok()); let not_found_result = not_found_result.unwrap(); diff --git a/src-tauri/src/search/mod.rs b/src-tauri/src/search/mod.rs index 060fcf845..316b2554e 100644 --- a/src-tauri/src/search/mod.rs +++ b/src-tauri/src/search/mod.rs @@ -1,6 +1,6 @@ mod deltas; -pub use deltas::{Deltas, SearchResult, SearchQuery}; +pub use deltas::{Deltas, SearchQuery, SearchResult}; #[cfg(test)] mod deltas_test; diff --git a/src/lib/search.ts b/src/lib/search.ts index 6b106773c..92f6ed285 100644 --- a/src/lib/search.ts +++ b/src/lib/search.ts @@ -6,6 +6,8 @@ export type SearchResult = { filePath: string; // index of the delta in the session. index: number; + timestampMsGte?: number; + timestampMsLt?: number; }; export const search = (params: { From 6b9c2db7a0588796b07566f348a6469ccdd2314b Mon Sep 17 00:00:00 2001 From: Nikita Galaiko Date: Mon, 6 Mar 2023 13:53:04 +0100 Subject: [PATCH 18/24] pnpm format --- src/lib/search.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/lib/search.ts b/src/lib/search.ts index 92f6ed285..a7168c729 100644 --- a/src/lib/search.ts +++ b/src/lib/search.ts @@ -1,18 +1,18 @@ import { invoke } from '@tauri-apps/api'; export type SearchResult = { - projectId: string; - sessionId: string; - filePath: string; - // index of the delta in the session. - index: number; - timestampMsGte?: number; - timestampMsLt?: number; + projectId: string; + sessionId: string; + filePath: string; + // index of the delta in the session. + index: number; + timestampMsGte?: number; + timestampMsLt?: number; }; export const search = (params: { - projectId: string; - query: string; - limit?: number; - offset?: number; + projectId: string; + query: string; + limit?: number; + offset?: number; }) => invoke('search', params); From 04734efcf4518b8309dedb2fcd2f8e7733e4b987 Mon Sep 17 00:00:00 2001 From: Kiril Videlov Date: Tue, 7 Mar 2023 09:46:17 +0100 Subject: [PATCH 19/24] lower the session related logging output --- src-tauri/src/watchers/session.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src-tauri/src/watchers/session.rs b/src-tauri/src/watchers/session.rs index e3fd2cb8d..39e4d5d16 100644 --- a/src-tauri/src/watchers/session.rs +++ b/src-tauri/src/watchers/session.rs @@ -38,8 +38,6 @@ impl<'a> SessionWatcher { format!("Error while getting project {} for git watcher", project_id) })? { Some(project) => { - log::info!("Checking for session to commit in {}", project.path); - let user = self.users_storage.get().with_context(|| { format!( "Error while getting user for git watcher in {}", @@ -130,10 +128,6 @@ fn session_to_commit( ) -> Result> { match sessions::Session::current(repo, project)? { None => { - log::debug!( - "No current session to commit for {}", - repo.workdir().unwrap().display() - ); Ok(None) } Some(current_session) => { From 96e4f16703e099fdfdb0e56ddbe99126f79d060b Mon Sep 17 00:00:00 2001 From: Kiril Videlov Date: Tue, 7 Mar 2023 10:05:27 +0100 Subject: [PATCH 20/24] dont panic on search error --- src-tauri/src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 498531b5f..01457e8d8 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -161,10 +161,11 @@ fn search( }, }; - let deltas = app_state + let deltas_lock = app_state .deltas_searcher .lock() - .unwrap() + .map_err(|poison_err| anyhow::anyhow!("Lock poisoned: {:?}", poison_err))?; + let deltas = deltas_lock .search(&query) .with_context(|| format!("Failed to search for {:?}", query))?; From efc07705e45f0a1987cc0c648297ca46f0624daa Mon Sep 17 00:00:00 2001 From: Kiril Videlov Date: Tue, 7 Mar 2023 10:18:56 +0100 Subject: [PATCH 21/24] release the lock when there are broken projects --- src-tauri/src/main.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 01457e8d8..3dd5054db 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -551,8 +551,7 @@ fn init(app_handle: tauri::AppHandle) -> Result<()> { .lock() .unwrap() .reindex_project(&repo, &project) - .with_context(|| format!("Failed to reindex project: {}", project.id)) - .unwrap(); + .with_context(|| format!("Failed to reindex project: {}", project.id))?; } watch_events(app_handle, rx); From e49e3433ed5113e1cb28c2070a254de5c93202e3 Mon Sep 17 00:00:00 2001 From: Nikita Galaiko Date: Tue, 7 Mar 2023 11:52:18 +0100 Subject: [PATCH 22/24] setup prettier-plugin-tailwindcss --- package.json | 1 + pnpm-lock.yaml | 88 +++++++++++++++---- src/app.html | 2 +- src/lib/components/BackForwardButtons.svelte | 8 +- src/lib/components/Breadcrumbs.svelte | 16 ++-- .../components/CodeViewer/CodeViewer.svelte | 2 +- src/lib/components/Login.svelte | 4 +- src/lib/components/Popover/Popover.svelte | 2 +- .../timeline/TimelineDaySession.svelte | 14 +-- .../TimelineDaySessionActivities.svelte | 14 +-- src/lib/components/week/WeekBlockEntry.svelte | 2 +- src/routes/+error.svelte | 2 +- src/routes/+layout.svelte | 8 +- src/routes/+page.svelte | 46 +++++----- .../projects/[projectId]/+layout.svelte | 16 ++-- src/routes/projects/[projectId]/+page.svelte | 8 +- .../projects/[projectId]/search/+page.svelte | 2 +- .../[projectId]/settings/+page.svelte | 30 +++---- .../[projectId]/timeline/+page.svelte | 62 ++++++------- src/routes/users/+page.svelte | 36 ++++---- 20 files changed, 211 insertions(+), 152 deletions(-) diff --git a/package.json b/package.json index d4d562414..eaed0f907 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,7 @@ "postcss-load-config": "^4.0.1", "prettier": "^2.8.0", "prettier-plugin-svelte": "^2.8.1", + "prettier-plugin-tailwindcss": "^0.2.4", "svelte": "^3.55.1", "svelte-check": "^3.0.1", "tailwindcss": "^3.1.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a786f280c..97f4b4bc5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -48,6 +48,7 @@ specifiers: posthog-js: ^1.46.1 prettier: ^2.8.0 prettier-plugin-svelte: ^2.8.1 + prettier-plugin-tailwindcss: ^0.2.4 seti-icons: ^0.0.4 svelte: ^3.55.1 svelte-check: ^3.0.1 @@ -62,7 +63,7 @@ dependencies: '@codemirror/autocomplete': 6.4.2_yom6siklgbeshd7shgtg2sdiku '@codemirror/commands': 6.2.0 '@codemirror/lang-angular': github.com/codemirror/lang-angular/ee6151b55668b2941c71b0d1db9f5a526ef29710 - '@codemirror/lang-css': github.com/codemirror/lang-css/9f5b41703dff289d94731c5caba72cf3b57fff43_nzpoxphwgc7witc3f5hdaoweju + '@codemirror/lang-css': github.com/codemirror/lang-css/2cde46bf378ae36413e7fca5e24a2606f3cdf840_nzpoxphwgc7witc3f5hdaoweju '@codemirror/lang-html': github.com/codemirror/lang-html/0420487e1ac04bfd59129c243e3b7b802ffca30c '@codemirror/lang-java': github.com/codemirror/lang-java/834c534e7d689b0d88c15e3af55b0ee551d985d2 '@codemirror/lang-javascript': 6.1.4 @@ -82,7 +83,7 @@ dependencies: '@lezer/lr': 1.3.3 '@nextjournal/lang-clojure': 1.0.0 '@replit/codemirror-lang-csharp': 6.1.0_dbd6aqsmfpystthdbxnrle4dwe - '@replit/codemirror-lang-svelte': 6.0.0_zlhskyhbzw2pn2yfpaeuivpmfu + '@replit/codemirror-lang-svelte': 6.0.0_yycrqtt34ynecrgehdjoffcaie '@square/svelte-store': 1.0.14 '@tabler/icons-svelte': 2.6.0_svelte@3.55.1 '@tauri-apps/api': 1.2.0 @@ -94,7 +95,7 @@ dependencies: posthog-js: 1.46.1 seti-icons: 0.0.4 svelte-french-toast: 1.0.3_svelte@3.55.1 - tauri-plugin-log-api: github.com/tauri-apps/tauri-plugin-log/921afb3366b14ac43e3d8041a7def4b85d4d7192 + tauri-plugin-log-api: github.com/tauri-apps/tauri-plugin-log/05a9bfd9edb9b5f4ab95412bb607691708b65a25 devDependencies: '@sveltejs/adapter-static': 1.0.0-next.50_l5ueyfihz3gpzzvvyo2ean5u3e @@ -111,6 +112,7 @@ devDependencies: postcss-load-config: 4.0.1_postcss@8.4.21 prettier: 2.8.4 prettier-plugin-svelte: 2.9.0_jrsxveqmsx2uadbqiuq74wlc4u + prettier-plugin-tailwindcss: 0.2.4_yjdjpc7im5hvpskij45owfsns4 svelte: 3.55.1 svelte-check: 3.0.3_gqx7lw3sljhsd4bstor5m2aa2u tailwindcss: 3.2.4_postcss@8.4.21 @@ -143,8 +145,8 @@ packages: '@lezer/common': 1.0.2 dev: false - /@codemirror/lang-css/6.0.2_nzpoxphwgc7witc3f5hdaoweju: - resolution: {integrity: sha512-4V4zmUOl2Glx0GWw0HiO1oGD4zvMlIQ3zx5hXOE6ipCjhohig2bhWRAasrZylH9pRNTcl1VMa59Lsl8lZWlTzw==} + /@codemirror/lang-css/6.1.0_nzpoxphwgc7witc3f5hdaoweju: + resolution: {integrity: sha512-GYn4TyMvQLrkrhdisFh8HCTDAjPY/9pzwN12hG9UdrTUxRUMicF+8GS24sFEYaleaG1KZClIFLCj0Rol/WO24w==} dependencies: '@codemirror/autocomplete': 6.4.2_yom6siklgbeshd7shgtg2sdiku '@codemirror/language': 6.6.0 @@ -159,7 +161,7 @@ packages: resolution: {integrity: sha512-bqCBASkteKySwtIbiV/WCtGnn/khLRbbiV5TE+d9S9eQJD7BA4c5dTRm2b3bVmSpilff5EYxvB4PQaZzM/7cNw==} dependencies: '@codemirror/autocomplete': 6.4.2_yom6siklgbeshd7shgtg2sdiku - '@codemirror/lang-css': 6.0.2_nzpoxphwgc7witc3f5hdaoweju + '@codemirror/lang-css': 6.1.0_nzpoxphwgc7witc3f5hdaoweju '@codemirror/lang-javascript': 6.1.4 '@codemirror/language': 6.6.0 '@codemirror/state': 6.2.0 @@ -608,7 +610,7 @@ packages: '@lezer/lr': 1.3.3 dev: false - /@replit/codemirror-lang-svelte/6.0.0_zlhskyhbzw2pn2yfpaeuivpmfu: + /@replit/codemirror-lang-svelte/6.0.0_yycrqtt34ynecrgehdjoffcaie: resolution: {integrity: sha512-U2OqqgMM6jKelL0GNWbAmqlu1S078zZNoBqlJBW+retTc5M4Mha6/Y2cf4SVg6ddgloJvmcSpt4hHrVoM4ePRA==} peerDependencies: '@codemirror/autocomplete': ^6.0.0 @@ -624,7 +626,7 @@ packages: '@lezer/lr': ^1.0.0 dependencies: '@codemirror/autocomplete': 6.4.2_yom6siklgbeshd7shgtg2sdiku - '@codemirror/lang-css': github.com/codemirror/lang-css/9f5b41703dff289d94731c5caba72cf3b57fff43_nzpoxphwgc7witc3f5hdaoweju + '@codemirror/lang-css': github.com/codemirror/lang-css/2cde46bf378ae36413e7fca5e24a2606f3cdf840_nzpoxphwgc7witc3f5hdaoweju '@codemirror/lang-html': github.com/codemirror/lang-html/0420487e1ac04bfd59129c243e3b7b802ffca30c '@codemirror/lang-javascript': 6.1.4 '@codemirror/language': 6.6.0 @@ -2505,6 +2507,62 @@ packages: svelte: 3.55.1 dev: true + /prettier-plugin-tailwindcss/0.2.4_yjdjpc7im5hvpskij45owfsns4: + resolution: {integrity: sha512-wMyugRI2yD8gqmMpZSS8kTA0gGeKozX/R+w8iWE+yiCZL09zY0SvfiHfHabNhjGhzxlQ2S2VuTxPE3T72vppCQ==} + engines: {node: '>=12.17.0'} + peerDependencies: + '@ianvs/prettier-plugin-sort-imports': '*' + '@prettier/plugin-php': '*' + '@prettier/plugin-pug': '*' + '@shopify/prettier-plugin-liquid': '*' + '@shufo/prettier-plugin-blade': '*' + '@trivago/prettier-plugin-sort-imports': '*' + prettier: '>=2.2.0' + prettier-plugin-astro: '*' + prettier-plugin-css-order: '*' + prettier-plugin-import-sort: '*' + prettier-plugin-jsdoc: '*' + prettier-plugin-organize-attributes: '*' + prettier-plugin-organize-imports: '*' + prettier-plugin-style-order: '*' + prettier-plugin-svelte: '*' + prettier-plugin-twig-melody: '*' + peerDependenciesMeta: + '@ianvs/prettier-plugin-sort-imports': + optional: true + '@prettier/plugin-php': + optional: true + '@prettier/plugin-pug': + optional: true + '@shopify/prettier-plugin-liquid': + optional: true + '@shufo/prettier-plugin-blade': + optional: true + '@trivago/prettier-plugin-sort-imports': + optional: true + prettier-plugin-astro: + optional: true + prettier-plugin-css-order: + optional: true + prettier-plugin-import-sort: + optional: true + prettier-plugin-jsdoc: + optional: true + prettier-plugin-organize-attributes: + optional: true + prettier-plugin-organize-imports: + optional: true + prettier-plugin-style-order: + optional: true + prettier-plugin-svelte: + optional: true + prettier-plugin-twig-melody: + optional: true + dependencies: + prettier: 2.8.4 + prettier-plugin-svelte: 2.9.0_jrsxveqmsx2uadbqiuq74wlc4u + dev: true + /prettier/2.8.4: resolution: {integrity: sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw==} engines: {node: '>=10.13.0'} @@ -3192,11 +3250,11 @@ packages: '@lezer/highlight': 1.1.3 dev: false - github.com/codemirror/lang-css/9f5b41703dff289d94731c5caba72cf3b57fff43_nzpoxphwgc7witc3f5hdaoweju: - resolution: {tarball: https://codeload.github.com/codemirror/lang-css/tar.gz/9f5b41703dff289d94731c5caba72cf3b57fff43} - id: github.com/codemirror/lang-css/9f5b41703dff289d94731c5caba72cf3b57fff43 + github.com/codemirror/lang-css/2cde46bf378ae36413e7fca5e24a2606f3cdf840_nzpoxphwgc7witc3f5hdaoweju: + resolution: {tarball: https://codeload.github.com/codemirror/lang-css/tar.gz/2cde46bf378ae36413e7fca5e24a2606f3cdf840} + id: github.com/codemirror/lang-css/2cde46bf378ae36413e7fca5e24a2606f3cdf840 name: '@codemirror/lang-css' - version: 6.0.2 + version: 6.1.0 prepare: true requiresBuild: true dependencies: @@ -3217,7 +3275,7 @@ packages: requiresBuild: true dependencies: '@codemirror/autocomplete': 6.4.2_yom6siklgbeshd7shgtg2sdiku - '@codemirror/lang-css': 6.0.2_nzpoxphwgc7witc3f5hdaoweju + '@codemirror/lang-css': 6.1.0_nzpoxphwgc7witc3f5hdaoweju '@codemirror/lang-javascript': 6.1.4 '@codemirror/language': 6.6.0 '@codemirror/state': 6.2.0 @@ -3321,8 +3379,8 @@ packages: '@lezer/lr': 1.3.3 dev: false - github.com/tauri-apps/tauri-plugin-log/921afb3366b14ac43e3d8041a7def4b85d4d7192: - resolution: {tarball: https://codeload.github.com/tauri-apps/tauri-plugin-log/tar.gz/921afb3366b14ac43e3d8041a7def4b85d4d7192} + github.com/tauri-apps/tauri-plugin-log/05a9bfd9edb9b5f4ab95412bb607691708b65a25: + resolution: {tarball: https://codeload.github.com/tauri-apps/tauri-plugin-log/tar.gz/05a9bfd9edb9b5f4ab95412bb607691708b65a25} name: tauri-plugin-log-api version: 0.0.0 dependencies: diff --git a/src/app.html b/src/app.html index 7709a6d49..e1211dd6f 100644 --- a/src/app.html +++ b/src/app.html @@ -6,7 +6,7 @@ %sveltekit.head% - +
%sveltekit.body%
diff --git a/src/lib/components/BackForwardButtons.svelte b/src/lib/components/BackForwardButtons.svelte index 25f4eb902..aa3b89505 100644 --- a/src/lib/components/BackForwardButtons.svelte +++ b/src/lib/components/BackForwardButtons.svelte @@ -5,11 +5,11 @@
{:else if $token !== null} @@ -40,7 +40,7 @@

{:else} {/if} diff --git a/src/lib/components/Popover/Popover.svelte b/src/lib/components/Popover/Popover.svelte index 7ce2a6ad6..c9e23cf02 100644 --- a/src/lib/components/Popover/Popover.svelte +++ b/src/lib/components/Popover/Popover.svelte @@ -66,7 +66,7 @@ in:fadeAndZoomIn={{ duration: 150 }} out:fade={{ duration: 100 }} on:mouseup={() => (showPopover = false)} - class="wrapper z-[999] bg-zinc-800 border border-zinc-700 text-zinc-50 rounded shadow-2xl min-w-[180px] max-w-[512px]" + class="wrapper z-[999] min-w-[180px] max-w-[512px] rounded border border-zinc-700 bg-zinc-800 text-zinc-50 shadow-2xl" style="--popover-top: {`${bottom}px`}; --popover-left: {`${left}px`}" > diff --git a/src/lib/components/timeline/TimelineDaySession.svelte b/src/lib/components/timeline/TimelineDaySession.svelte index 22991d87b..6f385ed9b 100644 --- a/src/lib/components/timeline/TimelineDaySession.svelte +++ b/src/lib/components/timeline/TimelineDaySession.svelte @@ -53,7 +53,7 @@ {#if !session.hash} - + {/if} @@ -91,11 +91,11 @@
{#await list({ projectId: projectId, sessionId: session.id }) then deltas} {#each Object.keys(deltas) as delta} -
-
+
+
{@html pathToIconSvg(delta)}
-
+
{pathToName(delta)}
diff --git a/src/lib/components/timeline/TimelineDaySessionActivities.svelte b/src/lib/components/timeline/TimelineDaySessionActivities.svelte index 5d3215e6a..6025fbc84 100644 --- a/src/lib/components/timeline/TimelineDaySessionActivities.svelte +++ b/src/lib/components/timeline/TimelineDaySessionActivities.svelte @@ -25,26 +25,26 @@
-
+
{#each activities as activity}
{#if activity.type.startsWith('commit')} - + {:else if activity.type.startsWith('merge')} - + {:else if activity.type.startsWith('rebase')} - + {:else if activity.type.startsWith('push')} - + {/if}
diff --git a/src/lib/components/week/WeekBlockEntry.svelte b/src/lib/components/week/WeekBlockEntry.svelte index 2f0fbdb45..92cb3fffc 100644 --- a/src/lib/components/week/WeekBlockEntry.svelte +++ b/src/lib/components/week/WeekBlockEntry.svelte @@ -38,7 +38,7 @@

{toHumanBranchName(label)} diff --git a/src/routes/+error.svelte b/src/routes/+error.svelte index ed6c90552..1572e9747 100644 --- a/src/routes/+error.svelte +++ b/src/routes/+error.svelte @@ -15,7 +15,7 @@ : 'Something went wrong'; -

+

{message} :(

diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 6b0f3e5bf..4853e5071 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -18,20 +18,20 @@ user.subscribe(posthog.identify); -
+
- + {#if $user} {#if $user.picture} - Avatar + Avatar {/if} {$user.name} {:else} diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 614d3e328..ae3f6a2bb 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -24,15 +24,15 @@ }; -
-
+
+
{#if $projects.length == 0} -
+
-
-
+
+
Welcome to GitButler.
-
More than just version control.
+
More than just version control.
GitButler is a tool to help you manage all the local work you do on your code projects. @@ -41,7 +41,7 @@ Think of us as a code concierge, a smart assistant for all the coding related tasks you need to do every day.
-