Skip to content

Commit b6c2c8a

Browse files
authored
Add matching conversations as InboxUIItem to archive job (keybase#26397)
* Add matching conversations as InboxUIItem to archive job * fix false progress reporting
1 parent ee398d8 commit b6c2c8a

6 files changed

Lines changed: 48 additions & 4 deletions

File tree

‎go/chat/archive.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ func (c *ChatArchiver) notifyProgress(ctx context.Context, jobID chat1.ArchiveJo
480480
c.Lock()
481481
defer c.Unlock()
482482
c.messagesComplete += int64(pagination.Num)
483-
if c.messagesComplete > c.messagesTotal || pagination.Last {
483+
if c.messagesComplete > c.messagesTotal {
484484
// total messages is capped to the convs expunge, don't over report.
485485
c.messagesComplete = c.messagesTotal
486486
}
@@ -686,6 +686,7 @@ func (c *ChatArchiver) ArchiveChat(ctx context.Context, arg chat1.ArchiveChatJob
686686
// Presume to resume
687687
jobInfo.Status = chat1.ArchiveChatJobStatus_RUNNING
688688
jobInfo.Err = ""
689+
jobInfo.MatchingConvs = utils.PresentConversationLocals(ctx, c.G(), c.uid, convs, utils.PresentParticipantsModeSkip)
689690

690691
// Setup to run each conv in parallel
691692
eg, ctx := errgroup.WithContext(ctx)

‎go/client/cmd_chat_archive_list.go‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package client
22

33
import (
44
"fmt"
5+
"slices"
6+
"strings"
57

68
"github.com/keybase/cli"
79
"github.com/keybase/client/go/chatrender"
@@ -50,12 +52,32 @@ func (c *CmdChatArchiveList) Run() error {
5052
if job.MessagesTotal > 0 {
5153
percent = int((100 * job.MessagesComplete) / job.MessagesTotal)
5254
}
55+
matchingConvs := ""
56+
if job.Request.Query.Name == nil && job.Request.Query.TopicName == nil {
57+
matchingConvs = "<all chat>"
58+
} else {
59+
names := make([]string, 0, len(job.MatchingConvs))
60+
for _, conv := range job.MatchingConvs {
61+
name := conv.Name
62+
if len(name) == 0 {
63+
continue
64+
}
65+
if conv.Channel != "" {
66+
name += fmt.Sprintf("#%s", conv.Channel)
67+
}
68+
names = append(names, name)
69+
}
70+
slices.Sort(names)
71+
matchingConvs += strings.Join(names, "\n")
72+
}
5373
ui.Printf(`Job ID: %s
74+
Matching Conversations:
75+
%s
5476
Output Path: %s
5577
Started At: %s (%s)
5678
Status: %s
5779
Progress: %d%% (%d of %d messages archived)
58-
`, job.Request.JobID, job.Request.OutputPath,
80+
`, job.Request.JobID, matchingConvs, job.Request.OutputPath,
5981
chatrender.FmtTime(gregor1.FromTime(job.StartedAt), chatrender.RenderOptions{UseDateTime: true}),
6082
chatrender.FmtTime(gregor1.FromTime(job.StartedAt), chatrender.RenderOptions{}),
6183
job.Status.String(), percent, job.MessagesComplete, job.MessagesTotal)

‎go/protocol/chat1/local.go‎

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎protocol/avdl/chat1/local.avdl‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,8 @@ protocol local {
14911491
}
14921492
record ArchiveChatJob {
14931493
ArchiveChatJobRequest request;
1494+
// All conversations that matched the request.
1495+
array<InboxUIItem> matchingConvs;
14941496
gregor1.Time startedAt;
14951497
ArchiveChatJobStatus status;
14961498
string err; // Set iff status == ERROR

‎protocol/json/chat1/local.json‎

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎shared/constants/types/rpc-chat-gen.tsx‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)