Skip to content

Commit e6d14d3

Browse files
StefanSteinerStefan Steiner
andauthored
fix: chart time-axis rendering, auto-detection, and MCP ergonomic fixes (#39)
* fix(mcp): disable ANSI escape codes on stderr tracing layer MCP servers communicate over stdio; their stderr goes to a client log pane (e.g. Claude Code output panel) that doesn't render ANSI codes. On Windows this produced raw escape sequences like [2m...[0m. Force plain text on both the daemon and MCP stderr layers. Also adds a pre-1.0 stability note to the README. * fix(mcp): auto-create parent dirs for chart/export output paths validate_output_path previously rejected paths whose parent directory didn't exist. Now it creates the directory tree (create_dir_all) before canonicalizing, so users don't need to pre-create output directories. Also improves chart tool description to guide LLMs on: - Long-format data requirement (one numeric y, use series for grouping) - x_as_category=true requirement for DATE/TIMESTAMP x-axes - UNION ALL reshaping for wide-format data * fix(chart): auto-detect categorical x columns for line/scatter charts Line and scatter charts now peek at the first row's x value — if it's not numeric (DATE, TIMESTAMP, TEXT, etc.), categorical mode activates automatically. This eliminates the need to manually set x_as_category=true for date-based time series. The explicit x_as_category parameter still works as an override. * fix(chart): auto-shorten TIMESTAMPTZ labels and thin dense tick marks Categorical axis labels now go through a shortening pass: 1. Strip shared timezone offset (+00:00) when all labels end with it 2. Auto-thin: blank intermediate labels when they'd overlap based on estimated character width vs chart pixel width This prevents label collision on charts with 12+ TIMESTAMPTZ ticks at 800px width. First and last labels are always preserved. * feat(chart): proportional time axis for DATE/TIMESTAMP/TIMESTAMPTZ + fix tick thinning Line and scatter charts now auto-detect DATE / TIMESTAMP / TIMESTAMPTZ x columns and render with a proportional time axis: real wall-clock gaps between data points are reflected on the chart's x-axis instead of being flattened to even spacing. Tick labels are formatted via chrono to match the input kind (%Y-%m-%d, %Y-%m-%d %H:%M:%S, or %Y-%m-%d %H:%M:%S%:z), with the originating offset captured from the first row preserved for TIMESTAMPTZ. Pass x_as_category: true to opt out and force the previous categorical layout; TEXT x columns continue to render categorically. Also fixes a tick-label thinning regression in the categorical path. The old shorten_labels blanked individual labels at non-step indices, but plotters picks its own tick positions on the float axis and rounds them to integer indices, so almost none of the chosen ticks landed on a kept index - a 90-point hourly TIMESTAMP series at any chart width rendered with only ONE visible x-axis label. The chart layer now computes a target tick count from chart width and label size, then passes it to plotters via .x_labels(N); every drawn tick carries a real label. Refactors: - shorten_labels split into strip_shared_tz_suffix (cosmetic +HH:MM compaction) and auto_tick_count (no-overlap budget for plotters). - group_series x_as_category: bool -> x_mode: XMode enum (Numeric / Categorical / Temporal(TemporalKind)). - New parse_temporal, format_temporal_tick, detect_line_x_mode, tick_count_for_label_width helpers. Tests: 16 new unit tests for the helpers (parse, format, detect, tick math, NaN safety, offset capture); 1 new integration test (line_chart_long_timestamp_series_renders_multiple_visible_labels) asserts >=3 visible date labels in the rendered SVG, locking in the regression fix. Total: 26 unit, 37 integration, all green; clippy --all-targets -D warnings clean. Docs: chart tool description in server.rs and LLM-facing readme.rs updated to document the new auto-detect behavior; CHANGELOG.md [Unreleased] gains two ### Fixed entries. * chore: re-enable release-please to release v0.2.0 * chore: fix formatting --------- Co-authored-by: Stefan Steiner <ssteiner@salesforce.com>
1 parent 7b4a1a9 commit e6d14d3

10 files changed

Lines changed: 808 additions & 105 deletions

File tree

.github/workflows/release-please.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ permissions:
2828

2929
jobs:
3030
release-please:
31-
# Temporarily disabled until post-daemon/two-db-model work is complete.
32-
# Re-enable by removing the `false &&` prefix below.
33-
if: false && github.repository == 'tableau/hyper-api-rust'
31+
if: github.repository == 'tableau/hyper-api-rust'
3432
runs-on: ubuntu-latest
3533
steps:
3634
- uses: googleapis/release-please-action@v5

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ A **pure-Rust** implementation of the Hyper database API, using the PostgreSQL
1010
wire protocol with Hyper-specific extensions. Create, read, and manipulate Hyper
1111
database files (`.hyper`) without any C library dependencies.
1212

13-
> **Project Status — 0.1.x, AI-Engineered**
13+
> **Project Status — 0.2.x, AI-Engineered**
1414
>
1515
> This crate was vibe-engineered with heavy use of AI coding assistants. The
16-
> **0.1.x** line may still undergo large breaking changes; the public API
17-
> won't settle until the 0.2.0 release.
16+
> **0.2.x** line may still undergo large breaking changes; the public API
17+
> won't settle until the 1.0.0 release.
1818
>
1919
> Contributors and reviewers should, at a minimum, run an **AI code reviewer**
2020
> over any changes, following the conventions, layering rules, and patterns

hyperdb-mcp/CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
143143

144144
### Fixed
145145

146+
- **Chart x-axis tick label thinning.** Long categorical line/scatter
147+
charts (e.g. a 90-point hourly TIMESTAMP series) used to render with
148+
only ONE visible x-axis label. The old logic blanked individual
149+
labels at non-step indices, but `plotters` picks its own tick
150+
*positions* on the float axis and rounds them to integer indices —
151+
so almost none of the chosen ticks landed on a kept index, and the
152+
formatter returned empty strings for the rest. The chart layer now
153+
computes a target tick count from chart width and label sizes and
154+
passes that count to `plotters` via `.x_labels(N)`; every drawn
155+
tick carries its real label. Same `+00:00` suffix stripping for
156+
shared TIMESTAMPTZ offsets is preserved (now isolated in
157+
`strip_shared_tz_suffix`).
158+
- **Line / scatter charts over `DATE`, `TIMESTAMP`, and `TIMESTAMPTZ`
159+
columns now use a proportional time axis** instead of the previous
160+
categorical-with-evenly-spaced-ticks behavior. Real-world time gaps
161+
between data points are now reflected in the chart's x-axis: a
162+
series at `2026-05-01 08:00`, `2026-05-01 12:30`, `2026-05-02 06:15`
163+
shows the 4.5-hour and 17.75-hour gaps proportionally instead of
164+
flattening every interval to the same width. Tick labels are
165+
formatted via `chrono` in a form that matches the input kind:
166+
`%Y-%m-%d` for DATE, `%Y-%m-%d %H:%M:%S` for TIMESTAMP, and
167+
`%Y-%m-%d %H:%M:%S%:z` for TIMESTAMPTZ (the offset captured from the
168+
first row, so a uniformly-`+05:30` series reports IST throughout).
169+
Set `x_as_category: true` to opt out and force the previous
170+
categorical layout (e.g. for charts where evenly-spaced bins are
171+
more readable than proportional gaps). TEXT x columns continue to
172+
render categorically as before. Bar charts are unaffected — they
173+
remain categorical regardless of x type, which matches reader
174+
expectations for grouped data.
146175
- **Watcher recovery after hyperd restart.** The watcher's connection
147176
pool now auto-rebuilds when a per-file ingest hits a connection-lost
148177
error (typically after the daemon restarts hyperd). Each ingest gets

hyperdb-mcp/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# hyperdb-mcp
22

3+
> **Note:** This crate was vibe-engineered with heavy use of AI coding assistants. The 0.1.x line may still undergo large breaking changes; the public API won't settle until the 1.0.0 release.
4+
35
An MCP (Model Context Protocol) server that turns the Hyper columnar database into an instant SQL analytics engine. Data flows in from other MCP plugins or files, lands in Hyper automatically, and becomes queryable with SQL — no setup, no schema files, no database management.
46

57
Built on the pure-Rust [`hyperdb-api`](../hyperdb-api/) crate for maximum performance: 22M+ rows/sec inserts, 18M+ rows/sec queries, constant memory for billion-row results.

hyperdb-mcp/src/attach.rs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,14 @@ pub fn validate_output_path(path: &str, kind: &str) -> Result<PathBuf, McpError>
727727
format!("{kind} path '{path}' has no file-name component"),
728728
)
729729
})?;
730+
if !parent.exists() {
731+
std::fs::create_dir_all(parent).map_err(|e| {
732+
McpError::new(
733+
ErrorCode::InternalError,
734+
format!("Failed to create parent directory for {kind} path '{path}': {e}"),
735+
)
736+
})?;
737+
}
730738
let canonical_parent = std::fs::canonicalize(parent).map_err(|e| {
731739
McpError::new(
732740
ErrorCode::FileNotFound,
@@ -924,14 +932,19 @@ mod tests {
924932
}
925933

926934
#[test]
927-
fn validate_output_path_rejects_missing_parent() {
928-
// Build a platform-portable absolute path with a missing parent.
929-
// Hardcoded "/definitely/..." paths are not absolute on Windows.
930-
let missing_parent = std::env::temp_dir()
931-
.join("hyper_mcp_validate_output_missing_parent_99999")
932-
.join("out.csv");
933-
let err = validate_output_path(missing_parent.to_str().unwrap(), "export").unwrap_err();
934-
assert_eq!(err.code, ErrorCode::FileNotFound);
935+
fn validate_output_path_creates_missing_parent() {
936+
let parent = std::env::temp_dir().join("hyper_mcp_validate_output_missing_parent_99999");
937+
// Clean up from any prior run.
938+
let _ = std::fs::remove_dir_all(&parent);
939+
assert!(!parent.exists());
940+
941+
let target = parent.join("out.csv");
942+
let canonical =
943+
validate_output_path(target.to_str().unwrap(), "export").expect("should create parent");
944+
assert!(canonical.is_absolute());
945+
assert!(parent.exists(), "parent directory should have been created");
946+
// Clean up.
947+
let _ = std::fs::remove_dir_all(&parent);
935948
}
936949

937950
#[test]

0 commit comments

Comments
 (0)