AT Protocol Terminal Interface Explorer
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

show pds

+50 -16
+29 -4
at/client.go
··· 31 31 } 32 32 } 33 33 34 - func (c *Client) withIdentifier(ctx context.Context, raw string) (*atclient.APIClient, error) { 34 + func (c *Client) GetIdentity(ctx context.Context, raw string) (*identity.Identity, error) { 35 35 id, err := syntax.ParseAtIdentifier(raw) 36 36 if err != nil { 37 - return nil, fmt.Errorf("failed to parse repo identifier: %w", err) 37 + return nil, fmt.Errorf("failed to parse identifier: %w", err) 38 38 } 39 39 idd, err := c.dir.Lookup(ctx, id) 40 40 if err != nil { ··· 44 44 "handle": idd.Handle, 45 45 "DID": idd.DID, 46 46 }).Info("identifier resolved") 47 + return idd, nil 48 + } 49 + 50 + func (c *Client) withIdentifier(ctx context.Context, raw string) (*atclient.APIClient, error) { 51 + idd, err := c.GetIdentity(ctx, raw) 52 + if err != nil { 53 + return nil, fmt.Errorf("failed to lookup identifier: %w", err) 54 + } 55 + log.WithFields(log.Fields{ 56 + "handle": idd.Handle, 57 + "DID": idd.DID, 58 + }).Info("identifier resolved") 47 59 return c.c.WithService(idd.PDSEndpoint()), nil 48 60 } 49 61 50 - func (c *Client) GetRepo(ctx context.Context, repo string) (*comatproto.RepoDescribeRepo_Output, error) { 62 + type RepoWithIdentity struct { 63 + Identity *identity.Identity 64 + Repo *comatproto.RepoDescribeRepo_Output 65 + } 66 + 67 + func (c *Client) GetRepo(ctx context.Context, repo string) (*RepoWithIdentity, error) { 51 68 log.WithFields(log.Fields{ 52 69 "repo": repo, 53 70 }).Info("describe repo") 54 71 72 + id, err := c.GetIdentity(ctx, repo) 73 + if err != nil { 74 + return nil, fmt.Errorf("failed to lookup identifier: %w", err) 75 + } 76 + 55 77 client, err := c.withIdentifier(ctx, repo) 56 78 if err != nil { 57 79 return nil, fmt.Errorf("failed to get client with identifier: %w", err) ··· 63 85 if err != nil { 64 86 return nil, fmt.Errorf("failed to describe repo: %w", err) 65 87 } 66 - return resp, nil 88 + return &RepoWithIdentity{ 89 + Identity: id, 90 + Repo: resp, 91 + }, nil 67 92 } 68 93 69 94 func (c *Client) ListRecords(ctx context.Context, collection, repo string) ([]*agnostic.RepoListRecords_Record, error) {
+5 -4
ui/app.go
··· 7 7 log "github.com/sirupsen/logrus" 8 8 9 9 "github.com/bluesky-social/indigo/api/agnostic" 10 - comatproto "github.com/bluesky-social/indigo/api/atproto" 10 + "github.com/bluesky-social/indigo/atproto/identity" 11 11 "github.com/bluesky-social/indigo/atproto/syntax" 12 12 "github.com/charmbracelet/bubbles/spinner" 13 13 "github.com/charmbracelet/bubbles/textinput" ··· 18 18 type App struct { 19 19 client *at.Client 20 20 search *CommandPallete 21 + identity identity.Identity 21 22 repoView *RepoView 22 23 rlist *RecordsList 23 24 recordView *RecordView ··· 72 73 case a.rlist: 73 74 a.active = a.repoView 74 75 return a, nil 75 - case a.recordView: 76 + case a.recordView: 76 77 a.active = a.rlist 77 78 return a, nil 78 79 } ··· 133 134 return repoErrorMsg{err: err} 134 135 } 135 136 log.WithFields(log.Fields{ 136 - "repo": resp.Handle, 137 + "repo": resp.Repo.Handle, 137 138 }).Info("Repo loaded") 138 139 return repoLoadedMsg{repo: resp} 139 140 } ··· 165 166 } 166 167 167 168 type repoLoadedMsg struct { 168 - repo *comatproto.RepoDescribeRepo_Output 169 + repo *at.RepoWithIdentity 169 170 } 170 171 171 172 type selectCollectionMsg struct {
+16 -8
ui/repo.go
··· 5 5 "strings" 6 6 7 7 comatproto "github.com/bluesky-social/indigo/api/atproto" 8 + "github.com/bluesky-social/indigo/atproto/identity" 8 9 "github.com/charmbracelet/bubbles/list" 9 10 tea "github.com/charmbracelet/bubbletea" 10 11 "github.com/charmbracelet/lipgloss" 12 + "github.com/treethought/goatie/at" 11 13 ) 12 14 13 15 var ( ··· 91 93 } 92 94 93 95 type RepoView struct { 94 - repo *comatproto.RepoDescribeRepo_Output 95 - clist *CollectionList 96 - header string 97 - width int 98 - height int 96 + identity *identity.Identity 97 + repo *comatproto.RepoDescribeRepo_Output 98 + clist *CollectionList 99 + header string 100 + width int 101 + height int 99 102 } 100 103 101 104 func NewRepoView() *RepoView { ··· 130 133 s.WriteString(dimStyle.Render(r.repo.Did)) 131 134 s.WriteString("\n\n") 132 135 136 + s.WriteString(labelStyle.Render("PDS: ")) 137 + s.WriteString(valueStyle.Render(r.identity.PDSEndpoint())) 138 + s.WriteString("\n") 139 + 133 140 // Collections section header 134 141 s.WriteString(headerStyle.Render("Collections ")) 135 142 s.WriteString(dimStyle.Render(fmt.Sprintf("(%d)", len(r.repo.Collections)))) ··· 140 147 141 148 } 142 149 143 - func (r *RepoView) SetRepo(repo *comatproto.RepoDescribeRepo_Output) tea.Cmd { 144 - r.repo = repo 150 + func (r *RepoView) SetRepo(repo *at.RepoWithIdentity) tea.Cmd { 151 + r.identity = repo.Identity 152 + r.repo = repo.Repo 145 153 r.header = r.buildHeader() 146 - r.clist = NewCollectionList(repo.Collections) 154 + r.clist = NewCollectionList(repo.Repo.Collections) 147 155 return r.clist.Init() 148 156 } 149 157