Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
1716467
feat(linux-grid): add Highlight Rules to colour the rows and cells th…
sedax90 Nov 8, 2026
1542564
fix(linux-grid): let a highlight win over the row shading
sedax90 Nov 8, 2026
3777079
docs(linux-grid): add the changelog entry
sedax90 Nov 8, 2026
72991a9
feat(linux-grid): keep a table's highlight rules across restarts
sedax90 Nov 8, 2026
372a4b0
docs(linux-grid): add the changelog entry
sedax90 Nov 8, 2026
4632452
fix(linux-grid): rebuild highlight rule evaluation and editing
datlechin Nov 8, 2026
a20f397
chore(linux-grid): merge reviewed highlight rules into persistence
datlechin Nov 8, 2026
a1ef9de
fix(linux-grid): preserve table rules and report failed state writes
datlechin Nov 8, 2026
fda40d2
fix(linux-grid): recheck pending settings before final window close
datlechin Nov 8, 2026
7d2b695
fix(linux-grid): borrow expected rules in result retention test
datlechin Nov 8, 2026
59738eb
fix(linux-grid): borrow rules in duplicate column test
datlechin Nov 8, 2026
4f4f745
chore(linux-grid): merge highlight rule test lint fixes
datlechin Nov 8, 2026
5e392a7
refactor(linux-grid): extract window quit input handler
datlechin Nov 8, 2026
a3576fa
fix(linux-grid): apply restored highlights on first cell bind
datlechin Nov 8, 2026
1b780b0
test(linux-grid): inspect unpresented highlight dialog content
datlechin Nov 8, 2026
52b74ae
fix(linux-grid): preserve immediate close and plain settings notices
datlechin Nov 8, 2026
b012289
chore(linux-grid): merge highlight dialog test lookup fix
datlechin Nov 8, 2026
38ed4ae
fix(linux-grid): apply highlights when new cells first bind
datlechin Nov 8, 2026
fccdfe7
chore(linux-grid): merge shared first-bind highlight fix
datlechin Nov 8, 2026
393fc41
Merge remote-tracking branch 'origin/main' into feat/linux-highlight-…
datlechin Nov 9, 2026
d0d51ff
Merge commit '393fc4197' into feat/linux-highlight-rules-saved
datlechin Nov 9, 2026
ad9b07f
Merge remote-tracking branch 'origin/main' into feat/linux-highlight-…
datlechin Nov 9, 2026
45c7b12
Merge commit 'ad9b07f6b' into feat/linux-highlight-rules-saved
datlechin Nov 9, 2026
a50b071
fix(linux-grid): move a renamed table's highlight rules to its new name
datlechin Nov 9, 2026
d3cc34e
Merge remote-tracking branch 'origin/main' into feat/linux-highlight-…
datlechin Nov 10, 2026
5c77160
Merge commit 'd3cc34e1d6360c3c3c3ca932e15271fa1c4b63d4' into feat/lin…
datlechin Nov 10, 2026
07ac092
Merge remote-tracking branch 'origin/main' into feat/linux-highlight-…
datlechin Nov 10, 2026
aaeb94b
Merge commit '07ac0924edaddc28178b50820686df50fe5520fa' into feat/lin…
datlechin Nov 10, 2026
10443ff
Merge remote-tracking branch 'origin/main' into feat/linux-highlight-…
datlechin Nov 10, 2026
a6f6e06
Merge commit '10443fff5' into feat/linux-highlight-rules-saved
datlechin Nov 10, 2026
5316846
fix(linux-grid): match highlight rules on ISO dates now that whole_te…
datlechin Nov 10, 2026
31072ff
Merge commit '531684618f7436b6eb3082b9f11d5e194ff70f1a' into feat/lin…
datlechin Nov 10, 2026
c24d30c
refactor(linux-browse): restore a tab's highlight rules in a function…
datlechin Nov 10, 2026
6806ed1
refactor(linux-browse): read the highlight rules' table from the grid
datlechin Nov 10, 2026
98f78f8
Merge remote-tracking branch 'origin/main' into feat/linux-highlight-…
datlechin Nov 10, 2026
f991cde
Merge remote-tracking branch 'origin/main' into feat/linux-highlight-…
datlechin Nov 11, 2026
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
8 changes: 8 additions & 0 deletions core/crates/storage/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ impl StoragePaths {
self.config.join("filter_settings.json")
}

pub fn highlight_rules_file(&self) -> PathBuf {
self.config.join("highlight_rules.json")
}

pub fn drafts_dir(&self) -> PathBuf {
self.data.join("drafts")
}
Expand Down Expand Up @@ -85,6 +89,10 @@ mod tests {
assert_eq!(paths.runtime, root.join("runtime/app/app.tablepro.TablePro"));
assert_eq!(paths.history_database(), root.join("state/tablepro/history.db"));
assert_eq!(paths.connections_file(), root.join("config/tablepro/connections.json"));
assert_eq!(
paths.highlight_rules_file(),
root.join("config/tablepro/highlight_rules.json")
);
assert_eq!(paths.snippets_dir(), root.join("data/tablepro/snippets"));
assert_eq!(paths.account_file(), root.join("state/tablepro/account.json"));
assert_eq!(paths.telemetry_file(), root.join("state/tablepro/telemetry.json"));
Expand Down
1 change: 1 addition & 0 deletions linux/changelog.d/4129.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Highlight Rules are kept for each table across restarts, including database files and other databases.
1 change: 1 addition & 0 deletions linux/crates/app/src/application/app_services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ impl AppServices {
)),
column_layouts: self.storage.column_layouts().clone(),
filters: self.storage.filter_settings().clone(),
highlight_rules: self.storage.highlight_rules().clone(),
workspaces: self.storage.workspaces().clone(),
history,
spawner: self.tasks.clone(),
Expand Down
77 changes: 45 additions & 32 deletions linux/crates/app/src/persistence/column_layout_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ use std::rc::Rc;
use tablepro_session::runtime::Tasks;
use uuid::Uuid;

use super::StateFile;
use super::column_layouts_document::ColumnLayoutsDocument;
use super::{StateFile, StateFileError, TableStateKey};
use crate::services::grid::ColumnLayout;

/// Each table's column order, hidden columns and widths, remembered per
/// connection, schema and table.
#[derive(Clone)]
pub struct ColumnLayoutStore {
file: Rc<StateFile<ColumnLayoutsDocument>>,
Expand All @@ -31,16 +29,12 @@ impl ColumnLayoutStore {
self.file.path()
}

pub fn layout(&self, connection_id: Uuid, schema: Option<&str>, table: &str) -> ColumnLayout {
self.read(connection_id, schema, table, |layout| {
layout.cloned().unwrap_or_default()
})
pub fn layout(&self, key: impl Into<TableStateKey>, schema: Option<&str>, table: &str) -> ColumnLayout {
self.read(&key.into(), schema, table, |layout| layout.cloned().unwrap_or_default())
}

/// Keep `layout` as the table's whole layout. The grid merges what it
/// shows into the stored layout before it saves.
pub fn save(&self, connection_id: Uuid, schema: Option<&str>, table: &str, layout: &ColumnLayout) {
self.change(connection_id, schema, table, |stored| {
pub fn save(&self, key: impl Into<TableStateKey>, schema: Option<&str>, table: &str, layout: &ColumnLayout) {
self.change(&key.into(), schema, table, |stored| {
if stored == layout {
return false;
}
Expand All @@ -49,20 +43,43 @@ impl ColumnLayoutStore {
});
}

/// Drop everything for a connection the user deleted, so the file
/// does not grow with entries nothing can reach.
pub fn forget_connection(&self, connection_id: Uuid) {
self.file
.update(|document| document.connections.remove(&connection_id.to_string()).is_some());
self.file.update(|document| {
let before = document.connections.len();
document
.connections
.retain(|key, _| !TableStateKey::belongs_to(key, connection_id));
before != document.connections.len()
});
}

pub fn failing(&self) -> tokio::sync::watch::Receiver<bool> {
self.file.failing()
}

pub fn revision(&self) -> u64 {
self.file.revision()
}

pub fn has_unsaved_changes(&self) -> bool {
self.file.has_unsaved_changes()
}

pub fn current_error(&self) -> Option<StateFileError> {
self.file.current_error()
}

pub fn retry(&self) -> bool {
self.file.retry()
}

pub fn flush(&self) -> impl Future<Output = ()> + Send + use<> {
pub fn flush(&self) -> impl Future<Output = Result<(), StateFileError>> + Send + use<> {
self.file.flush()
}

fn read<R>(
&self,
connection_id: Uuid,
key: &TableStateKey,
schema: Option<&str>,
table: &str,
with: impl FnOnce(Option<&ColumnLayout>) -> R,
Expand All @@ -71,33 +88,30 @@ impl ColumnLayoutStore {
with(
document
.connections
.get(&connection_id.to_string())
.get(key.as_str())
.and_then(|schemas| schemas.get(schema_key(schema)))
.and_then(|tables| tables.get(table)),
)
})
}

/// Change one table's layout. `change` returns whether anything moved.
/// A layout left with nothing in it is removed with any map it empties,
/// so a reset shrinks the file back.
fn change(
&self,
connection_id: Uuid,
key: &TableStateKey,
schema: Option<&str>,
table: &str,
change: impl FnOnce(&mut ColumnLayout) -> bool,
) {
let mut layout = self.layout(connection_id, schema, table);
let mut layout = self.layout(key, schema, table);
if !change(&mut layout) {
return;
}
self.file.update(|document| match layout == ColumnLayout::default() {
true => prune(document, connection_id, schema, table),
true => prune(document, key, schema, table),
false => {
document
.connections
.entry(connection_id.to_string())
.entry(key.as_str().to_owned())
.or_default()
.entry(schema_key(schema).to_owned())
.or_default()
Expand All @@ -108,14 +122,13 @@ impl ColumnLayoutStore {
}
}

/// `None` is stored as the empty string so every JSON key is concrete.
fn schema_key(schema: Option<&str>) -> &str {
schema.unwrap_or("")
}

fn prune(document: &mut ColumnLayoutsDocument, connection_id: Uuid, schema: Option<&str>, table: &str) -> bool {
let connection_key = connection_id.to_string();
let Some(schemas) = document.connections.get_mut(&connection_key) else {
fn prune(document: &mut ColumnLayoutsDocument, key: &TableStateKey, schema: Option<&str>, table: &str) -> bool {
let connection_key = key.as_str();
let Some(schemas) = document.connections.get_mut(connection_key) else {
return false;
};
let mut removed = false;
Expand All @@ -126,7 +139,7 @@ fn prune(document: &mut ColumnLayoutsDocument, connection_id: Uuid, schema: Opti
}
}
if schemas.is_empty() {
document.connections.remove(&connection_key);
document.connections.remove(connection_key);
}
removed
}
Expand Down Expand Up @@ -160,7 +173,7 @@ mod tests {
let store = store_at(&path);

store.save(id, Some("public"), "users", &arranged());
store.flush().await;
store.flush().await.expect("saved");
let reopened = store_at(&path);

assert_eq!(reopened.layout(id, Some("public"), "users"), arranged());
Expand Down Expand Up @@ -203,7 +216,7 @@ mod tests {
store.save(id, Some("public"), "users", &arranged());

store.save(id, Some("public"), "users", &ColumnLayout::default());
store.flush().await;
store.flush().await.expect("saved");

assert!(
!read_text_file(&path).contains(&id.to_string()),
Expand Down
62 changes: 42 additions & 20 deletions linux/crates/app/src/persistence/filter_settings_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ use tablepro_core::FilterSet;
use tablepro_session::runtime::Tasks;
use uuid::Uuid;

use super::StateFile;
use super::filter_settings_document::FilterSettingsDocument;
use super::{StateFile, StateFileError, TableStateKey};

/// The filter each table was left with, remembered per connection,
/// schema and table.
#[derive(Clone)]
pub struct FilterSettingsStore {
file: Rc<StateFile<FilterSettingsDocument>>,
Expand All @@ -25,27 +23,29 @@ impl FilterSettingsStore {
self.file.path()
}

pub fn filters(&self, connection_id: Uuid, schema: Option<&str>, table: &str) -> FilterSet {
pub fn filters(&self, key: impl Into<TableStateKey>, schema: Option<&str>, table: &str) -> FilterSet {
let key = key.into();
self.file.read(|document| {
document
.connections
.get(&connection_id.to_string())
.get(key.as_str())
.and_then(|schemas| schemas.get(schema_key(schema)))
.and_then(|tables| tables.get(table))
.cloned()
.unwrap_or_default()
})
}

pub fn set_filters(&self, connection_id: Uuid, schema: Option<&str>, table: &str, set: FilterSet) {
pub fn set_filters(&self, key: impl Into<TableStateKey>, schema: Option<&str>, table: &str, set: FilterSet) {
let key = key.into();
self.file.update(|document| match set.is_empty() {
// Clearing a filter shrinks the file back rather than
// leaving an empty blob behind.
true => prune(document, connection_id, schema, table),
true => prune(document, &key, schema, table),
false => {
let slot = document
.connections
.entry(connection_id.to_string())
.entry(key.as_str().to_owned())
.or_default()
.entry(schema_key(schema).to_owned())
.or_default()
Expand All @@ -60,26 +60,48 @@ impl FilterSettingsStore {
});
}

/// Drop everything for a connection the user deleted.
pub fn forget_connection(&self, connection_id: Uuid) {
self.file
.update(|document| document.connections.remove(&connection_id.to_string()).is_some());
self.file.update(|document| {
let before = document.connections.len();
document
.connections
.retain(|key, _| !TableStateKey::belongs_to(key, connection_id));
before != document.connections.len()
});
}

pub fn failing(&self) -> tokio::sync::watch::Receiver<bool> {
self.file.failing()
}

pub fn revision(&self) -> u64 {
self.file.revision()
}

pub fn has_unsaved_changes(&self) -> bool {
self.file.has_unsaved_changes()
}

pub fn current_error(&self) -> Option<StateFileError> {
self.file.current_error()
}

pub fn retry(&self) -> bool {
self.file.retry()
}

pub fn flush(&self) -> impl Future<Output = ()> + Send + use<> {
pub fn flush(&self) -> impl Future<Output = Result<(), StateFileError>> + Send + use<> {
self.file.flush()
}
}

/// `None` is stored as the empty string so every JSON key is concrete.
fn schema_key(schema: Option<&str>) -> &str {
schema.unwrap_or("")
}

/// Remove the entry and any map it leaves empty.
fn prune(document: &mut FilterSettingsDocument, connection_id: Uuid, schema: Option<&str>, table: &str) -> bool {
let connection_key = connection_id.to_string();
let Some(schemas) = document.connections.get_mut(&connection_key) else {
fn prune(document: &mut FilterSettingsDocument, key: &TableStateKey, schema: Option<&str>, table: &str) -> bool {
let connection_key = key.as_str();
let Some(schemas) = document.connections.get_mut(connection_key) else {
return false;
};
let mut removed = false;
Expand All @@ -90,7 +112,7 @@ fn prune(document: &mut FilterSettingsDocument, connection_id: Uuid, schema: Opt
}
}
if schemas.is_empty() {
document.connections.remove(&connection_key);
document.connections.remove(connection_key);
}
removed
}
Expand Down Expand Up @@ -140,7 +162,7 @@ mod tests {
store.set_filters(id, Some("public"), "users", sample_set());

store.set_filters(id, Some("public"), "users", FilterSet::default());
store.flush().await;
store.flush().await.expect("saved");

assert!(store.filters(id, Some("public"), "users").is_empty());
let written = std::fs::read_to_string(&path).expect("the file");
Expand Down Expand Up @@ -173,7 +195,7 @@ mod tests {
let id = Uuid::new_v4();
let store = FilterSettingsStore::load(path.clone(), &paused_tasks());
store.set_filters(id, None, "users", sample_set());
store.flush().await;
store.flush().await.expect("saved");

let reopened = FilterSettingsStore::load(path, &paused_tasks());

Expand Down
20 changes: 20 additions & 0 deletions linux/crates/app/src/persistence/highlight_rules_document.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use std::collections::HashMap;

use serde::{Deserialize, Serialize};
use tablepro_storage::document::VersionedDocument;

use crate::services::grid::HighlightRule;

#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
pub struct HighlightRulesDocument {
#[serde(default)]
pub connections: HashMap<String, Schemas>,
}

pub type Schemas = HashMap<String, Tables>;
pub type Tables = HashMap<String, Vec<HighlightRule>>;

impl VersionedDocument for HighlightRulesDocument {
const KIND: &'static str = "highlight-rules";
const VERSION: u32 = 1;
}
Loading
Loading