Repository navigation
Add Send to channel for thread messages #5305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
8cc27ba
Add Send to channel for thread messages
klopez4212 cccf293
Merge remote-tracking branch 'origin/main' into kennylopez-send-to-ch…
klopez4212 dacdf90
Restore shared thread chip styling
klopez4212 4fb733e
fix(desktop): wait for thread messages before sharing
klopez4212 8dff13d
Preserve shared message semantics
klopez4212 394165b
Refine shared thread provenance
klopez4212 530f235
Render thread provenance as a link
klopez4212 bbd4f85
Start shared posts as new message groups
klopez4212 2cc6ee2
Render thread links in the composer
klopez4212 98cc2b8
Align thread links with Inbox chips
klopez4212 19baa51
Underline thread source links on hover
klopez4212 0fbf9bb
Match thread source links to Inbox metadata
klopez4212 3115a60
Use read-state thread source styling
klopez4212 47f8eed
Refine thread source link styling
klopez4212 e37d554
Increase thread source emphasis
klopez4212 3514b71
Limit thread link underline to text
klopez4212 9387e0b
Make thread link hover webview reliable
klopez4212 eab77c9
Keep native thread underline visible
klopez4212 0030d90
Harden send-to-channel edge cases
klopez4212 caec1b5
Preserve edited mention identities
klopez4212 ea757a4
Merge origin/main into kennylopez-send-to-channel
klopez4212 a9ae085
Preserve mentions in partial edits
fea3292
Stabilize thread sharing edit metadata
c7d5de9
fix(desktop): preserve edit mention identities
d1268ab
fix(desktop): preserve mentions in partial edits
cbad00c
Fix thread sharing review edge cases
wesbillman 7811d5c
Merge origin/main into kennylopez-send-to-channel
wesbillman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
desktop/src/features/messages/lib/canSendToChannel.test.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import assert from "node:assert/strict"; | ||
| import test from "node:test"; | ||
|
|
||
| import { | ||
| assertCanSendMessageToChannel, | ||
| canSendMessageToChannel, | ||
| } from "./canSendToChannel.ts"; | ||
|
|
||
| const CURRENT = "a".repeat(64); | ||
| const OWNED_AGENT = "b".repeat(64); | ||
| const OTHER_PERSON = "c".repeat(64); | ||
| const OTHER_AGENT = "d".repeat(64); | ||
|
|
||
| const message = (pubkey) => ({ kind: 9, pubkey }); | ||
| const profiles = { | ||
| [OWNED_AGENT]: { isAgent: true, ownerPubkey: CURRENT }, | ||
| [OTHER_AGENT]: { isAgent: true, ownerPubkey: OTHER_PERSON }, | ||
| }; | ||
|
|
||
| test("send-to-channel permits self-authored messages", () => { | ||
| assert.equal( | ||
| canSendMessageToChannel(message(CURRENT), CURRENT, profiles), | ||
| true, | ||
| ); | ||
| }); | ||
|
|
||
| test("send-to-channel permits messages from an agent owned by the viewer", () => { | ||
| assert.equal( | ||
| canSendMessageToChannel(message(OWNED_AGENT), CURRENT, profiles), | ||
| true, | ||
| ); | ||
| }); | ||
|
|
||
| test("send-to-channel rejects third-party people and agents", () => { | ||
| assert.equal( | ||
| canSendMessageToChannel(message(OTHER_PERSON), CURRENT, profiles), | ||
| false, | ||
| ); | ||
| assert.equal( | ||
| canSendMessageToChannel(message(OTHER_AGENT), CURRENT, profiles), | ||
| false, | ||
| ); | ||
| assert.throws( | ||
| () => | ||
| assertCanSendMessageToChannel(message(OTHER_AGENT), CURRENT, profiles), | ||
| /only send your own or your agents' messages/, | ||
| ); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { canManageMessageForCurrentUser } from "@/features/messages/lib/canManageMessage"; | ||
| import type { TimelineMessage } from "@/features/messages/types"; | ||
| import type { UserProfileLookup } from "@/features/profile/lib/identity"; | ||
|
|
||
| export function canSendMessageToChannel( | ||
| message: TimelineMessage, | ||
| currentPubkey: string | undefined, | ||
| profiles: UserProfileLookup | undefined, | ||
| ): boolean { | ||
| return canManageMessageForCurrentUser(message, currentPubkey, profiles); | ||
|
klopez4212 marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| export function assertCanSendMessageToChannel( | ||
| message: TimelineMessage, | ||
| currentPubkey: string | undefined, | ||
| profiles: UserProfileLookup | undefined, | ||
| ): void { | ||
| if (!canSendMessageToChannel(message, currentPubkey, profiles)) { | ||
| throw new Error("You can only send your own or your agents' messages."); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import assert from "node:assert/strict"; | ||
| import test from "node:test"; | ||
|
|
||
| import { | ||
| buildSentFromThreadTag, | ||
| getSentFromThreadReference, | ||
| getSentFromThreadRootId, | ||
| SENT_FROM_THREAD_TAG, | ||
| summarizeThreadRoot, | ||
| } from "./sentFromThread.ts"; | ||
|
|
||
| test("buildSentFromThreadTag records the normalized root event ID", () => { | ||
| assert.deepEqual(buildSentFromThreadTag(" root-event "), [ | ||
| SENT_FROM_THREAD_TAG, | ||
| "root-event", | ||
| ]); | ||
| }); | ||
|
|
||
| test("buildSentFromThreadTag includes a normalized human excerpt", () => { | ||
| assert.deepEqual(buildSentFromThreadTag("root-event", " Launch plan "), [ | ||
| SENT_FROM_THREAD_TAG, | ||
| "root-event", | ||
| "Launch plan", | ||
| ]); | ||
| }); | ||
|
|
||
| test("buildSentFromThreadTag rejects an empty root event ID", () => { | ||
| assert.throws( | ||
| () => buildSentFromThreadTag(" "), | ||
| /thread root event ID is required/, | ||
| ); | ||
| }); | ||
|
|
||
| test("sent-from-thread references accept an optional excerpt", () => { | ||
| assert.equal( | ||
| getSentFromThreadRootId([ | ||
| ["h", "channel-id"], | ||
| [SENT_FROM_THREAD_TAG, "root-event"], | ||
| ]), | ||
| "root-event", | ||
| ); | ||
| assert.deepEqual( | ||
| getSentFromThreadReference([ | ||
| [SENT_FROM_THREAD_TAG, "root-event", "Root summary"], | ||
| ]), | ||
| { rootEventId: "root-event", rootExcerpt: "Root summary" }, | ||
| ); | ||
| assert.equal( | ||
| getSentFromThreadRootId([ | ||
| [SENT_FROM_THREAD_TAG, "root-event", "summary", "extra"], | ||
| ]), | ||
| null, | ||
| ); | ||
| assert.equal(getSentFromThreadRootId([[SENT_FROM_THREAD_TAG, " "]]), null); | ||
| assert.equal(getSentFromThreadRootId(undefined), null); | ||
| }); | ||
|
|
||
| test("summarizeThreadRoot keeps concise text and ignores media-only roots", () => { | ||
| assert.equal(summarizeThreadRoot(" **Launch** plan "), "Launch plan"); | ||
| assert.equal( | ||
| summarizeThreadRoot(""), | ||
| null, | ||
| ); | ||
| assert.equal( | ||
| summarizeThreadRoot("See [the plan](https://example.com/plan) for details"), | ||
| "See the plan for details", | ||
| ); | ||
| assert.match(summarizeThreadRoot("word ".repeat(30)) ?? "", /…$/); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.