Monorepo for Tangled tangled.org

appview: allows a default knot to be configured #991

open opened by willdot.net targeting master from willdot.net/tangled-fork: default-knot

This follows on from the work carried out in #836

I've added a select box in the Knots settings page which pulls in the users knots and also adds in knot1.tangled.sh. When the user selects one of these options, it will save to their profile in the database. NOTE: I haven't yet implemented adding that to the AT record because I'm not sure on how the lexicon setup works yet!

Then when users go to create a new repo / fork, if there is a value in their profile for the default knot, then that will pre select the knot to use for the new repo / fork.

This is a duplicate of https://tangled.org/tangled.org/core/pulls/858/ which had to be closed because there were merge conflicts which couldn't be resolved due to the origin fork being deleted ๐Ÿ™ˆ

Labels

None yet.

assignee

None yet.

Participants 2
AT URI
at://did:plc:dadhhalkfcq3gucaq25hjqon/sh.tangled.repo.pull/3mcrzfonnxs22
+1 -1
Interdiff #0 โ†’ #1
appview/db/db.go

This file has not been changed.

+1 -1
appview/db/profile.go
··· 141 141 pronouns, 142 142 default_knot 143 143 ) 144 - values (?, ?, ?, ?, ?)`, 144 + values (?, ?, ?, ?, ?, ? )`, 145 145 profile.Did, 146 146 profile.Description, 147 147 includeBskyValue,
appview/knots/knots.go

This file has not been changed.

appview/models/profile.go

This file has not been changed.

appview/pages/pages.go

This file has not been changed.

appview/pages/templates/knots/index.html

This file has not been changed.

appview/pages/templates/repo/fork.html

This file has not been changed.

appview/pages/templates/repo/new.html

This file has not been changed.

appview/repo/repo.go

This file has not been changed.

appview/state/profile.go

This file has not been changed.

appview/state/router.go

This file has not been changed.

appview/state/state.go

This file has not been changed.

History

8 rounds 9 comments
sign up or login to add to the discussion
1 commit
expand
appview: allow default knot to be saved as a preference and then used when creating a new repo
no conflicts, ready to merge
expand 0 comments
1 commit
expand
appview: allow default knot to be saved as a preference and then used when creating a new repo
expand 0 comments
1 commit
expand
appview: allow default knot to be saved as a preference and then used when creating a new repo
expand 0 comments
1 commit
expand
appview: allows a default knot to be selected from knots available to the user
expand 5 comments

@oppi.li While attempting to implement something else related to profiles, I've noticed that UpsertProfile(...) herehttps://tangled.org/tangled.org/core/blob/master/appview/db/profile.go#L133 also gets called as part of a JS ingester here https://tangled.org/tangled.org/core/blob/master/appview/ingester.go#L352 which means the DefaultKnot field will be overwritten with an empty string when a profile event is ingested. Am I understanding that correctly?

So instead I should probably not use the UpsertProfile(...) but use a smaller scoped function that just sets the Default Knot field?

ah that is correct, the default knot will be overwritten by that call. i suppose that is one of the drawbacks of overloading models.Profile! instead of cloning UpsertProfile to add this as an exception, perhaps this is an indication that we need to avoid using the profile table/model for this. what do you think about creating a preferences table for stuff like this? we already have notification_preferences, we could do something similar for knots.

i see you have a PR open for punchcard work as well, which would fit quite well in a punchcard_preferences table.

Yh I'm 100% down for using that approach. While I was implementing the punchcard PR I had this nagging feeling in me that this and other things belonged in some sort of separate "preferences" table so splitting them out into things like knot_preferences or punchcard_preferences is the right answer for me.

I'll redo that for this PR and then do the same of the other PR and hopefully it will prevent the merge conflicts I was dreading ๐Ÿ™ˆ

yeah! knot_preferences and punchcard_preferences seems okay for now. thanks for keeping at this by the way, and sorry for the slow review cycle!

No worries! I don't expect immediate reviews ๐Ÿ˜

I've refactored to use a new knot_preferences table for this PR. I had some merge conflicts with master though, so rebased that although took me a couple attempts to get everything nice and neat, hence so many rounds ๐Ÿ™ˆ

2 commits
expand
appview: allows a default knot to be configured
appview: allows a default knot to be selected from knots available to the user
expand 0 comments
1 commit
expand
appview: allows a default knot to be configured
expand 2 comments

the code itself works pretty nicely now. so i've noticed a couple issues (apologies for not looking more closely earlier!):

  • the default-knot selector only iterates over knots that the user is an admin of, whereas they should be able to choose any knot that they are a member of as the default. you can use s.enforcer.GetKnotsForUser(...) to get a list of knots that a user has access to
  • the HTML change adds knot1.tangled.sh as an explicit case, this is not necessary if the above is implemented
  • the HTML template currently triggers a request when the select changes, could we make this more like how the spindle selector works? a form with a button to submit.

I was looking for ages trying to find somewhere that did something similar. I don't use spindles so never saw that ๐Ÿ™ˆ A much better approach.

Also good shout on the knots for a user. Reading the code now, I understand what the registrations are now.

Anyhow, I've updated the PR and squashed everything so it should be good to test now.

Please note, that I have yet to figure out how to get multiple Knots running locally, and since I don't get knot1.tangled.sh locally I had to hard code some things in to test it worked, which is less than ideal.

1 commit
expand
appview: allows a default knot to be configured
expand 0 comments
1 commit
expand
appview: allows a default knot to be configured
expand 2 comments

i get this error at runtime:

2026/01/20 04:58:12 profile err 5 values for 6 columns
2026/01/20 04:58:12 failed to update profile 5 values for 6 columns

this sql query is incorrect:

		`insert or replace into profile (
			did,
			description,
			include_bluesky,
			location,
			pronouns,
			default_knot
		)
		values (?, ?, ?, ?, ?)`,

there should be 6 ? placeholders!

Ah crap, someone needs to create a lint tool that detects that ๐Ÿคฆโ€โ™‚๏ธ

Fixed.