Fixed some context
This commit is contained in:
@ -35,6 +35,5 @@ There's a `<-` arrow on the top right you can click to open the sidebar if it's
|
|||||||
If you've followed the other steps, you should see some activity in the chat page's console, then see a zip file downloaded with all the artifacts correctly mapped inside.
|
If you've followed the other steps, you should see some activity in the chat page's console, then see a zip file downloaded with all the artifacts correctly mapped inside.
|
||||||
|
|
||||||
|
|
||||||
## Changes under consideration
|
## Known bugs
|
||||||
1. Optionally scrape project-level artifacts instead of chat-level artifacts
|
1. Fix the scraper to work with single-artifact chats that don't have a selector button. Not sure how we'll get the artifact name here.
|
||||||
2. Fix the scraper to work with single-artifact chats that don't have a selector button. Not sure how we'll get the artifact name here.
|
|
||||||
|
|||||||
11
src/main.js
11
src/main.js
@ -1,8 +1,17 @@
|
|||||||
async function main() {
|
async function main() {
|
||||||
console.log('Running artifact collector');
|
console.log('Running artifact collector');
|
||||||
|
|
||||||
|
const currentUrl = window.location.href;
|
||||||
|
const isProjectPage = currentUrl.includes('/project/');
|
||||||
|
const isChatPage = currentUrl.includes('/chat/');
|
||||||
|
|
||||||
|
if (!isProjectPage && !isChatPage) {
|
||||||
|
console.log('Not on a project or chat page, exiting');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ProjectMeta.isInProject()) {
|
if (!ProjectMeta.isInProject()) {
|
||||||
console.log('Not in a project chat, exiting');
|
console.log('Not in a project context, exiting');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -215,7 +215,7 @@ const ChatArtifactScraper = {
|
|||||||
try {
|
try {
|
||||||
const content = await this.getArtifact(filename, isSelected);
|
const content = await this.getArtifact(filename, isSelected);
|
||||||
|
|
||||||
if (filename === 'files.txt') {
|
if (filename.toLowerCase().indexOf('files.txt') !== -1) {
|
||||||
fileMap = content;
|
fileMap = content;
|
||||||
console.log(`✓ Found files.txt - storing in fileMap`);
|
console.log(`✓ Found files.txt - storing in fileMap`);
|
||||||
} else {
|
} else {
|
||||||
@ -320,7 +320,6 @@ const ProjectArtifactScraper = {
|
|||||||
const artifactList = this.getArtifactListItems();
|
const artifactList = this.getArtifactListItems();
|
||||||
|
|
||||||
if (Object.keys(artifactList).length === 0) {
|
if (Object.keys(artifactList).length === 0) {
|
||||||
console.log('Nada');
|
|
||||||
return { artifacts: artifactCollection, fileMap: fileMap };
|
return { artifacts: artifactCollection, fileMap: fileMap };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,7 +329,7 @@ const ProjectArtifactScraper = {
|
|||||||
try {
|
try {
|
||||||
const content = await this.getArtifact(filename, isSelected);
|
const content = await this.getArtifact(filename, isSelected);
|
||||||
|
|
||||||
if (filename === 'files.txt') {
|
if (filename.toLowerCase().indexOf('files.txt') !== -1) {
|
||||||
fileMap = content;
|
fileMap = content;
|
||||||
console.log(`✓ Found files.txt - storing in fileMap`);
|
console.log(`✓ Found files.txt - storing in fileMap`);
|
||||||
} else {
|
} else {
|
||||||
@ -351,7 +350,6 @@ const ProjectArtifactScraper = {
|
|||||||
|
|
||||||
const ArtifactScraper = {
|
const ArtifactScraper = {
|
||||||
async collectArtifacts() {
|
async collectArtifacts() {
|
||||||
console.log('Collecting')
|
|
||||||
if (ProjectMeta.isProjectChat()) {
|
if (ProjectMeta.isProjectChat()) {
|
||||||
console.log('Detected project chat - using ChatArtifactScraper');
|
console.log('Detected project chat - using ChatArtifactScraper');
|
||||||
return await ChatArtifactScraper.collectArtifacts();
|
return await ChatArtifactScraper.collectArtifacts();
|
||||||
|
|||||||
Reference in New Issue
Block a user