Skip to content

feat(workspaces)!: remember current workspace and database across logins - #326

Merged
eddietejeda merged 2 commits into
mainfrom
feat/current-workspace-database
Oct 10, 2026
Merged

eddietejeda merged 2 commits into
mainfrom
feat/current-workspace-database

Conversation

@eddietejeda

Copy link
Copy Markdown
Contributor

What

The CLI no longer has a "default" workspace or database. It saves a current workspace and, per workspace, a current database on this machine. They are kept across auth logout / auth login, so a new session resumes where you left off.

Rules

  • Only hotdata workspaces use and hotdata databases use switch.
  • --workspace-id / -w and --database / -d apply to one command only.
  • databases create and databases fork no longer switch to the new database. Their output shows the use command and a -d example.

Other changes

  • databases use accepts a catalog alias or name, like -d.
  • workspaces list / databases list: column DEFAULT renamed to CURRENT.
  • Config: new current_workspace field. The cached workspaces list is no longer reordered. Old configs fall back to the first cached workspace.
  • Skill (Current workspace and database section), workflows and README updated; every create/fork example now includes databases use.

Breaking

Scripts that run databases create and then load or query without -d now get "a database is required". Add hotdata databases use <id> or pass -d <id>.

Testing

  • Unit tests for logout/login persistence, an inaccessible saved workspace, and legacy configs.
  • Validated end to end against prod with an isolated config: login → workspaces use → create (no switch) → use by catalog → query → fork (no switch) → -d / -w one-offs (no switch) → logout → login (workspace and database restored).

Replace the "default" workspace (first entry of the cached list) with an
explicit current workspace saved on this machine. Logout keeps it and the
per-workspace current database, so the next login resumes where you left off.

Only `workspaces use` and `databases use` switch. `--workspace-id`,
`-d/--database`, `databases create` and `databases fork` apply to one
command and no longer change the current selection.

- `databases use` accepts a catalog alias or name, like `-d`
- `workspaces list` / `databases list` column renamed DEFAULT -> CURRENT
- skill and README document the rules

BREAKING CHANGE: `databases create` and `databases fork` no longer make the
new database current. Run `hotdata databases use <id>` or pass `-d <id>`.
@eddietejeda
eddietejeda requested a review from a team as a code owner October 10, 2026 22:15
@eddietejeda
eddietejeda requested review from shefeek-jinnah and removed request for a team October 10, 2026 22:15
Comment thread src/config.rs Outdated
.iter()
.find(|w| w.public_id == c.public_id)
.cloned()
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Match against entry.current_workspace_id() here instead of entry.current_workspace (not blocking).

Consequence: an upgraded user loses the saved workspace choice on the first login. A legacy config has no current_workspace; the user's choice is workspaces[0], which the old save_default_workspace placed there. save_workspaces ignores workspaces[0] and picks the first fetched workspace instead. auth logout makes the problem worse, because clear_workspaces wipes the list before login can read it.

Fix: in clear_workspaces, copy workspaces.first() into current_workspace when current_workspace is None. In save_workspaces, look up the legacy fallback id from current_workspace_id() in the fetched list. With both changes, the PR's "survives logout/login" promise also covers existing configs.

Comment thread skills/hotdata/SKILL.md
- **Flags apply to one command only.** `--workspace-id` / `-w` and `--database` / `-d` (`--database-id` on `ingest`) target that command and leave the current workspace and database unchanged.
- `hotdata workspaces list` and `hotdata databases list` mark the current one with `*` in the `CURRENT` column. `hotdata databases unset` clears the current database.

If **`HOTDATA_WORKSPACE`** is set in the environment, the workspace is **locked** to that value: passing a different `--workspace-id` is an error, and **`hotdata workspaces use` fails** (“workspace is locked”).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Delete this paragraph (not blocking). Line 52 already has the same HOTDATA_WORKSPACE paragraph, so agents read the lock rule twice.

Retrieval workloads in Hotdata: **BM25 full-text**, **vector similarity**, and the **indexes** and **embedding providers** that power them.

**Prerequisites:** Authenticate, set a workspace, and set an active database (`hotdata databases use <id>`) — see the **`hotdata`** skill. Use fully qualified table names: `<catalog>.<schema>.<table>`.
**Prerequisites:** Authenticate, set a workspace, and set an current database (`hotdata databases use <id>`) — see the **`hotdata`** skill. Use fully qualified table names: `<catalog>.<schema>.<table>`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: Change "an current" to "a current" (not blocking). The same error is on line 51 ("with an current database set"), line 97, and skills/hotdata/SKILL.md ("With an current database set").

claude[bot]
claude Bot previously approved these changes Oct 10, 2026
@codecov

codecov Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.50704% with 22 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/commands/workspace.rs 0.00% 9 Missing ⚠️
src/commands/databases.rs 0.00% 7 Missing ⚠️
src/commands/auth.rs 58.33% 5 Missing ⚠️
src/main.rs 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

…nd logout

Address review: configs written before current_workspace store the choice
in workspaces[0]. save_workspaces now matches it via current_workspace_id,
and clear_workspaces copies it into current_workspace before wiping the
list. Also drop a duplicated HOTDATA_WORKSPACE paragraph and fix
'an current' typos in the skills.
@eddietejeda
eddietejeda merged commit c59167a into main Oct 10, 2026
15 checks passed
@eddietejeda
eddietejeda deleted the feat/current-workspace-database branch October 10, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant