@@ -14,6 +14,7 @@ type PendingItem struct {
1414 Branch string // e.g. "wl/alice/w-001"
1515 BranchURL string // web URL for the fork branch
1616 PRURL string // web URL for the upstream PR
17+ ForkOwner string // owner of the fork that hosts Branch
1718 CompletedBy string // from fork branch completions table
1819 Evidence string // from fork branch completions table
1920}
@@ -91,7 +92,7 @@ func (c *Client) Browse(filter commons.BrowseFilter) (*BrowseResult, error) {
9192 if best .Branch == "" {
9293 continue
9394 }
94- item , err := commons . QueryWantedDetailAsOf ( c . db , id , best . Branch )
95+ item , _ , _ , err := c . loadPendingDetail ( id , best )
9596 if err != nil {
9697 continue
9798 }
@@ -203,6 +204,14 @@ func (c *Client) detailPR(wantedID string) (*DetailResult, error) {
203204 }
204205 effective := state .Effective ()
205206 if effective == nil {
207+ upstreamPRs := c .fetchUpstreamPRs (wantedID )
208+ if len (upstreamPRs ) > 0 {
209+ result , err := c .detailFromPending (wantedID , upstreamPRs )
210+ if err == nil {
211+ return result , nil
212+ }
213+ return nil , err
214+ }
206215 // Fall back to main query if resolve found nothing.
207216 return c .detailWildWest (wantedID )
208217 }
@@ -229,6 +238,39 @@ func (c *Client) detailPR(wantedID string) (*DetailResult, error) {
229238 return result , nil
230239}
231240
241+ func (c * Client ) loadPendingDetail (wantedID string , pending PendingItem ) (* commons.WantedItem , * commons.CompletionRecord , * commons.Stamp , error ) {
242+ if c .LoadPendingDetail != nil {
243+ item , completion , stamp , err := c .LoadPendingDetail (wantedID , pending )
244+ if err == nil {
245+ return item , completion , stamp , nil
246+ }
247+ }
248+ return commons .QueryFullDetailAsOf (c .db , wantedID , pending .Branch )
249+ }
250+
251+ func (c * Client ) detailFromPending (wantedID string , pending []PendingItem ) (* DetailResult , error ) {
252+ best := bestPendingState (pending )
253+ if best .Branch == "" {
254+ return c .detailWildWest (wantedID )
255+ }
256+
257+ item , completion , stamp , err := c .loadPendingDetail (wantedID , best )
258+ if err != nil {
259+ return nil , err
260+ }
261+
262+ return & DetailResult {
263+ Item : item ,
264+ Completion : completion ,
265+ Stamp : stamp ,
266+ Branch : best .Branch ,
267+ BranchURL : best .BranchURL ,
268+ PRURL : best .PRURL ,
269+ Delta : commons .ComputeDelta ("" , item .Status , true ),
270+ UpstreamPRs : pending ,
271+ }, nil
272+ }
273+
232274func (c * Client ) detailWildWest (wantedID string ) (* DetailResult , error ) {
233275 item , completion , stamp , err := commons .QueryFullDetail (c .db , wantedID )
234276 if err != nil {
0 commit comments