@@ -3,6 +3,7 @@ package main
33import (
44 "fmt"
55 "io"
6+ "strings"
67
78 "github.com/julianknutsen/wasteland/internal/commons"
89 "github.com/julianknutsen/wasteland/internal/style"
@@ -14,9 +15,10 @@ func newMeCmd(stdout, stderr io.Writer) *cobra.Command {
1415 Use : "me" ,
1516 Short : "Show your personal dashboard" ,
1617 Long : `Show your personal dashboard: claimed items, items awaiting your review,
17- and recent completions.
18+ in-flight branch work (PR mode), and recent completions.
1819
1920Syncs with upstream first, then queries your local clone.
21+ Also scans wl/<handle>/* branches for PR-mode items not yet on main.
2022
2123Examples:
2224 wl me` ,
@@ -45,7 +47,7 @@ func runMe(cmd *cobra.Command, stdout, _ io.Writer) error {
4547 handle := cfg .RigHandle
4648 printed := false
4749
48- // My claimed items
50+ // My claimed items (on main)
4951 claimedCSV , err := commons .DoltSQLQuery (cfg .LocalDir , fmt .Sprintf (
5052 "SELECT id, title, status, priority, effort_level FROM wanted WHERE claimed_by = '%s' AND status IN ('claimed','in_review') ORDER BY priority ASC" ,
5153 commons .EscapeSQL (handle ),
@@ -66,6 +68,17 @@ func runMe(cmd *cobra.Command, stdout, _ io.Writer) error {
6668 printed = true
6769 }
6870
71+ // In-flight branches (PR-mode items not yet on main)
72+ mainIDs := mainClaimedIDs (claimedRows )
73+ branchItems := listBranchItems (cfg .LocalDir , handle , mainIDs )
74+ if len (branchItems ) > 0 {
75+ fmt .Fprintf (stdout , "\n %s\n " , style .Bold .Render ("In-flight branches (not yet on main):" ))
76+ for _ , bi := range branchItems {
77+ fmt .Fprintf (stdout , " %-12s %-30s %s\n " , bi .id , bi .title , style .Dim .Render (bi .branch ))
78+ }
79+ printed = true
80+ }
81+
6982 // Awaiting my review
7083 reviewCSV , err := commons .DoltSQLQuery (cfg .LocalDir , fmt .Sprintf (
7184 "SELECT id, title, claimed_by FROM wanted WHERE posted_by = '%s' AND status = 'in_review' ORDER BY priority ASC" ,
@@ -112,3 +125,69 @@ func runMe(cmd *cobra.Command, stdout, _ io.Writer) error {
112125
113126 return nil
114127}
128+
129+ // branchItem represents a wanted item found on a wl/* branch.
130+ type branchItem struct {
131+ id string
132+ title string
133+ branch string
134+ }
135+
136+ // mainClaimedIDs extracts IDs already shown in the "My claimed items" section
137+ // so we can deduplicate against branch results.
138+ func mainClaimedIDs (claimedRows [][]string ) map [string ]bool {
139+ ids := make (map [string ]bool )
140+ for i , row := range claimedRows {
141+ if i == 0 || len (row ) < 1 { // skip header
142+ continue
143+ }
144+ ids [row [0 ]] = true
145+ }
146+ return ids
147+ }
148+
149+ // listBranchItems scans wl/<handle>/* branches and returns items that differ
150+ // from main — i.e., PR-mode work not yet merged.
151+ func listBranchItems (dbDir , handle string , skipIDs map [string ]bool ) []branchItem {
152+ prefix := fmt .Sprintf ("wl/%s/" , handle )
153+ branches , err := commons .ListBranches (dbDir , prefix )
154+ if err != nil || len (branches ) == 0 {
155+ return nil
156+ }
157+
158+ var items []branchItem
159+ for _ , branch := range branches {
160+ wantedID := extractBranchWantedID (branch )
161+ if wantedID == "" || skipIDs [wantedID ] {
162+ continue
163+ }
164+ // Query the wanted table AS OF this branch to get the item state.
165+ query := fmt .Sprintf (
166+ "SELECT id, title, status FROM wanted AS OF '%s' WHERE id = '%s' LIMIT 1" ,
167+ commons .EscapeSQL (branch ), commons .EscapeSQL (wantedID ),
168+ )
169+ csv , err := commons .DoltSQLQuery (dbDir , query )
170+ if err != nil {
171+ continue
172+ }
173+ rows := wlParseCSV (csv )
174+ if len (rows ) < 2 || len (rows [1 ]) < 3 {
175+ continue
176+ }
177+ items = append (items , branchItem {
178+ id : rows [1 ][0 ],
179+ title : rows [1 ][1 ],
180+ branch : branch ,
181+ })
182+ }
183+ return items
184+ }
185+
186+ // extractBranchWantedID extracts the wanted ID from wl/<rig>/<id>.
187+ func extractBranchWantedID (branch string ) string {
188+ parts := strings .SplitN (branch , "/" , 3 )
189+ if len (parts ) < 3 {
190+ return ""
191+ }
192+ return parts [2 ]
193+ }
0 commit comments