2 Commits

Author SHA1 Message Date
Ryan Hamamura
6d4f3eb821 fix: add explicit --login and --repo flags to tea commands
All checks were successful
Deploy c4 / deploy (push) Successful in 49s
2026-02-20 17:05:46 -10:00
Ryan Hamamura
e68e4b48f5 fix: resolve nil pubsub preventing live game updates
All checks were successful
Deploy c4 / deploy (push) Successful in 45s
v.PubSub() was captured at startup before v.Start() initialized NATS,
so both stores held nil and notify() silently no-oped. Replace the
PubSub interface with a callback that evaluates v.PubSub() lazily at
call time.
2026-02-20 12:37:28 -10:00
4 changed files with 63 additions and 22 deletions

View File

@@ -0,0 +1,45 @@
Create a new Gitea release for this project using semantic versioning.
## Current state
Fetch tags and find the latest version:
```
!git fetch --tags && git tag --sort=-v:refname | head -5
```
Commits since the last release (if no tags exist, this shows all commits):
```
!git log $(git describe --tags --abbrev=0 2>/dev/null && echo "$(git describe --tags --abbrev=0)..HEAD" || echo "") --oneline
```
## Instructions
1. **Determine current version** from the tag output above. If no `vX.Y.Z` tags exist, treat current version as `v0.0.0`.
2. **Analyze commits** using conventional commit prefixes to pick the semver bump:
- Breaking changes (`!` after type, or `BREAKING CHANGE` in body) → **major** bump
- `feat:`**minor** bump
- `fix:`, `chore:`, `deps:`, `revert:`, and everything else → **patch** bump
- Use the **highest** applicable bump level across all commits
3. **Generate release notes** — group commits into sections:
- **Features** — `feat:` commits
- **Fixes** — `fix:` commits
- **Other** — everything else (`chore:`, `deps:`, `revert:`, etc.)
- Omit empty sections. Each commit is a bullet point with its short description (strip the prefix).
4. **Present for approval** — show the user:
- Current version → proposed new version
- The full release notes
- The exact `tea` command that will run
- Ask the user to confirm before proceeding
5. **Create the release** — on user approval, run:
```
tea releases create --login gitea --repo ryan/c4 --tag <version> --target main -t "<version>" -n "<release notes>"
```
Do NOT create a local git tag — Gitea creates it server-side.
6. **Verify** — run `tea releases ls --login gitea --repo ryan/c4` to confirm the release was created.

View File

@@ -6,10 +6,6 @@ import (
"sync"
)
type PubSub interface {
Publish(subject string, data []byte) error
}
type PlayerSession struct {
Player *Player
}
@@ -25,8 +21,8 @@ type Persister interface {
type GameStore struct {
games map[string]*GameInstance
gamesMu sync.RWMutex
persister Persister
pubsub PubSub
persister Persister
notifyFunc func(gameID string)
}
func NewGameStore() *GameStore {
@@ -39,14 +35,14 @@ func (gs *GameStore) SetPersister(p Persister) {
gs.persister = p
}
func (gs *GameStore) SetPubSub(ps PubSub) {
gs.pubsub = ps
func (gs *GameStore) SetNotifyFunc(f func(gameID string)) {
gs.notifyFunc = f
}
func (gs *GameStore) makeNotify(gameID string) func() {
return func() {
if gs.pubsub != nil {
gs.pubsub.Publish("game."+gameID, nil)
if gs.notifyFunc != nil {
gs.notifyFunc(gameID)
}
}
}

View File

@@ -81,8 +81,12 @@ func main() {
subFS, _ := fs.Sub(assets, "assets")
v.StaticFS("/assets/", subFS)
store.SetPubSub(v.PubSub())
snakeStore.SetPubSub(v.PubSub())
store.SetNotifyFunc(func(gameID string) {
v.PubSub().Publish("game."+gameID, nil)
})
snakeStore.SetNotifyFunc(func(gameID string) {
v.PubSub().Publish("snake."+gameID, nil)
})
// Home page - tabbed lobby
v.Page("/", func(c *via.Context) {

View File

@@ -6,10 +6,6 @@ import (
"sync"
)
type PubSub interface {
Publish(subject string, data []byte) error
}
type Persister interface {
SaveSnakeGame(sg *SnakeGame) error
LoadSnakeGame(id string) (*SnakeGame, error)
@@ -21,8 +17,8 @@ type Persister interface {
type SnakeStore struct {
games map[string]*SnakeGameInstance
gamesMu sync.RWMutex
persister Persister
pubsub PubSub
persister Persister
notifyFunc func(gameID string)
}
func NewSnakeStore() *SnakeStore {
@@ -35,14 +31,14 @@ func (ss *SnakeStore) SetPersister(p Persister) {
ss.persister = p
}
func (ss *SnakeStore) SetPubSub(ps PubSub) {
ss.pubsub = ps
func (ss *SnakeStore) SetNotifyFunc(f func(gameID string)) {
ss.notifyFunc = f
}
func (ss *SnakeStore) makeNotify(gameID string) func() {
return func() {
if ss.pubsub != nil {
ss.pubsub.Publish("snake."+gameID, nil)
if ss.notifyFunc != nil {
ss.notifyFunc(gameID)
}
}
}