Skip to content

Commit 331bf83

Browse files
npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67dTyler Longwell
andcommitted
chore(desktop): bring ChannelScreen back under the size gate
#1490 and #1487 each landed a few lines in ChannelScreen.tsx and pushed it to 1006, tripping the 1000-line file-size check and turning main's Desktop CI red. Recover the headroom by tightening prose comments (no semantic content dropped) and compacting one ternary the formatter accepts on a single line. No code behavior changes; 999 lines by the checker's count. Co-authored-by: Tyler Longwell <[email protected]> Signed-off-by: Tyler Longwell <[email protected]>
1 parent ee4c9ef commit 331bf83

1 file changed

Lines changed: 19 additions & 25 deletions

File tree

‎desktop/src/features/channels/ui/ChannelScreen.tsx‎

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,9 @@ export function ChannelScreen({
146146
string | null
147147
>(null);
148148
const [editTargetId, setEditTargetId] = React.useState<string | null>(null);
149-
// Thread panel state is URL-backed, but router navigation is intentionally
150-
// deferred out of the click handler. Keep a tiny optimistic override so the
151-
// auxiliary pane can open/close in the urgent render, then let the URL-backed
152-
// state hydrate the real thread contents when it catches up.
149+
// Thread panel state is URL-backed, but router navigation is deferred out
150+
// of the click handler; a tiny optimistic override lets the auxiliary pane
151+
// open/close in the urgent render before the URL-backed state catches up.
153152
const [optimisticOpenThreadHeadId, setOptimisticOpenThreadHeadId] =
154153
React.useState<string | null | undefined>(undefined);
155154
const clearOptimisticThreadOverride = React.useCallback(() => {
@@ -206,16 +205,14 @@ export function ChannelScreen({
206205
if (!activeChannelId || activeChannel?.isMember === false) {
207206
return;
208207
}
209-
// Passive channel-open: advance the marker to the newest top-level message
210-
// only (NIP-RS Option 1). Opening a channel clears the main timeline while
211-
// leaving thread badges and Home inbox thread activity intact until each
212-
// thread itself is read.
208+
// Passive channel-open (NIP-RS Option 1): advance the marker to the newest
209+
// top-level message only, clearing the main timeline while thread badges
210+
// and Home inbox thread activity stay intact until each thread is read.
213211
markChannelRead(activeChannelId, activeReadAt, { topLevelOnly: true });
214212
}, [activeChannel?.isMember, activeChannelId, activeReadAt, markChannelRead]);
215-
// Install the NIP-RS parent resolver. Active `thread:` and `msg:` contexts
216-
// belong to this channel; folding messages to the channel (never another
217-
// message) preserves ancestor/descendant isolation while channel reads still
218-
// cover top-level history. Clear on leave so the parent cannot go stale.
213+
// Install the NIP-RS parent resolver. Active `thread:`/`msg:` contexts fold
214+
// to this channel (never another message), preserving ancestor/descendant
215+
// isolation while channel reads cover top-level history. Clear on leave.
219216
React.useEffect(() => {
220217
if (!activeChannelId) {
221218
setContextParentResolver(null);
@@ -550,9 +547,8 @@ export function ChannelScreen({
550547
: undefined,
551548
[activeChannel, handleToggleReaction],
552549
);
553-
// The menu actions are typed (message) => void; the per-message read-state
554-
// handlers key off the message id (message + subtree). Adapt at the seam so
555-
// the handlers stay id-based and the menu stays message-based.
550+
// The menu actions are typed (message) => void; the read-state handlers
551+
// key off the message id (message + subtree). Adapt at the seam.
556552
const handleMessageMarkUnread = React.useCallback(
557553
(message: TimelineMessage) => handleMarkMessageUnread(message.id),
558554
[handleMarkMessageUnread],
@@ -607,10 +603,9 @@ export function ChannelScreen({
607603
} = useChannelAgentSessions({
608604
activeChannel,
609605
activeChannelId,
610-
// The agent list comes from three queries; treat it as loaded only once
611-
// none of them are in their initial fetch, so a channel with genuinely
612-
// zero agents can still auto-close a stale agentSession param. A disabled
613-
// query (e.g. no active channel) reports isLoading=false, which is fine.
606+
// Loaded only once none of the three agent queries are in their initial
607+
// fetch, so a channel with genuinely zero agents still auto-closes a stale
608+
// agentSession param (a disabled query reports isLoading=false — fine).
614609
agentsLoaded:
615610
!channelMembersQuery.isLoading &&
616611
!managedAgentsQuery.isLoading &&
@@ -640,10 +635,10 @@ export function ChannelScreen({
640635
setThreadReplyTargetId,
641636
setThreadScrollTargetId,
642637
});
643-
// `data !== undefined` is not "loaded": the cache is seeded early by stale
644-
// placeholders and the live subscription. Wait for the history fetch to settle.
645-
// Latch loaded per channel so a later background refetch can't flip back to
646-
// the skeleton — that re-flip is the "skeleton bouncing up and down" on entry.
638+
// `data !== undefined` is not "loaded" (the cache is seeded early by stale
639+
// placeholders and the live subscription); wait for the history fetch to
640+
// settle, latched per channel so a background refetch can't re-flip to the
641+
// skeleton (the "skeleton bouncing up and down" on entry).
647642
const settledChannelIdRef = React.useRef<string | null>(null);
648643
const hasSettledThisChannel =
649644
activeChannelId !== null && settledChannelIdRef.current === activeChannelId;
@@ -667,8 +662,7 @@ export function ChannelScreen({
667662
);
668663
settledChannelIdRef.current = settledChannelId;
669664
// Panel identity (thread/profile/agent session) lives in the URL search
670-
// params, so channel changes and back/forward traversals carry it per
671-
// history entry — only the local ephemeral targets need resetting here.
665+
// params and carries per history entry — only ephemeral targets reset here.
672666
const resetComposerTargets = React.useCallback(
673667
(_channelId: string | null) => {
674668
setExpandedThreadReplyIds(new Set());

0 commit comments

Comments
 (0)