An unofficial terminal client for Tangled, optimized for humans and agents. tgcli.wisp.place

pr/issue comment writes a deprecated record type that the appview drops #11

Closed katsuricata.com
Closed opened by katsuricata.com

tg pr comment (and tg issue comment) write records that Tangled's appview silently drops, so the comment never shows up on the PR or issue page. It looks like it worked -- tg prints the new record's at-uri and exits 0 -- but the comment is gone.

What's happening #

tg writes comments as sh.tangled.repo.pull.comment / sh.tangled.repo.issue.comment records. Tangled deprecated both collections. In appview/ingester.go, the handlers for them are no-ops on create/update:

// ingestPullComment ingests legacy sh.tangled.repo.pull.comment deletions
func (i *Ingester) ingestPullComment(e *jmodels.Event, l *slog.Logger) error {
	switch e.Commit.Operation {
	case jmodels.CommitOperationCreate, jmodels.CommitOperationUpdate:
		// no-op. sh.tangled.repo.pull.comment is deprecated
	case jmodels.CommitOperationDelete:
		// ... deletes still processed
	}
}

Same for ingestIssueComment. Deletes still go through, but anything you create is ignored. The record sits on your PDS, valid and well-formed, and the appview never reads it. I only noticed because a comment I posted with tg pr comment never rendered, and I had to go read the ingester to find out why.

What Tangled uses now #

Comments live in sh.tangled.feed.comment (FeedComment), which the appview ingests via ingestComment. It's a different shape:

  • subject is a com.atproto.repo.strongRef (uri + cid) pointing at the pull or issue, not a bare pull/issue at-uri string.
  • body is a union (sh.tangled.markup.markdown), not a plain string.
  • pullRoundIdx is an integer, required when the subject is a pull -- this is how a comment attaches to a specific review round.

tg v0.4.0 doesn't have the feed.comment schema at all. It only vendors the deprecated pulls/comment.json and issue/comment.json, so there's no code path that writes a comment the current appview will accept.

The fix #

tg pr comment and tg issue comment need to write sh.tangled.feed.comment records: build a strongRef to the pull/issue (which means resolving the subject's current cid), wrap the body in the markdown union, and set pullRoundIdx for pulls. Until then both subcommands are effectively broken -- they report success and produce nothing.

Repro: tg pr comment <rkey> -R <owner>/<repo> -b "test" on any open PR, then check the PR page. The comment won't be there, but the record exists on your PDS.

Found on tg 0.4.0 while commenting on a PR from the CLI.

oh the joys of a moving platform 😉 appreciate the reports, I'll fix these soon!

Following up with a second bug I hit while working around this one, since it's the other half of why tg issue comment can't post anything visible right now.

The deprecated-collection thing is only half the story. Once I knew repo.issue.comment was dropped, I tried writing the correct sh.tangled.feed.comment record straight to my PDS -- built the strongRef to the issue, wrapped the body in the markdown union, the works. That got bounced with InvalidToken: Bad token scope. tg's OAuth permission set doesn't include sh.tangled.feed.comment, so a session from tg auth login can write the deprecated collection but not the current one. There's no scope flag on login to widen it.

So fixing the collection in the code isn't enough on its own. The OAuth client metadata needs sh.tangled.feed.comment added too, otherwise the fix still won't post -- same Bad token scope, just on the right collection this time.

The only way I got a working comment in was an app-password session, which skips the granular scopes entirely.

Two tiny extras while I'm here. pullRoundIdx is required when the subject is a pull, and resolving the subject's cid means a getRecord round-trip before the write -- both easy to miss if you're going off the old record shape. And whatever comment I wrote to test the deprecated path is now orphaned on my PDS: deleting it hits the same scope wall, so it'll sit there doing nothing until the scopes catch up.

This was on tg 0.4.0.

sh.tangled.feed.comment should already be in the oauth scopes, huh

Is it possible you originally auth'd with a pevious version? I can look into when we got the right scopes.

I'm werkin on this (I can stop if aly or someone else already is though)

pls go ahead! I was gonna dive in tonight or tomorrow but always welcome.

still working on this? I can jump it tonight with some preliminary work on the lexicons

Merging a fix soon 😃

Sign up or Sign in to add to the discussion.