Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,4 @@ go/keybase_openbsd
.claude
.*-mcp
CLAUDE.md
.tsOuts
22 changes: 17 additions & 5 deletions go/chat/flipmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ func (m *FlipManager) formatError(ctx context.Context, rawErr error) chat1.UICoi
}

func (m *FlipManager) handleSummaryUpdate(ctx context.Context, gameID chat1.FlipGameID,
update *flip.GameSummary, convID chat1.ConversationID, force bool,
update *flip.GameSummary, statusConvID chat1.ConversationID, resultConvID chat1.ConversationID, force bool,
) (status chat1.UICoinFlipStatus) {
defer m.queueDirtyGameID(ctx, gameID, force)
if update.Err != nil {
Expand All @@ -622,6 +622,7 @@ func (m *FlipManager) handleSummaryUpdate(ctx context.Context, gameID chat1.Flip
formatted := m.formatError(ctx, update.Err)
status = chat1.UICoinFlipStatus{
GameID: gameID.FlipGameIDStr(),
ConvID: statusConvID.ConvIDStr(),
Phase: chat1.UICoinFlipPhase_ERROR,
ProgressText: fmt.Sprintf("Something went wrong: %s", update.Err),
Participants: parts,
Expand All @@ -632,9 +633,10 @@ func (m *FlipManager) handleSummaryUpdate(ctx context.Context, gameID chat1.Flip
}
status = chat1.UICoinFlipStatus{
GameID: gameID.FlipGameIDStr(),
ConvID: statusConvID.ConvIDStr(),
Phase: chat1.UICoinFlipPhase_COMPLETE,
}
m.addResult(ctx, &status, update.Result, convID)
m.addResult(ctx, &status, update.Result, resultConvID)
for _, p := range update.Players {
m.addParticipant(ctx, &status, flip.CommitmentUpdate{
User: p.Device,
Expand Down Expand Up @@ -669,6 +671,14 @@ func (m *FlipManager) handleUpdate(ctx context.Context, update flip.GameStateUpd
GameID: gameID.FlipGameIDStr(),
}
}
if len(status.ConvID) == 0 {
hmi, hmiErr := m.getHostMessageInfo(ctx, update.Metadata.ConversationID)
if hmiErr != nil {
m.Debug(ctx, "handleUpdate: failed to get host message info: %s", hmiErr)
} else {
status.ConvID = hmi.ConvID.ConvIDStr()
}
}

switch {
case update.Err != nil:
Expand Down Expand Up @@ -1371,10 +1381,10 @@ func (m *FlipManager) loadGame(ctx context.Context, job loadGameJob) (err error)
}
}
m.Debug(ctx, "loadGame: game had no action after pausing, sending error")
job.resCh <- m.handleSummaryUpdate(ctx, job.gameID, summary, flipConvID, true)
job.resCh <- m.handleSummaryUpdate(ctx, job.gameID, summary, hmi.ConvID, flipConvID, true)
}(globals.BackgroundChatCtx(ctx, m.G()), summary)
} else {
job.resCh <- m.handleSummaryUpdate(ctx, job.gameID, summary, flipConvID, true)
job.resCh <- m.handleSummaryUpdate(ctx, job.gameID, summary, hmi.ConvID, flipConvID, true)
}
return nil
}
Expand Down Expand Up @@ -1406,7 +1416,9 @@ func (m *FlipManager) LoadFlip(ctx context.Context, uid gregor1.UID, hostConvID
default:
m.queueDirtyGameID(ctx, gameID, true)
res = make(chan chat1.UICoinFlipStatus, 1)
res <- stored.(chat1.UICoinFlipStatus)
status := stored.(chat1.UICoinFlipStatus)
status.ConvID = hostConvID.ConvIDStr()
res <- status
err = make(chan error, 1)
return res, err
}
Expand Down
1 change: 1 addition & 0 deletions go/chat/flipmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ func TestFlipManagerLoadFlip(t *testing.T) {
case updates := <-ui0.CoinFlipUpdates:
require.Equal(t, 1, len(updates))
require.Equal(t, chat1.UICoinFlipPhase_COMPLETE, updates[0].Phase)
require.Equal(t, conv.Id.ConvIDStr(), updates[0].ConvID)
require.Equal(t, res, updates[0].ResultText)
case <-time.After(timeout):
require.Fail(t, "no updates")
Expand Down
2 changes: 2 additions & 0 deletions go/protocol/chat1/chat_ui.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions protocol/avdl/chat1/chat_ui.avdl
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ protocol chatUi {
}
record UICoinFlipStatus {
FlipGameIDStr gameID;
ConvIDStr convID;
UICoinFlipPhase phase;
string progressText;
string resultText;
Expand Down
4 changes: 4 additions & 0 deletions protocol/json/chat1/chat_ui.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion shared/constants/types/rpc-chat-gen.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.