From 8ddc38f768e18a7c72a3b904446fdb01835092bd Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 3 May 2026 10:04:14 -0500 Subject: disable weird rule --- src/web/.eslintrc.js | 1 + 1 file changed, 1 insertion(+) (limited to 'src/web') diff --git a/src/web/.eslintrc.js b/src/web/.eslintrc.js index 0c36e3ed..81d1001c 100644 --- a/src/web/.eslintrc.js +++ b/src/web/.eslintrc.js @@ -5,6 +5,7 @@ const overrides = { 'no-eq-null': 'off', // noisy 'react/forbid-component-props': 'off', // noisy 'react/prop-types': 'off', // noisy + 'canonical/sort-keys': 'off', // noisy 'unicorn/no-array-reduce': 'off', // noisy }; -- cgit v1.2.3 From 8a22018aefbb89d1b74788a0d6bda97b0d8da6b0 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 3 May 2026 10:05:03 -0500 Subject: use state for message input instead of dom ref (causing delay in updates) --- src/web/src/components/Chat/Chat.jsx | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'src/web') diff --git a/src/web/src/components/Chat/Chat.jsx b/src/web/src/components/Chat/Chat.jsx index 23619bd1..9e3605b8 100644 --- a/src/web/src/components/Chat/Chat.jsx +++ b/src/web/src/components/Chat/Chat.jsx @@ -20,6 +20,7 @@ const initialState = { conversations: {}, interval: undefined, loading: false, + message: '', }; class Chat extends Component { @@ -106,21 +107,15 @@ class Chat extends Component { await chat.acknowledge({ username }); }; - sendMessage = async (username, message) => { - if (!username || !message || username === '') return; - await chat.send({ message, username }); - }; - sendReply = async () => { - const { active } = this.state; - const message = this.messageRef.current.value; + const { active, message } = this.state; if (!this.validInput()) { return; } - await this.sendMessage(active, message); - this.messageRef.current.value = ''; + await chat.send({ username: active, message }); + this.setState({ message: '' }); // force a refresh to append the message // we could probably do this in the browser but we can be lazy @@ -129,12 +124,7 @@ class Chat extends Component { validInput = () => (this.state.active || '').length > 0 && - ( - (this.messageRef && - this.messageRef.current && - this.messageRef.current.value) || - '' - ).length > 0; + (this.state.message || '').length > 0; focusInput = () => { this.messageRef.current.focus(); @@ -294,7 +284,7 @@ class Chat extends Component { name="send" /> ), - onClick: this.sendMessage, + onClick: this.sendReply, }} fluid input={ @@ -302,7 +292,11 @@ class Chat extends Component { autoComplete="off" data-lpignore="true" id="chat-message-input" + onChange={(event) => + this.setState({ message: event.target.value }) + } type="text" + value={this.state.message} /> } onKeyUp={(event) => -- cgit v1.2.3 From e70664167d1766b63a12fa1833b452a217e8b6cc Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 3 May 2026 10:05:18 -0500 Subject: focus input when conversation is loaded --- src/web/src/components/Chat/Chat.jsx | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/web') diff --git a/src/web/src/components/Chat/Chat.jsx b/src/web/src/components/Chat/Chat.jsx index 9e3605b8..0a080466 100644 --- a/src/web/src/components/Chat/Chat.jsx +++ b/src/web/src/components/Chat/Chat.jsx @@ -170,6 +170,12 @@ class Chat extends Component { } catch { // no-op } + + try { + this.messageRef.current.focus(); + } catch { + // no-op + } }, ); }, -- cgit v1.2.3 From 402b4d7509c582bd2d93e73a33778068e660259e Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 3 May 2026 11:09:33 -0500 Subject: use state instead of dom ref for rooms --- src/web/src/components/Rooms/Rooms.jsx | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'src/web') diff --git a/src/web/src/components/Rooms/Rooms.jsx b/src/web/src/components/Rooms/Rooms.jsx index 0f2e4382..d30828eb 100644 --- a/src/web/src/components/Rooms/Rooms.jsx +++ b/src/web/src/components/Rooms/Rooms.jsx @@ -32,6 +32,7 @@ const initialState = { }, joined: [], loading: false, + message: '', room: { messages: [], users: [], @@ -131,6 +132,12 @@ class Rooms extends Component { } catch { // no-op } + + try { + this.messageRef.current.focus(); + } catch { + // no-op + } }); }, ); @@ -150,12 +157,7 @@ class Rooms extends Component { validInput = () => (this.state.active || '').length > 0 && - ( - (this.messageRef && - this.messageRef.current && - this.messageRef.current.value) || - '' - ).length > 0; + (this.state.message || '').length > 0; focusInput = () => { this.messageRef.current.focus(); @@ -174,15 +176,14 @@ class Rooms extends Component { }; sendMessage = async () => { - const { active } = this.state; - const message = this.messageRef.current.value; + const { active, message } = this.state; if (!this.validInput()) { return; } await rooms.sendMessage({ message, roomName: active }); - this.messageRef.current.value = ''; + this.setState({ message: '' }); }; handleContextMenu = (clickEvent, message) => { @@ -207,8 +208,12 @@ class Rooms extends Component { }; handleReply = () => { - this.messageRef.current.value = `[${this.state.contextMenu.message.username}] ${this.state.contextMenu.message.message} --> `; - this.focusInput(); + this.setState( + (previousState) => ({ + message: `[${previousState.contextMenu.message.username}] ${previousState.contextMenu.message.message} --> `, + }), + () => this.focusInput(), + ); }; handleUserProfile = () => { @@ -364,7 +369,11 @@ class Rooms extends Component { autoComplete="off" data-lpignore="true" id="room-message-input" + onChange={(event) => + this.setState({ message: event.target.value }) + } type="text" + value={this.state.message} /> } onKeyUp={(event) => -- cgit v1.2.3 From a232848ee4f5539b0041e3581705edd00aec80f0 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 3 May 2026 13:27:20 -0500 Subject: clear any captured message when changing room/conversation --- src/web/src/components/Chat/Chat.jsx | 1 + src/web/src/components/Rooms/Rooms.jsx | 1 + 2 files changed, 2 insertions(+) (limited to 'src/web') diff --git a/src/web/src/components/Chat/Chat.jsx b/src/web/src/components/Chat/Chat.jsx index 0a080466..72960129 100644 --- a/src/web/src/components/Chat/Chat.jsx +++ b/src/web/src/components/Chat/Chat.jsx @@ -147,6 +147,7 @@ class Chat extends Component { { active: username, loading: true, + message: '', }, async () => { const { active, conversations } = this.state; diff --git a/src/web/src/components/Rooms/Rooms.jsx b/src/web/src/components/Rooms/Rooms.jsx index d30828eb..0b1366fd 100644 --- a/src/web/src/components/Rooms/Rooms.jsx +++ b/src/web/src/components/Rooms/Rooms.jsx @@ -118,6 +118,7 @@ class Rooms extends Component { { active: roomName, loading: true, + message: '', room: initialState.room, }, async () => { -- cgit v1.2.3 From 9a7556a9c9b3c1313f11f369d8b38ad8fe144b58 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 3 May 2026 13:30:50 -0500 Subject: don't clear the message if the same room/convo is re-selected Co-authored-by: Copilot --- src/web/src/components/Chat/Chat.jsx | 6 +++--- src/web/src/components/Rooms/Rooms.jsx | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/web') diff --git a/src/web/src/components/Chat/Chat.jsx b/src/web/src/components/Chat/Chat.jsx index 72960129..086d2cd8 100644 --- a/src/web/src/components/Chat/Chat.jsx +++ b/src/web/src/components/Chat/Chat.jsx @@ -144,11 +144,11 @@ class Chat extends Component { selectConversation = (username) => { this.setState( - { + (previousState) => ({ active: username, loading: true, - message: '', - }, + message: previousState.active === username ? previousState.message : '', + }), async () => { const { active, conversations } = this.state; diff --git a/src/web/src/components/Rooms/Rooms.jsx b/src/web/src/components/Rooms/Rooms.jsx index 0b1366fd..3d29242b 100644 --- a/src/web/src/components/Rooms/Rooms.jsx +++ b/src/web/src/components/Rooms/Rooms.jsx @@ -115,12 +115,12 @@ class Rooms extends Component { selectRoom = async (roomName) => { this.setState( - { + (previousState) => ({ active: roomName, loading: true, - message: '', + message: previousState.active === roomName ? previousState.message : '', room: initialState.room, - }, + }), async () => { const { active } = this.state; -- cgit v1.2.3 From 9ad8b004544e9edcf5141f536bb6be99b49dba51 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 3 May 2026 13:51:20 -0500 Subject: memoize history Co-authored-by: Copilot --- src/web/src/components/Chat/Chat.jsx | 58 ++++++++++++++++++++++------------ src/web/src/components/Rooms/Rooms.jsx | 58 ++++++++++++++++++++-------------- 2 files changed, 73 insertions(+), 43 deletions(-) (limited to 'src/web') diff --git a/src/web/src/components/Chat/Chat.jsx b/src/web/src/components/Chat/Chat.jsx index 086d2cd8..39dd1a44 100644 --- a/src/web/src/components/Chat/Chat.jsx +++ b/src/web/src/components/Chat/Chat.jsx @@ -23,6 +23,32 @@ const initialState = { message: '', }; +const ChatMessageHistory = React.memo( + ({ formatTimestamp, messages, selfUsername }) => { + return ( + <> + {messages.map((message) => ( + + + {formatTimestamp(message.timestamp)} + + + {message.direction === 'Out' ? selfUsername : message.username}: + + {message.message} + + ))} + + + ); + }, +); + +ChatMessageHistory.displayName = 'ChatMessageHistory'; + class Chat extends Component { constructor(props) { super(props); @@ -63,6 +89,13 @@ class Chat extends Component { // fetch all of the active conversations (but no messages) let conversations = await chat.getAll(); + // the username '..' breaks nearly everything in slskd because it's a path traversal + // sequence and no API endpoints that expect usernames in the path work + // rather than letting this sit broken, i'm making the choice to filter it out + // eslint-disable-next-line no-warning-comments + // todo: remove this filter when the API can handle '..' + conversations = conversations.filter((f) => f.username !== '..'); + // turn into a map, keyed by username // if there are no active conversations, set to an empty map if (conversations.length === 0) { @@ -257,26 +290,11 @@ class Chat extends Component { - {messages.map((message) => ( - - - {this.formatTimestamp(message.timestamp)} - - - {message.direction === 'Out' - ? user.username - : message.username} - :{' '} - - - {message.message} - - - ))} - + diff --git a/src/web/src/components/Rooms/Rooms.jsx b/src/web/src/components/Rooms/Rooms.jsx index 3d29242b..f6bdb685 100644 --- a/src/web/src/components/Rooms/Rooms.jsx +++ b/src/web/src/components/Rooms/Rooms.jsx @@ -39,6 +39,36 @@ const initialState = { }, }; +const RoomMessageHistory = React.memo( + ({ formatTimestamp, messages, onHandleContextMenu }) => { + return ( + <> + {messages.map((message) => ( +
+ onHandleContextMenu(clickEvent, message) + } + > + + + {formatTimestamp(message.timestamp)} + + {message.username}: + {message.message} + +
+ ))} + + + ); + }, +); + +RoomMessageHistory.displayName = 'RoomMessageHistory'; + class Rooms extends Component { constructor(props) { super(props); @@ -325,29 +355,11 @@ class Rooms extends Component { - {room.messages.map((message) => ( -
- this.handleContextMenu(clickEvent, message) - } - > - - - {this.formatTimestamp(message.timestamp)} - - - {message.username}:{' '} - - - {message.message} - - -
- ))} - +
-- cgit v1.2.3 From e06999e5eec1616d93b34ffbab0eade617d1aaf6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Jun 2026 21:31:33 +0000 Subject: Bump launch-editor from 2.6.0 to 2.14.1 in /src/web Bumps [launch-editor](https://github.com/vitejs/launch-editor) from 2.6.0 to 2.14.1. - [Commits](https://github.com/vitejs/launch-editor/compare/v2.6.0...v2.14.1) --- updated-dependencies: - dependency-name: launch-editor dependency-version: 2.14.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] --- src/web/package-lock.json | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/web') diff --git a/src/web/package-lock.json b/src/web/package-lock.json index 22d9c714..e64bc38d 100644 --- a/src/web/package-lock.json +++ b/src/web/package-lock.json @@ -14304,13 +14304,14 @@ } }, "node_modules/launch-editor": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/launch-editor/-/launch-editor-2.6.0.tgz", - "integrity": "sha512-JpDCcQnyAAzZZaZ7vEiSqL690w7dAEyLao+KC96zBplnYbJS7TYNjvM3M7y3dGz+v7aIsJk3hllWuc0kWAjyRQ==", + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/launch-editor/-/launch-editor-2.14.1.tgz", + "integrity": "sha512-QWBrQsMpH7gPr965dsKD/3cKWiNoTjpATQf++Xq63N6sKRGMwlVXz41O1IZTMfZQgBctD/K5Zt06+/I6pP6+HA==", "dev": true, + "license": "MIT", "dependencies": { - "picocolors": "^1.0.0", - "shell-quote": "^1.7.3" + "picocolors": "^1.1.1", + "shell-quote": "^1.8.4" } }, "node_modules/less": { @@ -18840,10 +18841,14 @@ } }, "node_modules/shell-quote": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.1.tgz", - "integrity": "sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==", + "version": "1.8.4", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.4.tgz", + "integrity": "sha512-VsC6n6vz1ihYYyZZwX7YZSF5l5x36ca17OC+a69h94YqB7X6XLwf+5MOgynYir2SLFUbl8gIYvBo8K8RoNQ6bQ==", "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, "funding": { "url": "https://github.com/sponsors/ljharb" } -- cgit v1.2.3