Skip to content
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

Unread ai summary #1880

Merged
merged 8 commits into from
Nov 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add ai message summary to ChatViewController
Signed-off-by: Marcel Müller <marcel-mueller@gmx.de>
  • Loading branch information
SystemKeeper committed Nov 21, 2024
commit b4274f047b59d58238ef675dfe43308b76a2f101
8 changes: 8 additions & 0 deletions NextcloudTalk.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -58,6 +58,8 @@
1F1DF8442C64006E00E5EA86 /* SignalingParticipant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F1DF8422C64006E00E5EA86 /* SignalingParticipant.swift */; };
1F1DF8452C64006E00E5EA86 /* SignalingParticipant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F1DF8422C64006E00E5EA86 /* SignalingParticipant.swift */; };
1F1DF8462C64006E00E5EA86 /* SignalingParticipant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F1DF8422C64006E00E5EA86 /* SignalingParticipant.swift */; };
1F20582A2CEA404F00AAA673 /* AiSummaryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F2058292CEA404F00AAA673 /* AiSummaryViewController.swift */; };
1F20582C2CEA405700AAA673 /* AiSummaryViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1F20582B2CEA405700AAA673 /* AiSummaryViewController.xib */; };
1F24B5A228E0648600654457 /* ReferenceGithubView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F24B5A128E0648600654457 /* ReferenceGithubView.swift */; };
1F24B5A428E0649200654457 /* ReferenceGithubView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1F24B5A328E0649200654457 /* ReferenceGithubView.xib */; };
1F35F8E22AEEBAF900044BDA /* InputbarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F5A24322ADA77DA009939FE /* InputbarViewController.swift */; };
@@ -675,6 +677,8 @@
1F1DF83B2C5C17AF00E5EA86 /* TalkActor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TalkActor.swift; sourceTree = "<group>"; };
1F1DF8402C63C25900E5EA86 /* UnitNCDatabaseManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnitNCDatabaseManager.swift; sourceTree = "<group>"; };
1F1DF8422C64006E00E5EA86 /* SignalingParticipant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignalingParticipant.swift; sourceTree = "<group>"; };
1F2058292CEA404F00AAA673 /* AiSummaryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AiSummaryViewController.swift; sourceTree = "<group>"; };
1F20582B2CEA405700AAA673 /* AiSummaryViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AiSummaryViewController.xib; sourceTree = "<group>"; };
1F21A0622C77863500ED8C0C /* nb-NO */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "nb-NO"; path = "nb-NO.lproj/InfoPlist.strings"; sourceTree = "<group>"; };
1F21A0632C77863500ED8C0C /* nb-NO */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "nb-NO"; path = "nb-NO.lproj/Localizable.strings"; sourceTree = "<group>"; };
1F21A0642C77863500ED8C0C /* nb-NO */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = "nb-NO"; path = "nb-NO.lproj/Localizable.stringsdict"; sourceTree = "<group>"; };
@@ -2120,6 +2124,8 @@
1F35F8FA2AEEDBC600044BDA /* ChatViewControllerExtension.swift */,
2C4230F62B207AB00013E1FA /* ContextChatViewController.swift */,
1F0B0A712BA264540073FF8D /* MentionSuggestion.swift */,
1F2058292CEA404F00AAA673 /* AiSummaryViewController.swift */,
1F20582B2CEA405700AAA673 /* AiSummaryViewController.xib */,
);
name = Chat;
sourceTree = "<group>";
@@ -2514,6 +2520,7 @@
2C5BFBFC2891598A00E75118 /* PollResultTableViewCell.xib in Resources */,
1FADECDA2B8227B1007AD94B /* FederationInvitationCell.xib in Resources */,
1FEC459C2A02BCAE00A636AA /* ReferenceGithubPermalinkView.xib in Resources */,
1F20582C2CEA405700AAA673 /* AiSummaryViewController.xib in Resources */,
1FE0C56C2A0531200083576A /* ReferenceTalkView.xib in Resources */,
1F1B50382B8E070100B0F2F4 /* BaseChatTableViewCell.xib in Resources */,
2C5BFBF828902E3700E75118 /* PollFooterView.xib in Resources */,
@@ -3033,6 +3040,7 @@
1F66B71F29FA703B003FB168 /* TypingIndicatorView.swift in Sources */,
1F35F9042AEEDF0E00044BDA /* AutoCompletionTableViewCell.m in Sources */,
2C42ADB420B58E6300296DEA /* NCChatController.m in Sources */,
1F20582A2CEA404F00AAA673 /* AiSummaryViewController.swift in Sources */,
1FD9182928C55A73009092AB /* BGTaskHelper.swift in Sources */,
1F66B72929FA936E003FB168 /* SLKDefaultReplyView.m in Sources */,
1F785DDD2707865F00AC4B40 /* VoiceMessageTranscribeViewController.m in Sources */,
73 changes: 73 additions & 0 deletions NextcloudTalk/AiSummaryViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
// SPDX-License-Identifier: GPL-3.0-or-later
//

import UIKit

class AiSummaryViewController: UIViewController {

private var summaryText: String = ""

@IBOutlet weak var warningView: UIView!
@IBOutlet weak var warningTextLabel: UILabel!
@IBOutlet weak var saveToNoteToSelf: NCButton!
@IBOutlet weak var summaryTextView: UITextView!

init(summaryText: String) {
self.summaryText = summaryText

super.init(nibName: nil, bundle: nil)
}

required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}

override func viewDidLoad() {
super.viewDidLoad()

NCAppBranding.styleViewController(self)

let barButtonItem = UIBarButtonItem(title: nil, style: .plain, target: nil, action: nil)
barButtonItem.primaryAction = UIAction(title: NSLocalizedString("Close", comment: ""), handler: { [unowned self] _ in
self.dismiss(animated: true)
})
self.navigationItem.rightBarButtonItems = [barButtonItem]

saveToNoteToSelf.setTitle(NSLocalizedString("Save to 'Note to self'", comment: ""), for: .normal)
saveToNoteToSelf.setButtonStyle(style: .primary)

warningView.layer.cornerRadius = 8
warningView.layer.borderColor = NCAppBranding.placeholderColor().cgColor
warningView.layer.borderWidth = 1
warningView.layer.masksToBounds = true

warningTextLabel.text = NSLocalizedString("This summary is AI generated and may contain mistakes.", comment: "")

summaryTextView.text = self.summaryText
}

@IBAction func saveToNoteToSelfPressed(_ sender: Any) {
let activeAccount = NCDatabaseManager.sharedInstance().activeAccount()

self.saveToNoteToSelf.setButtonEnabled(enabled: false)

NCAPIController.sharedInstance().getNoteToSelfRoom(forAccount: activeAccount) { roomDict, error in
if error == nil, let room = NCRoom(dictionary: roomDict, andAccountId: activeAccount.accountId) {

NCAPIController.sharedInstance().sendChatMessage(self.summaryTextView.text, toRoom: room.token, displayName: nil, replyTo: -1, referenceId: nil, silently: false, for: activeAccount) { error in
if error == nil {
NotificationPresenter.shared().present(text: NSLocalizedString("Added note to self", comment: ""), dismissAfterDelay: 5.0, includedStyle: .success)
} else {
self.saveToNoteToSelf.setButtonEnabled(enabled: true)
NotificationPresenter.shared().present(text: NSLocalizedString("An error occurred while adding note", comment: ""), dismissAfterDelay: 5.0, includedStyle: .error)
}
}
} else {
self.saveToNoteToSelf.setButtonEnabled(enabled: true)
NotificationPresenter.shared().present(text: NSLocalizedString("An error occurred while adding note", comment: ""), dismissAfterDelay: 5.0, includedStyle: .error)
}
}
}
}
111 changes: 111 additions & 0 deletions NextcloudTalk/AiSummaryViewController.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23504" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23506"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="AiSummaryViewController" customModule="NextcloudTalk" customModuleProvider="target">
<connections>
<outlet property="saveToNoteToSelf" destination="d2N-C7-sYL" id="gAs-3g-Nhb"/>
<outlet property="summaryTextView" destination="kWW-BG-TWM" id="KP2-kO-EM5"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
<outlet property="warningTextLabel" destination="gUd-g3-bka" id="9Le-zN-hR3"/>
<outlet property="warningView" destination="aZn-kU-a4A" id="rry-r5-a8s"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="kWW-BG-TWM">
<rect key="frame" x="10" y="102" width="394" height="652"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<mutableString key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut lLorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in </mutableString>
<color key="textColor" systemColor="labelColor"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalSpacing" alignment="center" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="HDS-I5-5AY">
<rect key="frame" x="10" y="764" width="394" height="98"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="aZn-kU-a4A" userLabel="Warning View">
<rect key="frame" x="77" y="0.0" width="240" height="50"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="AI Warning" textAlignment="natural" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gUd-g3-bka">
<rect key="frame" x="15" y="10" width="215" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="4zd-CF-bax">
<rect key="frame" x="0.0" y="0.0" width="5" height="50"/>
<color key="backgroundColor" systemColor="systemYellowColor"/>
<constraints>
<constraint firstAttribute="width" constant="5" id="rRU-wl-5VU"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="gUd-g3-bka" secondAttribute="bottom" constant="10" id="598-zr-uee"/>
<constraint firstItem="gUd-g3-bka" firstAttribute="top" secondItem="aZn-kU-a4A" secondAttribute="top" constant="10" id="Cct-5f-OBw"/>
<constraint firstItem="4zd-CF-bax" firstAttribute="leading" secondItem="aZn-kU-a4A" secondAttribute="leading" id="TU1-V9-cjP"/>
<constraint firstItem="gUd-g3-bka" firstAttribute="leading" secondItem="4zd-CF-bax" secondAttribute="trailing" constant="10" id="dvf-Bd-Lav"/>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="20" id="nAq-tm-7xg"/>
<constraint firstItem="4zd-CF-bax" firstAttribute="top" secondItem="aZn-kU-a4A" secondAttribute="top" id="naM-oV-9qs"/>
<constraint firstAttribute="trailing" secondItem="gUd-g3-bka" secondAttribute="trailing" constant="10" id="nw6-dW-faE"/>
<constraint firstAttribute="bottom" secondItem="4zd-CF-bax" secondAttribute="bottom" id="tDg-eA-ama"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="d2N-C7-sYL" userLabel="Save to note to self" customClass="NCButton" customModule="NextcloudTalk" customModuleProvider="target">
<rect key="frame" x="148" y="58" width="98" height="40"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" id="3r9-cH-CLj"/>
<constraint firstAttribute="height" constant="40" id="hGU-lZ-L60"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<inset key="contentEdgeInsets" minX="24" minY="0.0" maxX="24" maxY="0.0"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="Button">
<color key="titleColor" systemColor="labelColor"/>
</state>
<connections>
<action selector="saveToNoteToSelfPressed:" destination="-1" eventType="touchUpInside" id="KvC-u8-Hcf"/>
</connections>
</button>
</subviews>
</stackView>
</subviews>
<viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="HDS-I5-5AY" firstAttribute="top" secondItem="kWW-BG-TWM" secondAttribute="bottom" constant="10" id="C6w-nB-yaf"/>
<constraint firstItem="kWW-BG-TWM" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" constant="10" id="L3p-dS-lyN"/>
<constraint firstItem="HDS-I5-5AY" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" constant="10" id="ZvA-oB-7uy"/>
<constraint firstItem="fnl-2z-Ty3" firstAttribute="bottom" secondItem="HDS-I5-5AY" secondAttribute="bottom" id="a1b-FO-AY1"/>
<constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="kWW-BG-TWM" secondAttribute="trailing" constant="10" id="eih-rD-OcA"/>
<constraint firstItem="kWW-BG-TWM" firstAttribute="top" secondItem="fnl-2z-Ty3" secondAttribute="top" constant="10" id="m5L-aD-vsu"/>
<constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="HDS-I5-5AY" secondAttribute="trailing" constant="10" id="zeZ-gu-9BY"/>
</constraints>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
<point key="canvasLocation" x="82.608695652173921" y="91.741071428571431"/>
</view>
</objects>
<resources>
<systemColor name="labelColor">
<color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="systemYellowColor">
<color red="1" green="0.80000000000000004" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
Loading