Skip to content

make channel scopes configurable - #68

Merged
fdlamotte merged 1 commit into
meshcore-dev:mainfrom
4nd3r:scopes_config
Aug 17, 2026
Merged

make channel scopes configurable#68
fdlamotte merged 1 commit into
meshcore-dev:mainfrom
4nd3r:scopes_config

Conversation

@4nd3r

@4nd3r 4nd3r commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

This is a quick hack to add per channel scope configuration and I'm probably doing it wrong.

Currently this only works when default_scope is not set.

Configuration file is straightforward and must be edited manually:

$ cat .config/meshcore/scopes
Public *
#estonia ee
#tartu ee
#test ee

I wish to have similar behavior as with mobile/web app where I can override default scope per channel, even if default scope is set (in experimental settings).

Happy to hear feedback from maintainer(s) and even more happier if anyone else implements this feature as they see fit. Thanks!

@fdlamotte fdlamotte left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting ...
I didn't want to implement this because this mapping is not stored on the device, but if there is some interest, and noone is forced to use it, that's good for me
Note that with this implentation, the scope will only be applied in interactive mode when using to, this is not a bad thing (and is in my opinion better) but users should be aware of that

Also, I would give priority to the scope set with % (for that just use elif on l1248)

I'm not sure about the behavior that should be taken when going back to root ... maybe set scope to "" only if current scope corresponds to the one in the dict for the channel we are living ? The user might want to keep is scope while changing destination (would not go further as it would mean using some stack of context and I'd like to let the mechanism as simple as possible)

@fdlamotte

Copy link
Copy Markdown
Collaborator

Currently this only works when default_scope is not set.

why doesn't it work when default scope is set ? I'm not using scopes since I've moved to dominican republic, maybe there is something I missed with the latest scope implementation ? but your patch does not seem to take default_scope into consideration so I'm wondering ...

@fdlamotte

Copy link
Copy Markdown
Collaborator
image In the example above, I've set the scope to an unknown one and verify my message is not repeated When using scope to force unscopped message, the message is repeated as it should, overriding default_scope

So I think with your implementation, the default scope will be overriden by the one set in the scope file, and it seems the logical way of doing it

As I said, I'm ok to merge your implementation, the two points you might consider:

  • give % a higher priority (as it is user request for a given scope)
  • see how you can keep the old behavior of keeping scope when going back to root (at least when no scope is attached to the channel we leave)

@4nd3r
4nd3r force-pushed the scopes_config branch 3 times, most recently from 6ab1305 to 7944709 Compare August 17, 2026 11:16
@4nd3r

4nd3r commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

Tried different approach.

My scopes:

$ cat .config/meshcore/scopes
Public *
#tartu tartu

With set default_scope ee (program restart is required for this to take effect):

A.²|ee> /to #tartu
A.²/#tartu|tartu> /to public
A.²/Public|*> /to #estonia
A.²/#estonia|ee> /to /
A.²|ee> 

Without default_scope:

A.²> /to #tartu
A.²/#tartu|tartu> /to public
A.²/Public|*> /to #estonia
A.²/#estonia> /to /
A.²> 

With this approach now prompt shows default scope when set. Not sure what to think about restart requirement after setting it. If it's documented behavior, then it's easier, otherwise bit more complex handling must be added.

How does this look? I'd deal with documentation and such after code is finished.

@fdlamotte

Copy link
Copy Markdown
Collaborator

Hi

I don't want the prompt to show default scope when set ;) that was on purpose ...

The scope on the prompt is the overriden one

When no scope name is shown user knows he is on default scope ... If he doesn't remind what it is, then he calls get default_scope

just found some issues with parsing (' and " split lines in chat mode !) so I'll probably include your proposal in 1.6.1 ;)

@fdlamotte

Copy link
Copy Markdown
Collaborator

I'm sorry, as I have the impression we are regressing ...

Your first try was good, and default scope was treated as it should (this is already taken care of actually)

The only thing that I wanted was to give priority to % over chanel scope in the to command and being able to keep scope when going to root if the scope was not set from the file ...

If you want, you can revert to the first version and I'll take care of the changes myself ;)

@fdlamotte

Copy link
Copy Markdown
Collaborator

the simplest the better ;)

thank you !

@4nd3r

4nd3r commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

Alright, I restored initial state, mostly.

I tried to solve switching between channels with and without defined scope. Now switching to channel without defined scope will inherit whatever was set for channel with scope. Also switching to root requires special treatment.

Of course I can define scopes for all my channels, not only those I want to override from default, and that solves it.

@fdlamotte
fdlamotte merged commit bcfd400 into meshcore-dev:main Aug 17, 2026
@fdlamotte

Copy link
Copy Markdown
Collaborator

I've implemented it the way I wanted ... if we leave a channel and the scope had been obtained from scopes file, then reset scope (if no new scope was resolved) ...
works for me, tell me what you think ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants