Skip to content

Restore the last-visited channel on startup#72

Merged
gammons merged 2 commits into
gammons:mainfrom
Frodotus:feat/restore-last-channel
Jun 11, 2026
Merged

Restore the last-visited channel on startup#72
gammons merged 2 commits into
gammons:mainfrom
Frodotus:feat/restore-last-channel

Conversation

@Frodotus

Copy link
Copy Markdown
Contributor

What

On startup, the active workspace now opens the most-recently-visited channel instead of always snapping to the sidebar's first entry — so a restart lands you back where you left off.

How

The channel_visits table already persists a per-channel last_visited timestamp (and is loaded into WorkspaceContext.LastVisitedByChannel at connect). This wires that existing data into the startup path:

  • mostRecentlyVisitedChannel(visits) picks the channel with the latest timestamp; it's passed on WorkspaceReadyMsg.LastChannelID.
  • reduceWorkspaceReady (the InitialActive branch) opens LastChannelID when it's set and still present in the sidebar, otherwise falls back to Channels[0].

Only the startup path changed; the existing mid-session workspace-switch restore (lastChannelByTeam) is untouched.

Edge cases

  • First run / no recorded visitLastChannelID is empty → opens Channels[0] (unchanged behavior).
  • Last channel archived/left → lookup finds no match → falls back to Channels[0].

Testing

go test ./... passes; added TestWorkspaceReadyRestoresLastChannel covering restore, the empty-visit fallback, and the stale-channel fallback.

@Frodotus Frodotus marked this pull request as draft June 10, 2026 14:15
@Frodotus Frodotus force-pushed the feat/restore-last-channel branch from ab192fd to 5586a0e Compare June 10, 2026 14:17
@Frodotus Frodotus marked this pull request as ready for review June 10, 2026 14:18
@gammons

gammons commented Jun 11, 2026

Copy link
Copy Markdown
Owner

One trivial fix: cmd/slk/main.go is missing a blank line between the new mostRecentlyVisitedChannel function's closing brace and the // rtmEventHandler doc comment, which is a gofmt violation that CI/go fmt will flag — otherwise the change looks correct and well-tested.

@Frodotus

Copy link
Copy Markdown
Contributor Author

Fixed in 03980a4 — added the blank line between mostRecentlyVisitedChannel and the rtmEventHandler doc comment. gofmt -l is clean on that change now.

@gammons

gammons commented Jun 11, 2026

Copy link
Copy Markdown
Owner

🍔

@gammons gammons merged commit 70cd754 into gammons:main Jun 11, 2026
3 checks passed
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.

2 participants