-
Notifications
You must be signed in to change notification settings - Fork 299
Vine proof of concept view + upload/record #3354
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
Changes from all commits
eef7731
79e08a6
c53a765
11851db
204438f
6861eb9
e052d0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "database": "beads.db", | ||
| "jsonl_export": "issues.jsonl" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,3 +7,6 @@ TODO.bak | |
| tags | ||
| build-git-hash.txt | ||
| .build | ||
| .beads/*.db | ||
| .beads/*.db-shm | ||
| .beads/*.db-wal | ||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| "images": [ | ||
| { | ||
| "filename": "vine.fill.svg", | ||
| "idiom": "universal", | ||
| "scale": "1x" | ||
| }, | ||
| { | ||
| "idiom": "universal", | ||
| "scale": "2x", | ||
| "filename": "vine.fill.svg" | ||
| }, | ||
| { | ||
| "idiom": "universal", | ||
| "scale": "3x", | ||
| "filename": "vine.fill.svg" | ||
| } | ||
| ], | ||
| "info": { | ||
| "author": "xcode", | ||
| "version": 1 | ||
| }, | ||
| "properties": { | ||
| "template-rendering-intent": "template" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| "images": [ | ||
| { | ||
| "filename": "vine.svg", | ||
| "idiom": "universal", | ||
| "scale": "1x" | ||
| }, | ||
| { | ||
| "idiom": "universal", | ||
| "scale": "2x", | ||
| "filename": "vine.svg" | ||
| }, | ||
| { | ||
| "idiom": "universal", | ||
| "scale": "3x", | ||
| "filename": "vine.svg" | ||
| } | ||
| ], | ||
| "info": { | ||
| "author": "xcode", | ||
| "version": 1 | ||
| }, | ||
| "properties": { | ||
| "template-rendering-intent": "template" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -44,6 +44,11 @@ class NostrNetworkManager { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private var connectionContinuations: [UUID: CheckedContinuation<Void, Never>] = [:] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// A lock to ensure thread-safe access to the continuations dictionary and connection state | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private let continuationsLock = NSLock() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Tracks relays that were added by features (not user-configured) so we can safely remove them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// without deleting user's relay configuration. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Isolated to `@MainActor` for thread-safe access without locks. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @MainActor private var featureManagedRelays: Set<RelayURL> = [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| init(delegate: Delegate, addNdbToRelayPool: Bool = true) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.delegate = delegate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -264,6 +269,48 @@ class NostrNetworkManager { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .filter { !filters.is_filtered(timeline: .search, relay_id: $0) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Ensures the relay pool is connected to a specific relay, adding it if necessary. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Used by feature-specific code (e.g., Vines) to connect to relays that are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// not part of the user's configured relay list. Tracks the relay so that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// ``disconnectRelay(_:)`` can safely remove it later. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func ensureRelayConnected(_ relayURL: RelayURL) async { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if await pool.get_relay(relayURL) != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await MainActor.run { featureManagedRelays.insert(relayURL) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let descriptor = RelayPool.RelayDescriptor(url: relayURL, info: .readWrite) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try await pool.add_relay(descriptor) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // If the relay already exists we can still connect to it; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // for any other error, log and bail out. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let isAlreadyAdded = await pool.get_relay(relayURL) != nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if !isAlreadyAdded { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Log.debug("Failed to add relay %s: %s", for: .networking, relayURL.id as CVarArg, error.localizedDescription) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await MainActor.run { featureManagedRelays.insert(relayURL) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+283
to
+295
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Silently swallowing
Proposed fix let descriptor = RelayPool.RelayDescriptor(url: relayURL, info: .readWrite)
- try? await pool.add_relay(descriptor)
- await pool.connect(to: [relayURL])
- await MainActor.run { featureManagedRelays.insert(relayURL) }
+ do {
+ try await pool.add_relay(descriptor)
+ await pool.connect(to: [relayURL])
+ await MainActor.run { featureManagedRelays.insert(relayURL) }
+ } catch {
+ Log.warning("Failed to add feature relay %s: %s", for: .networking, relayURL.absoluteString, error.localizedDescription)
+ }
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await pool.connect(to: [relayURL]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+272
to
+297
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the relay already exists in the pool (Lines 278-280), it's unconditionally added to Only insert into Proposed fix func ensureRelayConnected(_ relayURL: RelayURL) async {
if await pool.get_relay(relayURL) != nil {
- await MainActor.run { featureManagedRelays.insert(relayURL) }
+ // Relay already exists — don't claim ownership
return
}
let descriptor = RelayPool.RelayDescriptor(url: relayURL, info: .readWrite)
try? await pool.add_relay(descriptor)
await pool.connect(to: [relayURL])
await MainActor.run { featureManagedRelays.insert(relayURL) }
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Disconnects and removes a relay that was previously added via ``ensureRelayConnected(_:)``. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Only removes relays tracked as feature-managed — user-configured relays are left untouched. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func disconnectRelay(_ relayURL: RelayURL) async { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let isFeatureManaged = await MainActor.run { featureManagedRelays.contains(relayURL) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| guard isFeatureManaged else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Log.debug("Skipping removal of relay %s - not feature-managed", for: .networking, relayURL.id as CVarArg) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| guard await pool.get_relay(relayURL) != nil else { return } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await pool.remove_relay(relayURL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await MainActor.run { featureManagedRelays.remove(relayURL) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // MARK: NWC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // TODO: Move this to NWCManager | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: damus-io/damus
Length of output: 357
Add
beads.dbto.gitignore.The
.beads/metadata.jsonfile referencesbeads.db, which is a SQLite database that should not be committed to version control. Whilebeads.dbdoesn't currently exist in the repository, it's not excluded in.gitignore. Add a pattern to prevent accidental commits if the beads tool generates this database during development.🤖 Prompt for AI Agents