portal 2026-10-14

Is there some way to provide a link to a specific cell in a Portal session? If I were to expose my Portal session to someone outside my network, is there a way I can send them links to specific cells so we can discuss the contents?

Does that work for you?

hmm, if I understand correctly, this basically creates a standalone cel, so I'd lose the context of the neighbouring cells?

If you need to send a specific subset of the data, you can select them all and put them in a vector and send that.

If you need to send the UI in a specific state, that isn't currently possible

@djblue If you have some time, could you please share how this might be implemented and what the challenging parts might be?

I think the underlying request here is to have a multi-player enabled version of Portal. For {:mode :rpc}, which is the default, the majority of the state lives on the client and sync is generally and annoying problem to solve. However, Portal now has {:mode :ssr} where all the UI state lives server side. A potential solution to your problem is to have a ssr session which can be opened in multiple tabs. Some stuff in the UIs will still need to sync’d (like page scroll), but I think this gets closer to what you want.

The first hurdle you will encounter is https://github.com/djblue/portal/blob/master/src/portal/runtime/jvm/ssr.clj#L230 where portal establishes a one-to-one mapping between session and browser.

I put together a PR for multi party SSR https://github.com/djblue/portal/pull/322

Thanks very much for working on this, @djblue. I think it’s workable for my use case as is, and I’ll give it a try starting today. I think there’s some value to having a single shared view, but users will want to explore the data on their own and occasionally share specific findings within it (potentially deeply nested and using some particular viewer that isn’t the default). I have something that I vibe coded because I wanted to validate the use case before investing too much time into it. I’m sharing here in case you might find it helpful: Thanks for the pointers. Some context on what we’re doing: --- Use case. We want a shared Portal: several people open the same link onto the same live data, each moves around in it on their own, and anyone can share a link to a particular view so others open it there. What we’ve built. One :rpc session per dataset, opened with p/open {:launcher false :value data-atom}. Since several browsers share that session, we override [:get "/rpc"]: 1. We store each page’s websocket by session ID, so one session can have several pages connected at once, and point rt/connections at a function that sends to all of them. 2. When a page asks the server for something (say, pressing Enter runs nav), we answer on that page’s own websocket, not the session’s shared connection, so the result goes to the page that asked. 3. When a page closes, we drop only its websocket. If it was the last one, we call rt/reset-session. For sharing a single value, we use your suggestion: a standalone #content-url=data:... link when it’s small. This isn’t ideal because it loses the context of surrounding cells. What’s missing on our side. 1. Links to a view. We’d like a link that opens a specific place in the data, without sharing anyone’s live view. Our idea: the link carries a path [k1 k2 ...] from the root, we open a fresh session, replay the path with datafy/`nav` on the server, and reset! each step so Back walks up. 2. Getting the path. We don’t yet have a way to get the selected value’s path out of the UI, so a reader can’t copy a link to where they are. 3. The /rpc override. It relies on internals (`rt/connections`, rpc/ops), and we’re unsure the cleanup is right when one of several pages closes.

I re-read the thread and I think your implementation does address what I initially raised. My last message definitely adds quite a bit of scope. Once you mentioned “multi-player portal”, the wheels really started spinning 🙂

Do you need to be able to spin up multiple ad-hoc shared views, or is one enough?

Also, if everyone has access to the same instance, you don’t need to do #content-url=data:... you can just make a new session via portal.api/inspect and share that session id

The root dataset is shared, but Alice may want to show Bob some particular piece (path + viewer) within it and Bob may want to show something else in response. Not sure if that directly answers your question.

So for Alice and Bob, can they both have two instances running, one independent and one shared? The shared instance can be to an atom that gets reset from the independent instances via a command. Additionally, when both move over to the shared instance, either can drive to help the other understand a certain context.

Two Portal instances over the same underlying atom? If so, that sounds good. I’m not clear what you mean by the second sentence. The co-steering “mode” you describe in the last sentence makes perfect sense.

Here is the rough setup that is in my head:

(require '[portal.api :as p])

(def data {})

(def shared-value (atom nil))

(defn set-shared!
  "Set the value for the shared instance"
  {:command true}
  [value]
  (reset! shared-value value))

(p/register! #'set-shared!) ;; now users can reset the shared instance value directly from their other portal

(def share-instance (p/open {:mode :ssr :launcher false :value shared-value}))

(def alice-independent (p/open {:mode :ssr :value data}))
(def alice-shared (p/clone share-instance))

(def bob-independent (p/open {:mode :ssr :value data}))
(def bob-shared (p/clone share-instance))

Is that closer to what you had in mind?

Does a newly tapped value appear in both independent sessions?

That’s up to you. Their independent instances include any data you would want to include in any instance of Portal.

Is it possible to: • share a link to a shared value • go to the parent of the shared :hacker-news value to see surrounding context

(p/url share-instance) will give you a link that can be shared / opened in any browser tab

• go to the parent of the shared :hacker-news value to see surrounding context
You would need to have set-shared! the parent value then, but super easy to do

I have to step away now, but let me give this some thought over the next few days or so and I’ll get back to you. Thanks very much for everything.

👍 1

I haven’t tested your ssr approach yet and still haven’t thought it through fully, but to distill what it was that I was initially trying to achieve: • Several people open the same link onto the same live data. • Each person moves around in it on their own. • Anyone can share a link to a particular view. • That view can be any location, at any depth datafy/nav reaches, not just a row. • A shared link opens with that location already in front. • Someone who opens a shared link can then go anywhere a person on the main link can, not just back up to the root. The SSR approach might be able get us there and has other use cases. Not entirely sure right now. I think some way to simply provide a permalink-like URL to a particular [path, viewer] would be the simplest from the user’s perspective.