summaryrefslogtreecommitdiff
path: root/ui/lib
Commit message (Collapse)AuthorAge
* Don't retry operations where we received an unacceptable response.Owen Jacobson2025-05-05
| | | | | | | | This was actually two issues in one! Issue 1: `isRetryable` did not consider whether we got a response or not. It assumed that the presence of a request in the error signaled that the error was definitely due to network issues, when in fact it's the presence of a request _and_ the absence of a response. That's my misreading of the Axios docs; the replacement `isRetryable` is more thorough. Issue 2: operations in the outbox queue that fail with an exception stop the outbox drain process from making further progress, _and_ they stay in the queue. The outbox now dequeues jobs that throw an exception, and restarts itself if it terminates with a non-empty queue. The code that does this is _heinous_, but it seems to work well enough… Words I'm sure I won't come to regret.
* Use the outbox for more than just message sends.Owen Jacobson2025-05-05
| | | | | | | | | | A handful of operations are "synchronized" - that is, the server sends back information about them when the client asks to perform them, but notifies _all_ clients of completion through the event stream. As of this writing, these operations include sending and deleting messages, creating and deleting channels, and anything that creates new users. We can use the outbox for most of these. I've opted _not_ to use the outbox for creating users, as that often takes place when the client is not connected to the event stream (and can't be) and so cannot discover that the operation has been completed after it is sent. Outboxed tasks are objects, not closures, even though they behave in closure-like ways (`send()` carries out what amounts to "attempt this operation until it succeeds"). This is deliberate; I want the properties of incomplete tasks to be inspectable down the line, so that we can put them in the UI. If they're mere closures, we can't do that. It is deliberate that `outbox.postToChannel` et al do not return promises. I contemplated it, but it will interact weirdly with outbox serialization, when we get to that. Rather than relying on a promise to determine when an operation has completed, clients of `Outbox` should monitor its properties. (We can add additional view properties to make that easier.)
* Send messages through an outbox, rather than sending them to the API ↵Owen Jacobson2025-05-02
| | | | | | | | directly from the UI. This primarily serves to free up the message input immediately, so that the user can start drafting their next message right away. The wait while a message is being sent is actively disruptive when using Pilcrow on a server with noticable latency (hi.grimoire.ca has around 700ms), and this largely alleviates it. Unsent messages can be lost if the client is closed or deactivated before they make it to the head of the queue.
* Retry boot every five seconds.Owen Jacobson2025-04-23
|\ | | | | | | Merged in spite of misgivings. This method will loop over the request until it completes, even if the user moves to a view where the response is no longer relevant.
| * Naming improvements c/o KitOwen Jacobson2025-04-23
| |
| * When booting a session, retry every five seconds if unable to send the request.Owen Jacobson2025-04-22
| | | | | | | | | | | | This is intended to transparently resume the session (using `boot` to start over) after more serious connection interruptions. It interacts with the heartbeat timeout: we let the browser try to reconnect through `EventSource` on its own for up to 30 seconds, before intervening, closing the event source, and starting attempts to call `boot`. This covers both initial boot, which will now hang if the server is unavailable (sorry), and reconnection after an event timeout. No other operations are retried (particularly, sending a message is _not_ retried).
* | Remove trailing spaceKit La Touche2025-04-22
| |
* | Add the following attributes to all markdown-generated links:Owen Jacobson2025-04-21
|/ | | | | | | | * `target="_blank"`: when Pilcrow is running in a browser, clicking a link should not replace Pilcrow with the target of the link. Pilcrow is "app-like" enough that opening links in a new tab _by default_, without user intervention, is likely more appropriate. * `rel="noreferrer"`, which (A) stops most UAs from setting a referrer header when following those links, and (B) also implies `noopener`, preventing the link target from using `window.opener` from reaching back into Pilcrow's DOM. I briefly experimented with DOMPurify's `RETURN_DOM_FRAGMENT` mode, which would have made the tests somewhat easier to write, but I wasn't able to find a good way to integrate the returned `DocumentFragment` objects with Svelte components, so HTML-as-strings it is. Sigh.
* Restart the event connection if heartbeats stop showing up.Owen Jacobson2025-04-08
| | | | | | | | The changes introduced in the previous commit make it possible to detect lost connections and restart them, so do so. The process is pretty simple - a new remote state is spun up using `/api/boot`, swapped in for the existing state, and a `new EventSource` is started from that new remote state to consume events. This can induce some anomalies. For example, messages that arrive on the server between the loss of one connection and the creation of the next one just "show up" in boot, without ever appearing in the event stream. (This is technically also true on client startup, but it's easier to expect in that situation.) This is something we'll need to consider when implementing things like notifications or unread flags, though the ones we have today, which are state-based, do work fine. By design, this _does not_ retry either the `/api/boot` call or the new event source setup. Event sources will try to reconnect on their own, up to a point, so that's fine, but we need to build something more robust for `/api/boot`. I want to tackle that separately from detecting lost connections and reacting to them, but that does mean that this is not a complete solution to client reconnects.
* Remove stray debug outputOwen Jacobson2025-04-04
|
* Merge branch 'prop/rename-login-to-user'Owen Jacobson2025-04-03
|\
| * Rename `login` to `user` in the client.Owen Jacobson2025-03-24
| |
* | Decode stored channel state as JSON. (Oops.)Owen Jacobson2025-04-03
|/
* Track state on a per-session basis, rather than via globals.Owen Jacobson2025-02-26
| | | | | | | | | | | Sorry about the thousand-line omnibus change; this is functionally a rewrite of the client's state tracking, flavoured to resemble the existing code as far as is possible, rather than something that can be parted out and committed in pieces. Highlights: * No more `store.writeable()`s. All state is now tracked using state runs or derivatives. State is still largely structured the way it was, but several bits of nested state have been rewritten to ensure that their properties are reactive just as much as their containers are. * State is no longer global. `(app)/+layout` manages a stateful session, created via its load hook and started/stopped via component mount and destroy events. The session also tracks an event source for the current state, and feeds events into the state, broadly along the same lines as the previous stores-based approach. Together these two changes fix up several rough spots integrating state with Svelte, and allow for the possibility of multiple states. This is a major step towards restartable states, and thus towards better connection management, which will require the ability to "start over" once a connection is restored.
* Split Markdown rendering out into its own JS module.Owen Jacobson2025-02-25
|
* Don't scroll all the time as messages are addedKit La Touche2025-02-25
| | | | Only once on load, then once per new message.
* Merge branch 'prop/preserve-state'Owen Jacobson2025-02-24
|\
| * npm run fmtOwen Jacobson2025-02-24
| |
| * Move constant closer to usageOwen Jacobson2025-02-24
| |
| * Merge branch 'main' into prop/preserve-stateKit La Touche2025-02-21
| |\
| * | Remove explanatory commentKit La Touche2025-02-20
| | | | | | | | | | | | That no longer vitally pertains.
| * | Remember last active channel and navigate there on root loadKit La Touche2025-02-20
| | | | | | | | | | | | To facilitate PWA behaviour.
| * | Separate channel metadata out into its own storeKit La Touche2025-02-20
| | | | | | | | | | | | | | | | | | | | | | | | This is stored locally, and, while parallel to channel info, is not the same as. Eventually, this may hold info about moot/decayed channels, and grow unbounded. That'll need to be addressed.
| * | Merge local channel data and remote to maintain stateKit La Touche2025-02-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | When we hit the boot endpoint, we get the server's view of things. If we just setChannels with that, we overwrite all our locally-stored info in on things like lastReadAt. So we need to merge data. Eventually, this might militate for a `meta` key containing an object of locally stored data, rather than having to handle each key specially.
* | | Hoist global state access out of individual components.Owen Jacobson2025-02-21
| |/ |/| | | | | | | | | | | | | Access to "global" (maybe "external?") state is now handled at the top level of the component hierarchy, in `+page.svelte`, `+layout.svelte`, and their associated scripts. State is otherwise passed down through props, and changes are passed up through callbacks. This is - hopefully - groundwork for refactoring state management a bit. I wanted to move access to state out to a smaller number of places, so that I have fewer places to update to implement reconnect logic. My broader goal is to make it easier to refactor these kinds of external side effects, as well, though no such changes are in this branch. This change also makes testing a mile easier, since tests can interact with props and callbacks instead of emulating the whole HTTP request stack and the Pilcrow API. This change removes do-very-little tests.
* | Remove stray importsOwen Jacobson2025-02-21
| |
* | Add missing awaits on goto() callsOwen Jacobson2025-02-21
| |
* | Be a bit more careful with the nesting of anchors and list items.Owen Jacobson2025-02-21
| | | | | | | | Browsers cope with weird nestings mostly fine, but there's no upside for us in testing that.
* | Remove unused type attribute on textareaOwen Jacobson2025-02-21
| |
* | Split "set up the event source" and "apply events to state" from one another.Owen Jacobson2025-02-21
| |
* | Use axios to compute event stream URL, why not.Owen Jacobson2025-02-20
|/ | | | It's amazing what you can learn by skimming the docs.
* npm formatOwen Jacobson2025-02-15
|
* Add placeholder to message inputKit La Touche2025-01-28
|
* npm run formatOwen Jacobson2025-01-11
|
* Use margins, rather than alternating float/non-float elements, to lay out ↵Owen Jacobson2025-01-11
| | | | own/other messages.
* Stylize channel badgesKit La Touche2025-01-05
|
* A bit more stylingKit La Touche2025-01-05
|
* Stylize more betterKit La Touche2025-01-05
|
* Fix invite copy buttonKit La Touche2025-01-04
|
* Add username class to username spanKit La Touche2025-01-04
|
* Just oh so many stylesKit La Touche2025-01-01
|
* Strip out Tailwind etcKit La Touche2024-12-30
|
* Merge branch 'main' into wip/stylizeKit La Touche2024-12-03
|\
| * Prefer camelCase to snake_case in argument namesKit La Touche2024-11-29
| | | | | | | | Even when they get mapped to snake_case searchParams.
| * Style Channels differently when they have unreadsKit La Touche2024-11-29
| | | | | | | | I dunno, I like the fleuron. Maybe it's too twee?
| * Use Luxon dates on Message store and componentKit La Touche2024-11-29
| | | | | | | | | | | | This includes jamming the "at" of a message into a data- attribute on the Message component, so that it can later be used by parent components via Plain Old Javascript and the .dataset attribute of an HTML node.
| * Rename and modify channels storeKit La Touche2024-11-29
| | | | | | | | | | | | | | | | I tried to have a custom class for Channel objects, but Svelte's automatic proxy logic works only on bare objects, as far as I could tell. So that broke everything. I resorted to a function that would build the bare objects, but we still lack methods that I think would make life easier ("touch last read" etc).
* | Add styling for pre blocks in messagesKit La Touche2024-11-30
| |
* | Merge branch 'main' into wip/stylizeKit La Touche2024-11-28
|\|
| * Best-guess an ARIA role for this element.Owen Jacobson2024-11-26
| | | | | | | | Svelte's lint complains if you add interaction to a div but don't give that div an ARIA role.