Workspace resolution lives in workspace.py, a small module beside config.py.
The CLI client helpers (_client.py) resolve the database path before opening
a connection: an explicit --db wins, then --workspace, then auth.test when
a Slack client is available, then offline resolution from the last-used
pointer.
Token+base-URL hash to workspace name, avoiding repeated auth.test calls
auth.test payload fields used
Field
Use
url
Subdomain extraction (acme from https://acme.slack.com/)
team_id
Fallback workspace name when no subdomain is available
Resolution Rules
--db <path>: use the path as given; no workspace logic.
--workspace <name>: use <name>/threads.db and remember it as last used.
Credentials configured: look up the workspace name in
workspace_names.json (keyed by token and API base URL hash); on a hit,
claim that workspace's database immediately.
Cache miss: one auth.test call, store the resulting name, then claim it.
Otherwise (no credentials, or auth.test unreachable for serve): offline
resolution, last-used workspace, then the only existing workspace
database, then the legacy single threads.db.
Multiple workspace databases with no pointer: exit with an error listing
the known workspace names.
slackx show --no-fetch --channel C1 --ts T
-> _open_db(common) without client
-> last_workspace() -> "acme" -> cache/acme/threads.db
-> read thread state and messages; no network
Technical Decisions
Decision
Choice
Rationale
Workspace identity
auth.test subdomain, team id fallback
Same resolution for every command; permalink subdomains only cover URL-based commands
auth.test caching
Once per credential set on disk (hashed key)
A token belongs to exactly one workspace, so later calls resolve without network